From 64af18ddda1197497c5308e1f153c45a97b09ec1 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Wed, 27 Mar 2013 02:28:45 +0000 Subject: Fix -Wshadow that happens with some old versions of gcc (not mine, for some reason). Don't use g_assert_cmpuint, since it apparently causes warnings on windows that I don't know how to get rid of safely without breaking the conditions being checked. svn path=/trunk/; revision=48575 --- epan/wmem/wmem_allocator_block.c | 18 +++++++++--------- epan/wmem/wmem_test.c | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/epan/wmem/wmem_allocator_block.c b/epan/wmem/wmem_allocator_block.c index 682aa97c94..08a1e490dc 100644 --- a/epan/wmem/wmem_allocator_block.c +++ b/epan/wmem/wmem_allocator_block.c @@ -173,19 +173,19 @@ wmem_block_verify_chunk_chain(wmem_block_chunk_t *chunk) { guint32 total_len = 0; - g_assert_cmpuint(chunk->prev, ==, 0); + g_assert(chunk->prev == 0); do { total_len += chunk->len; if (WMEM_CHUNK_NEXT(chunk)) { - g_assert_cmpuint(chunk->len, ==, WMEM_CHUNK_NEXT(chunk)->prev); + g_assert(chunk->len == WMEM_CHUNK_NEXT(chunk)->prev); } chunk = WMEM_CHUNK_NEXT(chunk); } while (chunk); - g_assert_cmpuint(total_len, ==, WMEM_BLOCK_SIZE); + g_assert(total_len == WMEM_BLOCK_SIZE); } static void @@ -312,7 +312,7 @@ wmem_block_add_to_free_list_after(wmem_block_allocator_t *allocator, wmem_block_free_t *freeChunk; g_assert(!chunk->used); - g_assert_cmpuint(WMEM_CHUNK_DATA_LEN(chunk), >=, sizeof(wmem_block_free_t)); + g_assert(WMEM_CHUNK_DATA_LEN(chunk) >= sizeof(wmem_block_free_t)); freeChunk = WMEM_GET_FREE(chunk); @@ -450,7 +450,7 @@ wmem_block_split_free_chunk(wmem_block_allocator_t *allocator, gboolean last; g_assert(!chunk->used); - g_assert_cmpuint(WMEM_CHUNK_DATA_LEN(chunk), >=, size); + g_assert(WMEM_CHUNK_DATA_LEN(chunk) >= size); aligned_size = WMEM_ALIGN_SIZE(size); @@ -559,7 +559,7 @@ wmem_block_split_used_chunk(wmem_block_allocator_t *allocator, gboolean last; g_assert(chunk->used); - g_assert_cmpuint(WMEM_CHUNK_DATA_LEN(chunk), >=, size); + g_assert(WMEM_CHUNK_DATA_LEN(chunk) >= size); aligned_size = WMEM_ALIGN_SIZE(size); @@ -657,7 +657,7 @@ wmem_block_alloc(void *private_data, const size_t size) /* We can't allocate more than will fit in a block (less our header), * which is an awful lot. */ - g_assert_cmpuint(size, <, WMEM_BLOCK_SIZE - sizeof(wmem_block_chunk_t)); + g_assert(size < WMEM_BLOCK_SIZE - sizeof(wmem_block_chunk_t)); if (allocator->free_list_head == NULL) { /* No free chunks at all, grab a new block */ @@ -681,13 +681,13 @@ wmem_block_alloc(void *private_data, const size_t size) chunk = allocator->free_list_head; /* if we still don't have the space at this point, something is wrong */ - g_assert_cmpuint(size, <=, WMEM_CHUNK_DATA_LEN(chunk)); + g_assert(size <= WMEM_CHUNK_DATA_LEN(chunk)); /* Split our chunk into two to preserve any trailing free space */ wmem_block_split_free_chunk(allocator, chunk, size); /* if our split reduced our size too much, something went wrong */ - g_assert_cmpuint(size, <=, WMEM_CHUNK_DATA_LEN(chunk)); + g_assert(size <= WMEM_CHUNK_DATA_LEN(chunk)); /* the resulting chunk should not be in the free list */ g_assert(chunk != allocator->free_list_head); diff --git a/epan/wmem/wmem_test.c b/epan/wmem/wmem_test.c index b5ecbd1196..433045ea48 100644 --- a/epan/wmem/wmem_test.c +++ b/epan/wmem/wmem_test.c @@ -102,18 +102,19 @@ wmem_test_block_allocator(void) /* Run ~64,000 iterations */ for (i=0; i<1024*64; i++) { - gint index; + gint ptrs_index; gint new_size; - /* returns value 0 <= x < MAX_SIMULTANEOUS_ALLOCS which is a valid index into ptrs */ - index = g_test_rand_int_range(0, MAX_SIMULTANEOUS_ALLOCS); + /* returns value 0 <= x < MAX_SIMULTANEOUS_ALLOCS which is a valid + * index into ptrs */ + ptrs_index = g_test_rand_int_range(0, MAX_SIMULTANEOUS_ALLOCS); - if (ptrs[index] == NULL) { + if (ptrs[ptrs_index] == NULL) { /* if that index is unused, allocate some random amount of memory * between 0 and MAX_ALLOC_SIZE */ new_size = g_test_rand_int_range(0, MAX_ALLOC_SIZE); - ptrs[index] = (char *) wmem_alloc0(allocator, new_size); + ptrs[ptrs_index] = (char *) wmem_alloc0(allocator, new_size); } else if (g_test_rand_bit()) { /* the index is used, and our random bit has determined we will be @@ -122,17 +123,17 @@ wmem_test_block_allocator(void) * new memory */ new_size = g_test_rand_int_range(0, MAX_ALLOC_SIZE); - ptrs[index] = (char *) wmem_realloc(allocator, ptrs[index], - new_size); + ptrs[ptrs_index] = (char *) wmem_realloc(allocator, + ptrs[ptrs_index], new_size); - memset(ptrs[index], 0, new_size); + memset(ptrs[ptrs_index], 0, new_size); } else { /* the index is used, and our random bit has determined we will be * freeing instead of reallocating. Do so and NULL the pointer for * the next iteration. */ - wmem_free(allocator, ptrs[index]); - ptrs[index] = NULL; + wmem_free(allocator, ptrs[ptrs_index]); + ptrs[ptrs_index] = NULL; } wmem_block_verify(allocator); } -- cgit v1.2.3