summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2016-09-21 11:21:28 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-09-21 11:21:28 +0200
commit4d7c402482cf2b205ea94b73c6b3206d8964272e (patch)
tree08678df06568baca1dc4cc451ee2803e9edc4511
parentd821fccad2cb0a0e0fc0de41fce6a2ee23df5367 (diff)
downloadcmocka-4d7c402482cf2b205ea94b73c6b3206d8964272e.tar.gz
cmocka-4d7c402482cf2b205ea94b73c6b3206d8964272e.tar.bz2
cmocka-4d7c402482cf2b205ea94b73c6b3206d8964272e.zip
cmocka: Use defines for WILL_RETURN values
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--include/cmocka.h7
-rw-r--r--src/cmocka.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/include/cmocka.h b/include/cmocka.h
index fecd873..282963d 100644
--- a/include/cmocka.h
+++ b/include/cmocka.h
@@ -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
/** @} */
diff --git a/src/cmocka.c b/src/cmocka.c
index 9300f04..829dd7a 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -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 {