cmocka: Use defines for WILL_RETURN values
authorAndreas Schneider <asn@cryptomilk.org>
Wed, 21 Sep 2016 09:21:28 +0000 (11:21 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 21 Sep 2016 09:21:28 +0000 (11:21 +0200)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
include/cmocka.h
src/cmocka.c

index fecd873..282963d 100644 (file)
@@ -149,6 +149,9 @@ cast_to_largest_integral_type(cast_to_pointer_integral_type(value))
 #define CMOCKA_DEPRECATED
 #endif
 
+#define WILL_RETURN_ALWAYS -1
+#define WILL_RETURN_ONCE -2
+
 /**
  * @defgroup cmocka_mock Mock Objects
  * @ingroup cmocka
@@ -338,7 +341,7 @@ void will_return_count(#function, LargestIntegralType value, int count);
 void will_return_always(#function, LargestIntegralType value);
 #else
 #define will_return_always(function, value) \
-    will_return_count(function, (value), -1)
+    will_return_count(function, (value), WILL_RETURN_ALWAYS)
 #endif
 
 #ifdef DOXYGEN
@@ -366,7 +369,7 @@ void will_return_always(#function, LargestIntegralType value);
 void will_return_maybe(#function, LargestIntegralType value);
 #else
 #define will_return_maybe(function, value) \
-    will_return_count(function, (value), -2)
+    will_return_count(function, (value), WILL_RETURN_ONCE)
 #endif
 /** @} */
 
index 9300f04..829dd7a 100644 (file)
@@ -691,7 +691,7 @@ static int get_symbol_value(
             return_value = value_node->refcount;
             if (value_node->refcount - 1 == 0) {
                 list_remove_free(value_node, NULL, NULL);
-            } else if (value_node->refcount > -2) {
+            } else if (value_node->refcount > WILL_RETURN_ONCE) {
                 --value_node->refcount;
             }
         } else {