summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-02-21 11:58:03 +0100
committerAndreas Schneider <asn@cryptomilk.org>2014-02-21 16:30:14 +0100
commita1e707b30ad819b15445d785819516ad58da4aa2 (patch)
tree217d041fee5b4f8450a494dc039b129c7f85159b
parent1e56a5646d30594e3174a9811d5b1bb7bd4bd77d (diff)
downloadcmocka-a1e707b30ad819b15445d785819516ad58da4aa2.tar.gz
cmocka-a1e707b30ad819b15445d785819516ad58da4aa2.tar.bz2
cmocka-a1e707b30ad819b15445d785819516ad58da4aa2.zip
Enable warning Wundef
It is better to use "#ifdef" for testing macros instead of "#if" In header file, "#ifdef DOXYGEN" was used 30 times and "#if DOXYGEN" 23 times. This patch makes it consistent and enable warning Wundef to prevent this kind of issues. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake2
-rw-r--r--doc/index.html4
-rw-r--r--example/allocate_module.c2
-rw-r--r--example/assert_module.c2
-rw-r--r--example/calculator.c2
-rw-r--r--include/cmocka.h52
-rw-r--r--src/cmocka.c2
7 files changed, 33 insertions, 33 deletions
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
index 7b65720..4fb0aed 100644
--- a/cmake/Modules/DefineCompilerFlags.cmake
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -13,7 +13,7 @@ if (UNIX AND NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute -Wundef")
# with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC)
diff --git a/doc/index.html b/doc/index.html
index 8db0247..5f7c5a7 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -137,7 +137,7 @@ calls to <b>mock_assert()</b> occur during the function called via
#include &lt;assert.h&gt;
// If unit testing is enabled override assert with mock_assert().
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
extern void mock_assert(const int result, const char* const expression,
const char * const file, const int line);
#undef assert
@@ -285,7 +285,7 @@ the test application to exit prematurely.</p>
<listing>
#include &lt;malloc.h&gt;
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
extern void* _test_malloc(const size_t size, const char* file, const int line);
extern void* _test_calloc(const size_t number_of_elements, const size_t size,
const char* file, const int line);
diff --git a/example/allocate_module.c b/example/allocate_module.c
index 295e10e..3c4fb49 100644
--- a/example/allocate_module.c
+++ b/example/allocate_module.c
@@ -22,7 +22,7 @@
#include <sys/types.h>
#include <stdlib.h>
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
extern void* _test_malloc(const size_t size, const char* file, const int line);
extern void* _test_calloc(const size_t number_of_elements, const size_t size,
const char* file, const int line);
diff --git a/example/assert_module.c b/example/assert_module.c
index bb75aaa..381069b 100644
--- a/example/assert_module.c
+++ b/example/assert_module.c
@@ -18,7 +18,7 @@
#include "assert_module.h"
/* If unit testing is enabled override assert with mock_assert(). */
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
extern void mock_assert(const int result, const char* const expression,
const char * const file, const int line);
#undef assert
diff --git a/example/calculator.c b/example/calculator.c
index 684fb9b..307b551 100644
--- a/example/calculator.c
+++ b/example/calculator.c
@@ -28,7 +28,7 @@
#include <string.h>
/* If this is being built for a unit test. */
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
/* Redirect printf to a function in the test application so it's possible to
* test the standard output. */
diff --git a/include/cmocka.h b/include/cmocka.h
index a3544b7..0047df9 100644
--- a/include/cmocka.h
+++ b/include/cmocka.h
@@ -384,7 +384,7 @@ void expect_check(#function, #parameter, #check_function, const void *check_data
cast_to_largest_integral_type(check_data), NULL, 0)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is part of the provided
* array.
@@ -405,7 +405,7 @@ void expect_in_set(#function, #parameter, uintmax_t value_array[]);
expect_in_set_count(function, parameter, value_array, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is part of the provided
* array.
@@ -431,7 +431,7 @@ void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t
sizeof(value_array) / sizeof((value_array)[0]), count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is not part of the
* provided array.
@@ -452,7 +452,7 @@ void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
expect_not_in_set_count(function, parameter, value_array, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is not part of the
* provided array.
@@ -480,7 +480,7 @@ void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], siz
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check a parameter is inside a numerical range.
* The check would succeed if minimum <= value <= maximum.
@@ -503,7 +503,7 @@ void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum
expect_in_range_count(function, parameter, minimum, maximum, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check a parameter is inside a
* numerical range. The check would succeed if minimum <= value <= maximum.
@@ -531,7 +531,7 @@ void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t m
maximum, count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check a parameter is outside a numerical range.
* The check would succeed if minimum > value > maximum.
@@ -554,7 +554,7 @@ void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t max
expect_not_in_range_count(function, parameter, minimum, maximum, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check a parameter is outside a
* numerical range. The check would succeed if minimum > value > maximum.
@@ -583,7 +583,7 @@ void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax
minimum, maximum, count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if a parameter is the given value.
*
@@ -603,7 +603,7 @@ void expect_value(#function, #parameter, uintmax_t value);
expect_value_count(function, parameter, value, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check if a parameter is the given value.
*
@@ -628,7 +628,7 @@ void expect_value_count(#function, #parameter, uintmax_t value, size_t count);
cast_to_largest_integral_type(value), count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if a parameter isn't the given value.
*
@@ -648,7 +648,7 @@ void expect_not_value(#function, #parameter, uintmax_t value);
expect_not_value_count(function, parameter, value, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check if a parameter isn't the given value.
*
@@ -673,7 +673,7 @@ void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count
cast_to_largest_integral_type(value), count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is equal to the
* provided string.
@@ -694,7 +694,7 @@ void expect_string(#function, #parameter, const char *string);
expect_string_count(function, parameter, string, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value is equal to the
* provided string.
@@ -720,7 +720,7 @@ void expect_string_count(#function, #parameter, const char *string, size_t count
(const char*)(string), count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value isn't equal to the
* provided string.
@@ -741,7 +741,7 @@ void expect_not_string(#function, #parameter, const char *string);
expect_not_string_count(function, parameter, string, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter value isn't equal to the
* provided string.
@@ -767,7 +767,7 @@ void expect_not_string_count(#function, #parameter, const char *string, size_t c
(const char*)(string), count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter does match an area of memory.
*
@@ -789,7 +789,7 @@ void expect_memory(#function, #parameter, void *memory, size_t size);
expect_memory_count(function, parameter, memory, size, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check if the parameter does match an area
* of memory.
@@ -817,7 +817,7 @@ void expect_memory_count(#function, #parameter, void *memory, size_t size, size_
(const void*)(memory), size, count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if the parameter doesn't match an area of
* memory.
@@ -840,7 +840,7 @@ void expect_not_memory(#function, #parameter, void *memory, size_t size);
expect_not_memory_count(function, parameter, memory, size, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check if the parameter doesn't match an
* area of memory.
@@ -869,7 +869,7 @@ void expect_not_memory_count(#function, #parameter, void *memory, size_t size, s
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to check if a parameter (of any value) has been passed.
*
@@ -887,7 +887,7 @@ void expect_any(#function, #parameter);
expect_any_count(function, parameter, 1)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Add an event to repeatedly check if a parameter (of any value) has
* been passed.
@@ -910,7 +910,7 @@ void expect_any_count(#function, #parameter, size_t count);
_expect_any(#function, #parameter, __FILE__, __LINE__, count)
#endif
-#if DOXYGEN
+#ifdef DOXYGEN
/**
* @brief Determine whether a function parameter is correct.
*
@@ -1431,7 +1431,7 @@ int run_tests(const UnitTest tests[]);
* @return A pointer to the allocated memory or NULL on error.
*
* @code
- * #if UNIT_TESTING
+ * #ifdef UNIT_TESTING
* extern void* _test_malloc(const size_t size, const char* file, const int line);
*
* #define malloc(size) _test_malloc(size, __FILE__, __LINE__)
@@ -1483,7 +1483,7 @@ void test_free(void *ptr);
#endif
/* Redirect malloc, calloc and free to the unit test allocators. */
-#if UNIT_TESTING
+#ifdef UNIT_TESTING
#define malloc test_malloc
#define calloc test_calloc
#define free test_free
@@ -1524,7 +1524,7 @@ void test_free(void *ptr);
* @param[in] line The line mock_assert() is called.
*
* @code
- * #if UNIT_TESTING
+ * #ifdef UNIT_TESTING
* extern void mock_assert(const int result, const char* const expression,
* const char * const file, const int line);
*
diff --git a/src/cmocka.c b/src/cmocka.c
index b4de262..76cd783 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -1697,7 +1697,7 @@ int _run_test(
#ifdef _WIN32
handle_exceptions = !IsDebuggerPresent();
#endif /* _WIN32 */
-#if UNIT_TESTING_DEBUG
+#ifdef UNIT_TESTING_DEBUG
handle_exceptions = 0;
#endif /* UNIT_TESTING_DEBUG */