From: Trond Norbye Date: Tue, 22 Feb 2011 13:41:58 +0000 (+0100) Subject: Don't use __attribute__((unused)) X-Git-Tag: 0.51~31^2~2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6c2bd52dfa24287c856b0b679270b7f7681333a5;p=m6w6%2Flibmemcached Don't use __attribute__((unused)) It's not supported by all compilers, and they will most likely spit out a warning about an unknown attribute. Since we're treating warnings as errors this stops the compilation.. --- diff --git a/clients/memdump.c b/clients/memdump.c index 3654be2b..3b8027fd 100644 --- a/clients/memdump.c +++ b/clients/memdump.c @@ -43,10 +43,11 @@ static char *opt_username; static char *opt_passwd; /* Print the keys and counter how many were found */ -static memcached_return_t key_printer(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t key_printer(const memcached_st *ptr, const char *key, size_t key_length, - void *context __attribute__((unused))) + void *context) { + (void)ptr;(void)context; printf("%.*s\n", (uint32_t)key_length, key); return MEMCACHED_SUCCESS; diff --git a/clients/utilities.c b/clients/utilities.c index 52f46b40..f223ae6f 100644 --- a/clients/utilities.c +++ b/clients/utilities.c @@ -71,9 +71,10 @@ static const char *lookup_help(memcached_options option) void help_command(const char *command_name, const char *description, const struct option *long_options, - memcached_programs_help_st *options __attribute__((unused))) + memcached_programs_help_st *options) { unsigned int x; + (void)options; printf("%s v%u.%u\n\n", command_name, 1U, 0U); printf("\t%s\n\n", description); diff --git a/configure.ac b/configure.ac index 8473f1bb..66159d2d 100644 --- a/configure.ac +++ b/configure.ac @@ -79,7 +79,6 @@ AH_BOTTOM([ #define closesocket(a) close(a) #define get_socket_errno() errno #endif - #endif ]) diff --git a/example/memcached_light.c b/example/memcached_light.c index 0b434a5f..84635b2a 100644 --- a/example/memcached_light.c +++ b/example/memcached_light.c @@ -287,8 +287,8 @@ static const char* comcode2str(uint8_t cmd) /** * Print out the command we are about to execute */ -static void pre_execute(const void *cookie __attribute__((unused)), - protocol_binary_request_header *header __attribute__((unused))) +static void pre_execute(const void *cookie, + protocol_binary_request_header *header) { if (verbose) { @@ -303,8 +303,8 @@ static void pre_execute(const void *cookie __attribute__((unused)), /** * Print out the command we just executed */ -static void post_execute(const void *cookie __attribute__((unused)), - protocol_binary_request_header *header __attribute__((unused))) +static void post_execute(const void *cookie, + protocol_binary_request_header *header) { if (verbose) { diff --git a/example/storage.c b/example/storage.c index 84894476..1fb79730 100644 --- a/example/storage.c +++ b/example/storage.c @@ -165,7 +165,8 @@ void update_cas(struct item* item) item->cas= ++cas; } -void release_item(struct item* item __attribute__((unused))) +void release_item(struct item* item) { + (void)item; /* EMPTY */ } diff --git a/libhashkit/crc32.c b/libhashkit/crc32.c index 6db04783..b4ad8ec3 100644 --- a/libhashkit/crc32.c +++ b/libhashkit/crc32.c @@ -73,10 +73,11 @@ static const uint32_t crc32tab[256] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; -uint32_t hashkit_crc32(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_crc32(const char *key, size_t key_length, void *context) { uint64_t x; uint32_t crc= UINT32_MAX; + (void)context; for (x= 0; x < key_length; x++) crc= (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff]; diff --git a/libhashkit/fnv.c b/libhashkit/fnv.c index ee3754d8..41243813 100644 --- a/libhashkit/fnv.c +++ b/libhashkit/fnv.c @@ -14,10 +14,11 @@ static uint64_t FNV_64_PRIME= UINT64_C(0x100000001b3); static uint32_t FNV_32_INIT= 2166136261UL; static uint32_t FNV_32_PRIME= 16777619; -uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context) { /* Thanks to pierre@demartines.com for the pointer */ uint64_t hash= FNV_64_INIT; + (void)context; for (size_t x= 0; x < key_length; x++) { @@ -28,9 +29,10 @@ uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context __att return (uint32_t)hash; } -uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context) { uint32_t hash= (uint32_t) FNV_64_INIT; + (void)context; for (size_t x= 0; x < key_length; x++) { @@ -42,9 +44,10 @@ uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context __at return hash; } -uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context) { uint32_t hash= FNV_32_INIT; + (void)context; for (size_t x= 0; x < key_length; x++) { @@ -56,9 +59,10 @@ uint32_t hashkit_fnv1_32(const char *key, size_t key_length, void *context __att return hash; } -uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_fnv1a_32(const char *key, size_t key_length, void *context) { uint32_t hash= FNV_32_INIT; + (void)context; for (size_t x= 0; x < key_length; x++) { diff --git a/libhashkit/jenkins.c b/libhashkit/jenkins.c index b684d7a0..53e35a82 100644 --- a/libhashkit/jenkins.c +++ b/libhashkit/jenkins.c @@ -56,10 +56,11 @@ use a bitmask. For example, if you need only 10 bits, do In which case, the hash table should have hashsize(10) elements. */ -uint32_t hashkit_jenkins(const char *key, size_t length, void *context __attribute__((unused))) +uint32_t hashkit_jenkins(const char *key, size_t length, void *context) { uint32_t a,b,c; /* internal state */ union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ + (void)context; /* Set up the internal state */ a = b = c = 0xdeadbeef + ((uint32_t)length) + JENKINS_INITVAL; @@ -82,7 +83,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length, void *context __attribu } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -109,7 +110,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length, void *context __attribu default: return c; } - } + } else if ((u.i & 0x1) == 0) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ @@ -159,7 +160,7 @@ uint32_t hashkit_jenkins(const char *key, size_t length, void *context __attribu default: return c; } - } + } else { /* need to read the key one byte at a time */ #endif /* little endian */ diff --git a/libhashkit/md5.c b/libhashkit/md5.c index 7371c6d1..025c6662 100644 --- a/libhashkit/md5.c +++ b/libhashkit/md5.c @@ -1,5 +1,5 @@ /* - This Library has been modified from its original form by + This Library has been modified from its original form by Brian Aker (brian@tangent.org) See below for original Copyright. @@ -125,7 +125,7 @@ Rotation is separate from addition to prevent recomputation. } -/* +/* Just a simple method for getting the signature result must be == 16 */ @@ -352,9 +352,10 @@ unsigned int len) (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); } -uint32_t hashkit_md5(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_md5(const char *key, size_t key_length, void *context) { unsigned char results[16]; + (void)context; md5_signature((unsigned char*)key, (unsigned int)key_length, results); diff --git a/libhashkit/murmur.c b/libhashkit/murmur.c index a18ac403..78d7f193 100644 --- a/libhashkit/murmur.c +++ b/libhashkit/murmur.c @@ -1,4 +1,4 @@ -/* +/* "Murmur" hash provided by Austin, tanjent@gmail.com http://murmurhash.googlepages.com/ @@ -17,9 +17,9 @@ #include "common.h" -uint32_t hashkit_murmur(const char *key, size_t length, void *context __attribute__((unused))) +uint32_t hashkit_murmur(const char *key, size_t length, void *context) { - /* + /* 'm' and 'r' are mixing constants generated offline. They're not really 'magic', they just happen to work well. */ @@ -36,16 +36,17 @@ uint32_t hashkit_murmur(const char *key, size_t length, void *context __attribut // Mix 4 bytes at a time into the hash const unsigned char * data= (const unsigned char *)key; + (void)context; while(length >= 4) { unsigned int k = *(unsigned int *)data; - k *= m; - k ^= k >> r; - k *= m; + k *= m; + k ^= k >> r; + k *= m; - h *= m; + h *= m; h ^= k; data += 4; @@ -63,9 +64,9 @@ uint32_t hashkit_murmur(const char *key, size_t length, void *context __attribut default: break; }; - /* + /* Do a few final mixes of the hash to ensure the last few bytes are - well-incorporated. + well-incorporated. */ h ^= h >> 13; diff --git a/libhashkit/one_at_a_time.c b/libhashkit/one_at_a_time.c index 579d0445..0c9ec31a 100644 --- a/libhashkit/one_at_a_time.c +++ b/libhashkit/one_at_a_time.c @@ -13,10 +13,11 @@ http://en.wikipedia.org/wiki/Jenkins_hash_function #include "common.h" -uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *context __attribute__((unused))) +uint32_t hashkit_one_at_a_time(const char *key, size_t key_length, void *context) { const char *ptr= key; uint32_t value= 0; + (void)context; while (key_length--) { diff --git a/libhashkit/strerror.c b/libhashkit/strerror.c index 270fa214..ac51f996 100644 --- a/libhashkit/strerror.c +++ b/libhashkit/strerror.c @@ -8,8 +8,9 @@ #include "common.h" -const char *hashkit_strerror(hashkit_st *ptr __attribute__((unused)), hashkit_return_t rc) +const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc) { + (void)ptr; switch (rc) { case HASHKIT_SUCCESS: diff --git a/libmemcached/stats.c b/libmemcached/stats.c index ab005f49..93012a8d 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -162,7 +162,8 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char strcmp("reclaimed", key) == 0)) { WATCHPOINT_STRING(key); - return MEMCACHED_UNKNOWN_STAT_KEY; + /* return MEMCACHED_UNKNOWN_STAT_KEY; */ + return MEMCACHED_SUCCESS; } return MEMCACHED_SUCCESS; diff --git a/libmemcached/storage.c b/libmemcached/storage.c index deb4aed4..191802ab 100644 --- a/libmemcached/storage.c +++ b/libmemcached/storage.c @@ -310,8 +310,8 @@ memcached_return_t memcached_cas(memcached_st *ptr, } memcached_return_t memcached_set_by_key(memcached_st *ptr, - const char *master_key __attribute__((unused)), - size_t master_key_length __attribute__((unused)), + const char *master_key, + size_t master_key_length, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, diff --git a/libmemcached/strerror.c b/libmemcached/strerror.c index 4ed2a24c..d1c0f297 100644 --- a/libmemcached/strerror.c +++ b/libmemcached/strerror.c @@ -1,7 +1,8 @@ #include "common.h" -const char *memcached_strerror(memcached_st *ptr __attribute__((unused)), memcached_return_t rc) +const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc) { + (void)ptr; switch (rc) { case MEMCACHED_SUCCESS: diff --git a/libmemcached/util/version.c b/libmemcached/util/version.c index a4d5b2d4..a0b69255 100644 --- a/libmemcached/util/version.c +++ b/libmemcached/util/version.c @@ -22,12 +22,13 @@ struct local_context bool truth; }; -static memcached_return_t check_server_version(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t check_server_version(const memcached_st *ptr, const memcached_server_st *instance, void *context) { /* Do Nothing */ struct local_context *check= (struct local_context *)context; + (void)ptr; if (instance->major_version != UINT8_MAX && instance->major_version >= check->major_version && @@ -42,7 +43,7 @@ static memcached_return_t check_server_version(const memcached_st *ptr __attribu return MEMCACHED_FAILURE; } -bool libmemcached_util_version_check(memcached_st *memc, +bool libmemcached_util_version_check(memcached_st *memc, uint8_t major_version, uint8_t minor_version, uint8_t micro_version) diff --git a/libmemcached/verbosity.c b/libmemcached/verbosity.c index d0903514..d71fced7 100644 --- a/libmemcached/verbosity.c +++ b/libmemcached/verbosity.c @@ -1,12 +1,12 @@ #include "common.h" -struct context_st +struct context_st { size_t length; const char *buffer; }; -static memcached_return_t _set_verbosity(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t _set_verbosity(const memcached_st *ptr, const memcached_server_st *server, void *context) { @@ -16,6 +16,7 @@ static memcached_return_t _set_verbosity(const memcached_st *ptr __attribute__(( char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; struct context_st *execute= (struct context_st *)context; + (void)ptr; memc_ptr= memcached_create(&local_memc); @@ -46,7 +47,7 @@ memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity) char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "verbosity %u\r\n", verbosity); if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) return MEMCACHED_WRITE_FAILURE; diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index a7e49c91..fac6986c 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -43,21 +43,23 @@ static pairs_st *global_pairs; static char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; -static test_return_t cleanup_pairs(memcached_st *memc __attribute__((unused))) +static test_return_t cleanup_pairs(memcached_st *memc) { + (void)memc; pairs_free(global_pairs); return 0; } -static test_return_t generate_pairs(memcached_st *memc __attribute__((unused))) +static test_return_t generate_pairs(memcached_st *memc) { + (void)memc; global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; for (size_t x= 0; x < global_count; x++) { - global_keys[x]= global_pairs[x].key; + global_keys[x]= global_pairs[x].key; global_keys_length[x]= global_pairs[x].key_length; } @@ -97,12 +99,12 @@ infinite: WATCHPOINT_ERROR(rc); WATCHPOINT_ASSERT(rc); } - } + } else { - rc= memcached_set(memc, global_pairs[test_bit].key, + rc= memcached_set(memc, global_pairs[test_bit].key, global_pairs[test_bit].key_length, - global_pairs[test_bit].value, + global_pairs[test_bit].value, global_pairs[test_bit].value_length, 0, 0); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) @@ -126,7 +128,7 @@ static test_return_t pre_nonblock(memcached_st *memc) return TEST_SUCCESS; } -/* +/* Set the value, then quit to make sure it is flushed. Come back in and test that add fails. */ @@ -139,12 +141,12 @@ static test_return_t add_test(memcached_st *memc) setting_value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK); - rc= memcached_set(memc, key, strlen(key), + rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED); memcached_quit(memc); - rc= memcached_add(memc, key, strlen(key), + rc= memcached_add(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); @@ -192,8 +194,9 @@ struct benchmark_state_st memcached_st *clone; } benchmark_state; -static test_return_t memcached_create_benchmark(memcached_st *memc __attribute__((unused))) +static test_return_t memcached_create_benchmark(memcached_st *memc) { + (void)memc; benchmark_state.create_init= true; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) @@ -222,8 +225,9 @@ static test_return_t memcached_clone_benchmark(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t pre_allocate(memcached_st *memc __attribute__((unused))) +static test_return_t pre_allocate(memcached_st *memc) { + (void)memc; memset(&benchmark_state, 0, sizeof(benchmark_state)); benchmark_state.create= (memcached_st *)calloc(BENCHMARK_TEST_LOOP, sizeof(memcached_st)); @@ -234,8 +238,9 @@ static test_return_t pre_allocate(memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t post_allocate(memcached_st *memc __attribute__((unused))) +static test_return_t post_allocate(memcached_st *memc) { + (void)memc; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { if (benchmark_state.create_init) diff --git a/tests/hashkit_functions.c b/tests/hashkit_functions.c index 46f53934..53c94b59 100644 --- a/tests/hashkit_functions.c +++ b/tests/hashkit_functions.c @@ -31,10 +31,11 @@ struct hash_test_st bool _unused; }; -static test_return_t init_test(void *not_used __attribute__((unused))) +static test_return_t init_test(void *not_used) { hashkit_st hashk; hashkit_st *hashk_ptr; + (void)not_used; hashk_ptr= hashkit_create(&hashk); test_true(hashk_ptr); @@ -46,9 +47,10 @@ static test_return_t init_test(void *not_used __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t allocation_test(void *not_used __attribute__((unused))) +static test_return_t allocation_test(void *not_used) { hashkit_st *hashk_ptr; + (void)not_used; hashk_ptr= hashkit_create(NULL); test_true(hashk_ptr); @@ -115,10 +117,11 @@ static test_return_t clone_test(hashkit_st *hashk) return TEST_SUCCESS; } -static test_return_t one_at_a_time_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t one_at_a_time_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -131,10 +134,11 @@ static test_return_t one_at_a_time_run (hashkit_st *hashk __attribute__((unused) return TEST_SUCCESS; } -static test_return_t md5_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t md5_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -147,10 +151,11 @@ static test_return_t md5_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t crc_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t crc_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -163,10 +168,11 @@ static test_return_t crc_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1_64_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t fnv1_64_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -179,10 +185,11 @@ static test_return_t fnv1_64_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1a_64_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t fnv1a_64_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -195,11 +202,11 @@ static test_return_t fnv1a_64_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1_32_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t fnv1_32_run (hashkit_st *hashk) { uint32_t x; const char **ptr; - + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -212,10 +219,11 @@ static test_return_t fnv1_32_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1a_32_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t fnv1a_32_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -228,10 +236,11 @@ static test_return_t fnv1a_32_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t hsieh_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t hsieh_run (hashkit_st *hashk) { uint32_t x; const char **ptr; + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -248,8 +257,10 @@ static test_return_t hsieh_run (hashkit_st *hashk __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t murmur_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t murmur_run (hashkit_st *hashk) { + (void)hashk; + #ifdef WORDS_BIGENDIAN return TEST_SKIPPED; #else @@ -268,11 +279,11 @@ static test_return_t murmur_run (hashkit_st *hashk __attribute__((unused))) #endif } -static test_return_t jenkins_run (hashkit_st *hashk __attribute__((unused))) +static test_return_t jenkins_run (hashkit_st *hashk) { uint32_t x; const char **ptr; - + (void)hashk; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -309,7 +320,7 @@ static test_return_t hashkit_digest_test(hashkit_st *hashk) static test_return_t hashkit_set_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) { hashkit_return_t rc; uint32_t x; @@ -415,7 +426,7 @@ static test_return_t hashkit_set_custom_function_test(hashkit_st *hashk) static test_return_t hashkit_set_distribution_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) { hashkit_return_t rc; @@ -447,7 +458,7 @@ static test_return_t hashkit_set_custom_distribution_function_test(hashkit_st *h static test_return_t hashkit_get_function_test(hashkit_st *hashk) { - for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) + for (hashkit_hash_algorithm_t algo = HASHKIT_HASH_DEFAULT; algo < HASHKIT_HASH_MAX; algo++) { hashkit_return_t rc; diff --git a/tests/mem_functions.c b/tests/mem_functions.c index f7b30c8d..48b254db 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -55,9 +55,10 @@ static size_t global_keys_length[GLOBAL_COUNT]; static test_return_t pre_binary(memcached_st *memc); -static test_return_t init_test(memcached_st *not_used __attribute__((unused))) +static test_return_t init_test(memcached_st *not_used) { memcached_st memc; + (void)not_used; (void)memcached_create(&memc); memcached_free(&memc); @@ -65,10 +66,11 @@ static test_return_t init_test(memcached_st *not_used __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t server_list_null_test(memcached_st *ptr __attribute__((unused))) +static test_return_t server_list_null_test(memcached_st *ptr) { memcached_server_st *server_list; memcached_return_t rc; + (void)ptr; server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL); test_true(server_list == NULL); @@ -85,26 +87,28 @@ static test_return_t server_list_null_test(memcached_st *ptr __attribute__((unus #define TEST_PORT_COUNT 7 in_port_t test_ports[TEST_PORT_COUNT]; -static memcached_return_t server_display_function(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t server_display_function(const memcached_st *ptr, const memcached_server_st *server, void *context) { /* Do Nothing */ size_t bigger= *((size_t *)(context)); + (void)ptr; assert(bigger <= memcached_server_port(server)); *((size_t *)(context))= memcached_server_port(server); return MEMCACHED_SUCCESS; } -static memcached_return_t dump_server_information(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t dump_server_information(const memcached_st *ptr, const memcached_server_st *instance, void *context) { /* Do Nothing */ FILE *stream= (FILE *)context; + (void)ptr; - fprintf(stream, "Memcached Server: %s %u Version %u.%u.%u\n", + fprintf(stream, "Memcached Server: %s %u Version %u.%u.%u\n", memcached_server_name(instance), memcached_server_port(instance), instance->major_version, @@ -114,13 +118,14 @@ static memcached_return_t dump_server_information(const memcached_st *ptr __attr return MEMCACHED_SUCCESS; } -static test_return_t server_sort_test(memcached_st *ptr __attribute__((unused))) +static test_return_t server_sort_test(memcached_st *ptr) { size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_return_t rc; memcached_server_fn callbacks[1]; memcached_st *local_memc; + (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); @@ -146,13 +151,14 @@ static test_return_t server_sort_test(memcached_st *ptr __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused))) +static test_return_t server_sort2_test(memcached_st *ptr) { size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_return_t rc; memcached_server_fn callbacks[1]; memcached_st *local_memc; memcached_server_instance_st instance; + (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); @@ -182,11 +188,13 @@ static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused)) return TEST_SUCCESS; } -static memcached_return_t server_print_callback(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t server_print_callback(const memcached_st *ptr, const memcached_server_st *server, - void *context __attribute__((unused))) + void *context) { (void)server; // Just in case we aren't printing. + (void)ptr; + (void)context; #if 0 fprintf(stderr, "%s(%d)", memcached_server_name(server), memcached_server_port(server)); @@ -195,7 +203,7 @@ static memcached_return_t server_print_callback(const memcached_st *ptr __attrib return MEMCACHED_SUCCESS; } -static test_return_t memcached_server_remove_test(memcached_st *ptr __attribute__((unused))) +static test_return_t memcached_server_remove_test(memcached_st *ptr) { memcached_return_t rc; memcached_st local_memc; @@ -204,6 +212,7 @@ static test_return_t memcached_server_remove_test(memcached_st *ptr __attribute_ memcached_server_fn callbacks[1]; const char *server_string= "localhost:4444, localhost:4445, localhost:4446, localhost:4447, localhost, memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214"; + (void)ptr; memc= memcached_create(&local_memc); @@ -220,12 +229,13 @@ static test_return_t memcached_server_remove_test(memcached_st *ptr __attribute_ return TEST_SUCCESS; } -static memcached_return_t server_display_unsort_function(const memcached_st *ptr __attribute__((unused)), +static memcached_return_t server_display_unsort_function(const memcached_st *ptr, const memcached_server_st *server, void *context) { /* Do Nothing */ uint32_t x= *((uint32_t *)(context)); + (void)ptr; assert(test_ports[x] == server->port); *((uint32_t *)(context))= ++x; @@ -233,13 +243,14 @@ static memcached_return_t server_display_unsort_function(const memcached_st *ptr return MEMCACHED_SUCCESS; } -static test_return_t server_unsort_test(memcached_st *ptr __attribute__((unused))) +static test_return_t server_unsort_test(memcached_st *ptr) { size_t counter= 0; /* Prime the value for the test_true in server_display_function */ size_t bigger= 0; /* Prime the value for the test_true in server_display_function */ memcached_return_t rc; memcached_server_fn callbacks[1]; memcached_st *local_memc; + (void)ptr; local_memc= memcached_create(NULL); test_true(local_memc); @@ -269,8 +280,9 @@ static test_return_t server_unsort_test(memcached_st *ptr __attribute__((unused) return TEST_SUCCESS; } -static test_return_t allocation_test(memcached_st *not_used __attribute__((unused))) +static test_return_t allocation_test(memcached_st *not_used) { + (void)not_used; memcached_st *memc; memc= memcached_create(NULL); test_true(memc); @@ -759,10 +771,11 @@ static test_return_t flush_test(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return_t server_function(const memcached_st *ptr __attribute__((unused)), - const memcached_server_st *server __attribute__((unused)), - void *context __attribute__((unused))) +static memcached_return_t server_function(const memcached_st *ptr, + const memcached_server_st *server, + void *context) { + (void)ptr; (void)server; (void)context; /* Do Nothing */ return MEMCACHED_SUCCESS; @@ -876,12 +889,12 @@ static test_return_t bad_key_test(memcached_st *memc) } #define READ_THROUGH_VALUE "set for me" -static memcached_return_t read_through_trigger(memcached_st *memc __attribute__((unused)), - char *key __attribute__((unused)), - size_t key_length __attribute__((unused)), +static memcached_return_t read_through_trigger(memcached_st *memc, + char *key, + size_t key_length, memcached_result_st *result) { - + (void)memc;(void)key;(void)key_length; return memcached_result_set_value(result, READ_THROUGH_VALUE, strlen(READ_THROUGH_VALUE)); } @@ -924,10 +937,11 @@ static test_return_t read_through(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return_t delete_trigger(memcached_st *ptr __attribute__((unused)), +static memcached_return_t delete_trigger(memcached_st *ptr, const char *key, - size_t key_length __attribute__((unused))) + size_t key_length) { + (void)ptr;(void)key_length; assert(key); return MEMCACHED_SUCCESS; @@ -1575,10 +1589,11 @@ static test_return_t mget_result_alloc_test(memcached_st *memc) } /* Count the results */ -static memcached_return_t callback_counter(const memcached_st *ptr __attribute__((unused)), - memcached_result_st *result __attribute__((unused)), +static memcached_return_t callback_counter(const memcached_st *ptr, + memcached_result_st *result, void *context) { + (void)ptr; (void)result; size_t *counter= (size_t *)context; *counter= *counter + 1; @@ -1805,9 +1820,10 @@ static test_return_t get_stats_keys(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t version_string_test(memcached_st *memc __attribute__((unused))) +static test_return_t version_string_test(memcached_st *memc) { const char *version_string; + (void)memc; version_string= memcached_lib_version(); @@ -1875,13 +1891,15 @@ static test_return_t add_host_test(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return_t clone_test_callback(memcached_st *parent __attribute__((unused)), memcached_st *memc_clone __attribute__((unused))) +static memcached_return_t clone_test_callback(memcached_st *parent, memcached_st *memc_clone) { + (void)parent;(void)memc_clone; return MEMCACHED_SUCCESS; } -static memcached_return_t cleanup_test_callback(memcached_st *ptr __attribute__((unused))) +static memcached_return_t cleanup_test_callback(memcached_st *ptr) { + (void)ptr; return MEMCACHED_SUCCESS; } @@ -2407,7 +2425,7 @@ static test_return_t user_supplied_bug6(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t user_supplied_bug8(memcached_st *memc __attribute__((unused))) +static test_return_t user_supplied_bug8(memcached_st *memc) { memcached_return_t rc; memcached_st *mine; @@ -2416,6 +2434,7 @@ static test_return_t user_supplied_bug8(memcached_st *memc __attribute__((unused memcached_server_st *servers; const char *server_list= "memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214"; + (void)memc; servers= memcached_servers_parse(server_list); test_true(servers); @@ -2960,8 +2979,9 @@ static test_return_t user_supplied_bug18(memcached_st *trash) */ /* sighandler_t function that always asserts false */ -static void fail(int unused __attribute__((unused))) +static void fail(int unused) { + (void)unused; assert(0); } @@ -3329,15 +3349,17 @@ static test_return_t string_alloc_append_toobig(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t cleanup_pairs(memcached_st *memc __attribute__((unused))) +static test_return_t cleanup_pairs(memcached_st *memc) { + (void)memc; pairs_free(global_pairs); return TEST_SUCCESS; } -static test_return_t generate_pairs(memcached_st *memc __attribute__((unused))) +static test_return_t generate_pairs(memcached_st *memc) { + (void)memc; global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; @@ -3350,8 +3372,9 @@ static test_return_t generate_pairs(memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t generate_large_pairs(memcached_st *memc __attribute__((unused))) +static test_return_t generate_large_pairs(memcached_st *memc) { + (void)memc; global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10); global_count= GLOBAL2_COUNT; @@ -3851,9 +3874,10 @@ static test_return_t pre_replication_noblock(memcached_st *memc) } -static void my_free(const memcached_st *ptr __attribute__((unused)), void *mem, void *context) +static void my_free(const memcached_st *ptr, void *mem, void *context) { - (void) context; + (void)context; + (void)ptr; #ifdef HARD_MALLOC_TESTS void *real_ptr= (mem == NULL) ? mem : (void*)((caddr_t)mem - 8); free(real_ptr); @@ -3863,9 +3887,10 @@ static void my_free(const memcached_st *ptr __attribute__((unused)), void *mem, } -static void *my_malloc(const memcached_st *ptr __attribute__((unused)), const size_t size, void *context) +static void *my_malloc(const memcached_st *ptr, const size_t size, void *context) { (void)context; + (void)ptr; #ifdef HARD_MALLOC_TESTS void *ret= malloc(size + 8); if (ret != NULL) @@ -3885,7 +3910,7 @@ static void *my_malloc(const memcached_st *ptr __attribute__((unused)), const si } -static void *my_realloc(const memcached_st *ptr __attribute__((unused)), void *mem, const size_t size, void *context) +static void *my_realloc(const memcached_st *ptr, void *mem, const size_t size, void *context) { (void)context; #ifdef HARD_MALLOC_TESTS @@ -3900,12 +3925,13 @@ static void *my_realloc(const memcached_st *ptr __attribute__((unused)), void *m return ret; #else + (void)ptr; return realloc(mem, size); #endif } -static void *my_calloc(const memcached_st *ptr __attribute__((unused)), size_t nelem, const size_t size, void *context) +static void *my_calloc(const memcached_st *ptr, size_t nelem, const size_t size, void *context) { (void)context; #ifdef HARD_MALLOC_TESTS @@ -3917,6 +3943,7 @@ static void *my_calloc(const memcached_st *ptr __attribute__((unused)), size_t n return mem; #else + (void)ptr; return calloc(nelem, size); #endif } @@ -4343,11 +4370,12 @@ static test_return_t analyzer_test(memcached_st *memc) } /* Count the objects */ -static memcached_return_t callback_dump_counter(const memcached_st *ptr __attribute__((unused)), - const char *key __attribute__((unused)), - size_t key_length __attribute__((unused)), +static memcached_return_t callback_dump_counter(const memcached_st *ptr, + const char *key, + size_t key_length, void *context) { + (void)ptr; (void)key; (void)key_length; size_t *counter= (size_t *)context; *counter= *counter + 1; @@ -4831,10 +4859,11 @@ static test_return_t hsieh_avaibility_test (memcached_st *memc) return TEST_SUCCESS; } -static test_return_t one_at_a_time_run (memcached_st *memc __attribute__((unused))) +static test_return_t one_at_a_time_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4847,10 +4876,11 @@ static test_return_t one_at_a_time_run (memcached_st *memc __attribute__((unused return TEST_SUCCESS; } -static test_return_t md5_run (memcached_st *memc __attribute__((unused))) +static test_return_t md5_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4863,10 +4893,11 @@ static test_return_t md5_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t crc_run (memcached_st *memc __attribute__((unused))) +static test_return_t crc_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4879,10 +4910,11 @@ static test_return_t crc_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1_64_run (memcached_st *memc __attribute__((unused))) +static test_return_t fnv1_64_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4895,10 +4927,11 @@ static test_return_t fnv1_64_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1a_64_run (memcached_st *memc __attribute__((unused))) +static test_return_t fnv1a_64_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4911,11 +4944,11 @@ static test_return_t fnv1a_64_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1_32_run (memcached_st *memc __attribute__((unused))) +static test_return_t fnv1_32_run (memcached_st *memc) { uint32_t x; const char **ptr; - + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4928,10 +4961,11 @@ static test_return_t fnv1_32_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t fnv1a_32_run (memcached_st *memc __attribute__((unused))) +static test_return_t fnv1a_32_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4944,10 +4978,11 @@ static test_return_t fnv1a_32_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t hsieh_run (memcached_st *memc __attribute__((unused))) +static test_return_t hsieh_run (memcached_st *memc) { uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4960,13 +4995,14 @@ static test_return_t hsieh_run (memcached_st *memc __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t murmur_run (memcached_st *memc __attribute__((unused))) +static test_return_t murmur_run (memcached_st *memc) { #ifdef WORDS_BIGENDIAN return TEST_SKIPPED; #else uint32_t x; const char **ptr; + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -4980,11 +5016,11 @@ static test_return_t murmur_run (memcached_st *memc __attribute__((unused))) #endif } -static test_return_t jenkins_run (memcached_st *memc __attribute__((unused))) +static test_return_t jenkins_run (memcached_st *memc) { uint32_t x; const char **ptr; - + (void)memc; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { @@ -5079,9 +5115,9 @@ static test_return_t memcached_get_hashkit_test (memcached_st *memc) } /* - Test case adapted from John Gorman + Test case adapted from John Gorman - We are testing the error condition when we connect to a server via memcached_get() + We are testing the error condition when we connect to a server via memcached_get() but find that the server is not available. */ static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc) @@ -5114,7 +5150,7 @@ static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *memc) return TEST_SUCCESS; } -/* +/* We connect to a server which exists, but search for a key that does not exist. */ static test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc) @@ -5136,9 +5172,9 @@ static test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc) } /* - Test case adapted from John Gorman + Test case adapted from John Gorman - We are testing the error condition when we connect to a server via memcached_get_by_key() + We are testing the error condition when we connect to a server via memcached_get_by_key() but find that the server is not available. */ static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc) @@ -5171,7 +5207,7 @@ static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc) return TEST_SUCCESS; } -/* +/* We connect to a server which exists, but search for a key that does not exist. */ static test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc) @@ -5625,16 +5661,16 @@ static test_return_t regression_bug_447342(memcached_st *memc) static test_return_t regression_bug_463297(memcached_st *memc) { - memcached_st *memc_clone= memcached_clone(NULL, memc); - test_true(memc_clone != NULL); - test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); + memcached_st *memc_clone= memcached_clone(NULL, memc); + test_true(memc_clone != NULL); + test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); - memcached_server_instance_st instance= - memcached_server_instance_by_position(memc_clone, 0); + memcached_server_instance_st instance= + memcached_server_instance_by_position(memc_clone, 0); - if (instance->major_version > 1 || - (instance->major_version == 1 && - instance->minor_version > 2)) + if (instance->major_version > 1 || + (instance->major_version == 1 && + instance->minor_version > 2)) { /* Binary protocol doesn't support deferred delete */ memcached_st *bin_clone= memcached_clone(NULL, memc); @@ -5653,7 +5689,7 @@ static test_return_t regression_bug_463297(memcached_st *memc) memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); /* but there is a bug in some of the memcached servers (1.4) that treats - * the counter as noreply so it doesn't send the proper error message + * the counter as noreply so it doesn't send the proper error message */ test_true_got(rc == MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_NOTFOUND || rc == MEMCACHED_CLIENT_ERROR || rc == MEMCACHED_INVALID_ARGUMENTS, memcached_strerror(NULL, rc)); @@ -6049,7 +6085,7 @@ static test_return_t regression_bug_(memcached_st *memc) return TEST_SKIPPED; } - for (uint32_t x= 0; x < TEST_CONSTANT_CREATION; x++) + for (uint32_t x= 0; x < TEST_CONSTANT_CREATION; x++) { memcached_st* mc= memcached_create(NULL); memcached_return rc; @@ -6079,7 +6115,7 @@ static test_return_t regression_bug_(memcached_st *memc) if (rc == MEMCACHED_SUCCESS) { - if (x > 0) + if (x > 0) { size_t get_value_len; char *get_value;