verify(strncmp(buffer, "VALUE ", 6) == 0);
char *end= strchr(buffer + 6, ' ');
verify(end != NULL);
- *end= '\0';
+ if (end)
+ {
+ *end= '\0';
+ }
*key= strdup(buffer + 6);
verify(*key != NULL);
char *ptr= end + 1;
*ndata = (ssize_t)strtoul(end, &end, 10); /* size */
verify(ptr != end);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
++end;
- verify(*end == '\n');
+ verify(end and *end == '\n');
*value= static_cast<char*>(malloc((size_t)*ndata));
verify(*value != NULL);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
+ {
++end;
- verify(*end == '\n');
+ }
+ verify(end and *end == '\n');
execute(retry_read(buffer, datasize));
verify(memcmp(buffer, value, datasize) == 0);
verify(val == datasize);
verify(end != NULL);
- while (*end != '\n' && isspace(*end))
+ while (end and *end != '\n' and isspace(*end))
+ {
++end;
- verify(*end == '\n');
+ }
+ verify(end and *end == '\n');
execute(retry_read(buffer, datasize));
verify(memcmp(buffer, value, datasize) == 0);
set= MEMCACHED_HASH_DEFAULT; /* Just here to solve warning */
if (!strcasecmp(opt_hash, "CRC"))
+ {
set= MEMCACHED_HASH_CRC;
+ }
else if (!strcasecmp(opt_hash, "FNV1_64"))
+ {
set= MEMCACHED_HASH_FNV1_64;
+ }
else if (!strcasecmp(opt_hash, "FNV1A_64"))
+ {
set= MEMCACHED_HASH_FNV1A_64;
+ }
else if (!strcasecmp(opt_hash, "FNV1_32"))
+ {
set= MEMCACHED_HASH_FNV1_32;
+ }
else if (!strcasecmp(opt_hash, "FNV1A_32"))
+ {
set= MEMCACHED_HASH_FNV1A_32;
+ }
else
{
fprintf(stderr, "hash: type not recognized %s\n", opt_hash);
#include <libhashkit/common.h>
/* FNV hash'es lifted from Dustin Sallings work */
-static uint64_t FNV_64_INIT= 0xcbf29ce484222325LLU;
-static uint64_t FNV_64_PRIME= 0x100000001b3LLU;
+static uint64_t FNV_64_INIT= 0xcbf29ce484222325;
+static uint64_t FNV_64_PRIME= 0x100000001b3;
-uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *context)
+uint32_t hashkit_fnv1_64(const char *key, size_t key_length, void *)
{
/* 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++)
{
return (uint32_t)hash;
}
-uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *context)
+uint32_t hashkit_fnv1a_64(const char *key, size_t key_length, void *)
{
uint32_t hash= (uint32_t) FNV_64_INIT;
- (void)context;
for (size_t x= 0; x < key_length; x++)
{
rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
+ if (rc == MEMCACHED_SUCCESS)
+ {
+ return MEMCACHED_SUCCESS;
+ }
+
/*
So why recheck responce? Because the protocol is brain dead :)
The number returned might end up equaling one of the string
if ((rc= memcached_vdo(instance, vector, 3, flush)) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
- rc= (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
}
unlikely (ptr->number_of_replicas > 0)
const char *memcached_last_error_message(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS);
+ }
if (not memc->error_messages)
return memcached_strerror(memc, MEMCACHED_SUCCESS);
memcached_return_t memcached_last_error(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return MEMCACHED_INVALID_ARGUMENTS;
+ }
if (not memc->error_messages)
return MEMCACHED_SUCCESS;
int memcached_last_error_errno(memcached_st *memc)
{
- if (not memc)
+ if (memc == NULL)
+ {
return 0;
+ }
if (not memc->error_messages)
+ {
return 0;
+ }
return memc->error_messages->local_errno;
}
const char *memcached_server_error(memcached_server_instance_st server)
{
- if (not server)
- return memcached_strerror(server->root, MEMCACHED_INVALID_ARGUMENTS);
+ if (server == NULL)
+ {
+ return NULL;
+ }
if (not server->error_messages)
return memcached_strerror(server->root, MEMCACHED_SUCCESS);
memcached_error_t *memcached_error_copy(const memcached_server_st& server)
{
- if (not server.error_messages)
+ if (server.error_messages == NULL)
+ {
return NULL;
+ }
memcached_error_t *error= (memcached_error_t *)libmemcached_malloc(server.root, sizeof(memcached_error_t));
memcpy(error, server.error_messages, sizeof(memcached_error_t));
return -1;
}
}
- ssize_t sent_length;
size_t return_length;
char *local_write_ptr= ptr->write_buffer;
size_t write_length= ptr->write_buffer_offset;
{
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
WATCHPOINT_ASSERT(write_length > 0);
- sent_length= 0;
if (ptr->type == MEMCACHED_CONNECTION_UDP)
increment_udp_message_id(ptr);
+ ssize_t sent_length= 0;
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (with_flush)
{
}
if (ptr->type == MEMCACHED_CONNECTION_UDP and
- (size_t)sent_length != write_length)
+ size_t(sent_length) != write_length)
{
memcached_quit_server(ptr, true);
*error= memcached_set_error(*ptr, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
/* We add two bytes so that we can walk the \r\n */
if (memcached_failed(memcached_string_check(&result->value, value_length +2)))
{
- value_length= 0;
return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
}
hostname,
source->port, source->weight,
source->type);
- if (not destination)
+ if (destination)
{
if (source->error_messages)
{
string_ptr= end_ptr + 1;
for (end_ptr= string_ptr; !(isspace(*end_ptr)); end_ptr++) {};
value= string_ptr;
- value[(size_t)(end_ptr-string_ptr)]= 0;
- string_ptr= end_ptr + 2;
+ value[(size_t)(end_ptr -string_ptr)]= 0;
if (memc_stat)
{
unlikely((set_data(memc_stat, key, value)) == MEMCACHED_UNKNOWN_STAT_KEY)
virtual_bucket->replicas= replicas;
self->virtual_bucket= virtual_bucket;
- for (uint32_t x=0; x < buckets; x++)
+ uint32_t x= 0;
+ for (; x < buckets; x++)
{
virtual_bucket->buckets[x].master= host_map[x];
if (forward_map)
PANDORA_USE_PIPE
- AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
+ AM_CFLAGS="-std=c99 ${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}"
AC_SUBST([AM_CFLAGS])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([PANDORA_CHECK_CXX_STANDARD],[
- dnl AC_REQUIRE([AC_CXX_COMPILE_STDCXX_0X])
- AS_IF([test "$GCC" = "yes"],
- [AS_IF([test "$ac_cv_cxx_compile_cxx0x_native" = "yes"],[],
- [AS_IF([test "$ac_cv_cxx_compile_cxx0x_gxx" = "yes"],
- [CXX_STANDARD="-std=gnu++0x"],
- [CXX_STANDARD="-std=gnu++98"])
- ])
- ])
- AM_CXXFLAGS="${CXX_STANDARD} ${AM_CXXFLAGS}"
-
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${CXXFLAGS} ${CXX_STANDARD}"
- AC_CXX_HEADER_STDCXX_98
- CXXFLAGS="${save_CXXFLAGS}"
-
- AC_SUBST([CXX_STANDARD])
-])
+++ /dev/null
-# ===========================================================================
-# http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AC_CXX_COMPILE_STDCXX_0X
-#
-# DESCRIPTION
-#
-# Check for baseline language coverage in the compiler for the C++0x
-# standard.
-#
-# LICENSE
-#
-# Copyright (C) 2008 Benjamin Kosnik <bkoz@redhat.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
-
-AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [
- AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
- ac_cv_cxx_compile_cxx0x_native,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
- AC_LANG_RESTORE
- ])
-
- AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
- ac_cv_cxx_compile_cxx0x_cxx,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -std=c++0x"
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
- CXXFLAGS="$ac_save_CXXFLAGS"
- AC_LANG_RESTORE
- ])
-
- AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
- ac_cv_cxx_compile_cxx0x_gxx,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_CXXFLAGS="$CXXFLAGS"
- CXXFLAGS="$CXXFLAGS -std=gnu++0x"
- AC_TRY_COMPILE([
- template <typename T>
- struct check
- {
- static_assert(sizeof(int) <= sizeof(T), "not big enough");
- };
-
- typedef check<check<bool>> right_angle_brackets;
-
- int a;
- decltype(a) b;
-
- typedef check<int> check_type;
- check_type c;
- check_type&& cr = c;],,
- ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
- CXXFLAGS="$ac_save_CXXFLAGS"
- AC_LANG_RESTORE
- ])
-
- if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
- test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
- test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
- AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
- fi
-])
;;
esac
- dnl Once we can use a modern autoconf, we can replace the std=gnu99 here
- dnl with using AC_CC_STD_C99 above
- CC="${CC} -std=gnu99"
-
AM_CPPFLAGS="-g ${AM_CPPFLAGS}"
DEBUG_CFLAGS="-O0"
test_compare(MEMCACHED_SUCCESS, rc);
}
- rc= memcached_mget(memc, keys, key_length, 3);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, key_length, 3));
results= memcached_result_create(memc, &results_obj);
+ test_true(results);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
(time_t)0, (uint32_t)0);
test_compare(MEMCACHED_SUCCESS, rc);
- rc= memcached_mget(memc, keys, keylengths, 1);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys, keylengths, 1));
results= memcached_result_create(memc, &results_obj);
+ test_true(results);
results= memcached_fetch_result(memc, &results_obj, &rc);
test_true(results);
/* All keys are valid in the binary protocol (except for length) */
if (not memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
{
- query_id= memcached_query_id(memc_clone);
+ uint64_t before_query_id= memcached_query_id(memc_clone);
{
size_t string_length;
char *string= memcached_get(memc_clone, key, strlen(key),
test_zero(string_length);
test_false(string);
}
+ test_compare(before_query_id, memcached_query_id(memc_clone) +1);
query_id= memcached_query_id(memc_clone);
test_compare(MEMCACHED_SUCCESS,
// this should indicate end
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
test_compare(MEMCACHED_END, rc);
+ test_null(string);
// now get just one
rc= memcached_mget(memc, keys, lengths, 1);
// this should indicate end
string= memcached_fetch(memc, key, &key_length, &string_length, &flags, &rc);
test_compare(MEMCACHED_END, rc);
+ test_null(string);
return TEST_SUCCESS;
}
{
memcached_result_st results_obj;
memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
memcached_return_t rc;
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
{
memcached_result_st results_obj;
memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
+ test_false(memcached_is_allocated(results));
memcached_return_t rc;
while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
/* Make sure be default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
+ test_null(value);
test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
/* Test a clean set */
/* Make sure be default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
+ test_null(value);
test_compare_got(MEMCACHED_FAILURE, rc, memcached_strerror(NULL, rc));
/* Test a clean set */