From 4d7c402482cf2b205ea94b73c6b3206d8964272e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 21 Sep 2016 11:21:28 +0200 Subject: cmocka: Use defines for WILL_RETURN values Signed-off-by: Andreas Schneider --- include/cmocka.h | 7 +++++-- src/cmocka.c | 2 +- 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 { -- cgit v1.2.3