diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-03-21 14:30:44 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-03-21 14:30:44 +0100 |
commit | bf77d9eb377ca9072bb81aa304edfdf23bfc2e16 (patch) | |
tree | fafbf3dc67892a4d84ef845e6758065e00144488 | |
parent | eaa37d90adadbba812af9fc67edc9f166bba1f3f (diff) | |
download | cmocka-bf77d9eb377ca9072bb81aa304edfdf23bfc2e16.tar.gz cmocka-bf77d9eb377ca9072bb81aa304edfdf23bfc2e16.tar.xz cmocka-bf77d9eb377ca9072bb81aa304edfdf23bfc2e16.zip |
src: Fix size type for allocated_blocks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | src/cmocka.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/cmocka.c b/src/cmocka.c index 3fa5cce..92db93b 100644 --- a/src/cmocka.c +++ b/src/cmocka.c @@ -1952,10 +1952,10 @@ static const ListNode* check_point_allocated_blocks(void) { /* Display the blocks allocated after the specified check point. This * function returns the number of blocks displayed. */ -static int display_allocated_blocks(const ListNode * const check_point) { +static size_t display_allocated_blocks(const ListNode * const check_point) { const ListNode * const head = get_allocated_blocks_list(); const ListNode *node; - int allocated_blocks = 0; + size_t allocated_blocks = 0; assert_non_null(check_point); assert_non_null(check_point->next); @@ -1964,14 +1964,14 @@ static int display_allocated_blocks(const ListNode * const check_point) { (const MallocBlockInfo*)node->value; assert_non_null(block_info); - if (!allocated_blocks) { + if (allocated_blocks == 0) { cm_print_error("Blocks allocated...\n"); } cm_print_error(SOURCE_LOCATION_FORMAT ": note: block %p allocated here\n", block_info->location.file, block_info->location.line, block_info->block); - allocated_blocks ++; + allocated_blocks++; } return allocated_blocks; } @@ -1997,10 +1997,10 @@ static void free_allocated_blocks(const ListNode * const check_point) { /* Fail if any any blocks are allocated after the specified check point. */ static void fail_if_blocks_allocated(const ListNode * const check_point, const char * const test_name) { - const int allocated_blocks = display_allocated_blocks(check_point); - if (allocated_blocks) { + const size_t allocated_blocks = display_allocated_blocks(check_point); + if (allocated_blocks > 0) { free_allocated_blocks(check_point); - cm_print_error("ERROR: %s leaked %d block(s)\n", test_name, + cm_print_error("ERROR: %s leaked %zu block(s)\n", test_name, allocated_blocks); exit_test(1); } |