From: Brian Aker Date: Mon, 21 Feb 2011 09:57:43 +0000 (-0800) Subject: Store up errno in a couple of spots. X-Git-Tag: 0.51~37 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b95b86ccfcaf1491760cf84723c48be9f13df49b;p=awesomized%2Flibmemcached Store up errno in a couple of spots. --- diff --git a/libmemcached/result.c b/libmemcached/result.c index dae53bf7..c6c754f3 100644 --- a/libmemcached/result.c +++ b/libmemcached/result.c @@ -92,7 +92,14 @@ memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length) { - return memcached_string_append(&ptr->value, value, length); + memcached_return_t rc= memcached_string_append(&ptr->value, value, length); + + if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) + { + ((memcached_st *)ptr->root)->cached_errno= errno; + } + + return rc; } const char *memcached_result_key_value(const memcached_result_st *self) diff --git a/libmemcached/server_list.c b/libmemcached/server_list.c index 9287bc19..c20f8dbf 100644 --- a/libmemcached/server_list.c +++ b/libmemcached/server_list.c @@ -37,6 +37,7 @@ memcached_server_list_append_with_weight(memcached_server_list_st ptr, new_host_list= (memcached_server_write_instance_st)realloc(ptr, sizeof(memcached_server_st) * count); if (!new_host_list) { + ptr->cached_errno= errno; *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; } diff --git a/libmemcached/string.c b/libmemcached/string.c index f708f8d4..34597067 100644 --- a/libmemcached/string.c +++ b/libmemcached/string.c @@ -32,7 +32,9 @@ inline static memcached_return_t _string_check(memcached_string_st *string, size new_value= libmemcached_realloc(string->root, string->string, new_size); if (new_value == NULL) + { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; + } string->string= new_value; string->end= string->string + current_offset; @@ -80,7 +82,12 @@ memcached_string_st *memcached_string_create(const memcached_st *memc, memcached rc= _string_check(self, initial_size); if (rc != MEMCACHED_SUCCESS) { + if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) + { + ((memcached_st *)memc)->cached_errno= errno; + } libmemcached_free(memc, self); + return NULL; } @@ -99,7 +106,9 @@ memcached_return_t memcached_string_append_character(memcached_string_st *string rc= _string_check(string, 1); if (rc != MEMCACHED_SUCCESS) + { return rc; + } *string->end= character; string->end++; @@ -115,7 +124,9 @@ memcached_return_t memcached_string_append(memcached_string_st *string, rc= _string_check(string, length); if (rc != MEMCACHED_SUCCESS) + { return rc; + } WATCHPOINT_ASSERT(length <= string->current_size); WATCHPOINT_ASSERT(string->string); diff --git a/m4/pandora_warnings.m4 b/m4/pandora_warnings.m4 index 6d82df1d..badce21c 100644 --- a/m4/pandora_warnings.m4 +++ b/m4/pandora_warnings.m4 @@ -153,7 +153,7 @@ AC_DEFUN([PANDORA_WARNINGS],[ [ac_cv_safe_to_use_Wextra_=no]) CFLAGS="$save_CFLAGS"]) - BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}" + BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wswitch-enum -Wenum-compare -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}" AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"], [BASE_WARNINGS="${BASE_WARNINGS} -Wextra"], [BASE_WARNINGS="${BASE_WARNINGS} -W"])