From: Brian Aker Date: Thu, 21 Jan 2010 22:30:33 +0000 (-0800) Subject: Solaris fixes. X-Git-Tag: 0.40~67 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c15e27789bf0ba95ae05e70628a1eb39016159c9;p=m6w6%2Flibmemcached Solaris fixes. --- diff --git a/libhashkit/function.c b/libhashkit/function.c index 2b22590b..25c929bd 100644 --- a/libhashkit/function.c +++ b/libhashkit/function.c @@ -50,7 +50,6 @@ static hashkit_return_t _set_function(struct hashkit_function_st *self, hashkit_ case HASHKIT_HASH_MAX: default: return HASHKIT_FAILURE; - break; } self->context= NULL; diff --git a/libhashkit/hashkit.h b/libhashkit/hashkit.h index fe6c148d..8b7985ac 100644 --- a/libhashkit/hashkit.h +++ b/libhashkit/hashkit.h @@ -45,6 +45,10 @@ void hashkit_free(hashkit_st *hash); #define hashkit_is_allocated(__object) ((__object)->options.is_allocated) #define hashkit_is_initialized(__object) ((__object)->options.is_initialized) +#ifdef __cplusplus +} // extern "C" +#endif + struct hashkit_st { struct hashkit_function_st { @@ -119,9 +123,5 @@ struct hashkit_st #endif }; -#ifdef __cplusplus -} // extern "C" -#endif - #endif /* HASHKIT_H */ diff --git a/libhashkit/strerror.h b/libhashkit/strerror.h index f78a4838..3d6a908d 100644 --- a/libhashkit/strerror.h +++ b/libhashkit/strerror.h @@ -14,7 +14,7 @@ extern "C" { #endif HASHKIT_API - const char *hashkit_strerror(hashkit_st *ptr __attribute__((unused)), hashkit_return_t rc); + const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc); #ifdef __cplusplus } diff --git a/tests/hash_plus.cc b/tests/hash_plus.cc index cbf2fdf9..30e14106 100644 --- a/tests/hash_plus.cc +++ b/tests/hash_plus.cc @@ -10,16 +10,18 @@ #include "hash_results.h" -static test_return_t exists_test(void *obj __attribute__((unused))) +static test_return_t exists_test(void *obj) { Hashkit hashk; + (void)obj; return TEST_SUCCESS; } -static test_return_t new_test(void *obj __attribute__((unused))) +static test_return_t new_test(void *obj) { Hashkit *hashk= new Hashkit; + (void)obj; (void)hashk; @@ -28,10 +30,11 @@ static test_return_t new_test(void *obj __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t copy_test(void *obj __attribute__((unused))) +static test_return_t copy_test(void *obj) { Hashkit *hashk= new Hashkit; Hashkit *copy(hashk); + (void)obj; (void)copy; @@ -40,10 +43,11 @@ static test_return_t copy_test(void *obj __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t assign_test(void *obj __attribute__((unused))) +static test_return_t assign_test(void *obj) { Hashkit hashk; Hashkit copy; + (void)obj; copy= hashk; @@ -52,17 +56,18 @@ static test_return_t assign_test(void *obj __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t digest_test(void *obj __attribute__((unused))) +static test_return_t digest_test(void *obj) { Hashkit hashk; uint32_t value; + (void)obj; value= hashk.digest("Foo", sizeof("Foo")); return TEST_SUCCESS; } -static test_return_t set_function_test(void *obj __attribute__((unused))) +static test_return_t set_function_test(void *obj) { Hashkit hashk; hashkit_hash_algorithm_t algo_list[]= { @@ -78,6 +83,7 @@ static test_return_t set_function_test(void *obj __attribute__((unused))) HASHKIT_HASH_MAX }; hashkit_hash_algorithm_t *algo; + (void)obj; for (algo= algo_list; *algo != HASHKIT_HASH_MAX; algo++) @@ -143,10 +149,11 @@ static test_return_t set_function_test(void *obj __attribute__((unused))) return TEST_SUCCESS; } -static test_return_t set_distribution_function_test(void *obj __attribute__((unused))) +static test_return_t set_distribution_function_test(void *obj) { Hashkit hashk; hashkit_return_t rc; + (void)obj; rc= hashk.set_distribution_function(HASHKIT_HASH_CUSTOM); test_true(rc == HASHKIT_FAILURE); @@ -157,9 +164,10 @@ static test_return_t set_distribution_function_test(void *obj __attribute__((unu return TEST_SUCCESS; } -static test_return_t compare_function_test(void *obj __attribute__((unused))) +static test_return_t compare_function_test(void *obj) { Hashkit a, b; + (void)obj; b= a; @@ -175,14 +183,14 @@ static test_return_t compare_function_test(void *obj __attribute__((unused))) } test_st basic[] ={ - { "exists", 0, exists_test }, - { "new", 0, new_test }, - { "copy", 0, copy_test }, - { "assign", 0, assign_test }, - { "digest", 0, digest_test }, - { "set_function", 0, set_function_test }, - { "set_distribution_function", 0, set_distribution_function_test }, - { "compare", 0, compare_function_test }, + { "exists", 0, reinterpret_cast(exists_test) }, + { "new", 0, reinterpret_cast(new_test) }, + { "copy", 0, reinterpret_cast(copy_test) }, + { "assign", 0, reinterpret_cast(assign_test) }, + { "digest", 0, reinterpret_cast(digest_test) }, + { "set_function", 0, reinterpret_cast(set_function_test) }, + { "set_distribution_function", 0, reinterpret_cast(set_distribution_function_test) }, + { "compare", 0, reinterpret_cast(compare_function_test) }, { 0, 0, 0} }; diff --git a/tests/hashkit_functions.c b/tests/hashkit_functions.c index 1d548f4a..005143a0 100644 --- a/tests/hashkit_functions.c +++ b/tests/hashkit_functions.c @@ -361,16 +361,23 @@ static test_return_t hashkit_set_function_test(hashkit_st *hashk) case HASHKIT_HASH_MAX: default: list= NULL; - test_fail("We ended up on a non-existent hash"); + break; } // Now we make sure we did set the hash correctly. - for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) + if (list) { - uint32_t hash_val; + for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) + { + uint32_t hash_val; - hash_val= hashkit_digest(hashk, *ptr, strlen(*ptr)); - test_true(list[x] == hash_val); + hash_val= hashkit_digest(hashk, *ptr, strlen(*ptr)); + test_true(list[x] == hash_val); + } + } + else + { + return TEST_FAILURE; } }