From 997db18fb96e07ee64e9ab7564055410aa6a1c23 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 3 Oct 2011 01:13:24 -0400 Subject: [PATCH] Merge in some updates to style. --- libmemcached/auto.cc | 31 ++++++++++++++++++++++--------- libmemcached/verbosity.cc | 19 ++++++++----------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index d0b7dd48..a73685ac 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -120,9 +120,6 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, { bool no_reply= ptr->flags.no_reply; - if (memcached_server_count(ptr) == 0) - return memcached_set_error(*ptr, MEMCACHED_NO_SERVERS, MEMCACHED_AT); - uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key); @@ -190,8 +187,10 @@ memcached_return_t memcached_increment_by_key(memcached_st *ptr, { memcached_return_t rc; uint64_t local_value; - if (not value) + if (value == NULL) + { value= &local_value; + } if (memcached_failed(rc= initialize_query(ptr))) { @@ -228,8 +227,10 @@ memcached_return_t memcached_decrement_by_key(memcached_st *ptr, uint64_t *value) { uint64_t local_value; - if (not value) + if (value == NULL) + { value= &local_value; + } memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr))) @@ -270,8 +271,10 @@ memcached_return_t memcached_increment_with_initial(memcached_st *ptr, uint64_t *value) { uint64_t local_value; - if (! value) + if (value == NULL) + { value= &local_value; + } return memcached_increment_with_initial_by_key(ptr, key, key_length, key, key_length, @@ -289,8 +292,10 @@ memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, uint64_t *value) { uint64_t local_value; - if (not value) + if (value == NULL) + { value= &local_value; + } memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr))) @@ -305,12 +310,16 @@ memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_START(); if (ptr->flags.binary_protocol) + { rc= binary_incr_decr(ptr, PROTOCOL_BINARY_CMD_INCREMENT, group_key, group_key_length, key, key_length, offset, initial, (uint32_t)expiration, value); + } else + { rc= MEMCACHED_PROTOCOL_ERROR; + } LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END(); @@ -326,8 +335,10 @@ memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, uint64_t *value) { uint64_t local_value; - if (! value) + if (value == NULL) + { value= &local_value; + } return memcached_decrement_with_initial_by_key(ptr, key, key_length, key, key_length, @@ -345,8 +356,10 @@ memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, uint64_t *value) { uint64_t local_value; - if (not value) + if (value == NULL) + { value= &local_value; + } memcached_return_t rc; if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol))) diff --git a/libmemcached/verbosity.cc b/libmemcached/verbosity.cc index c4231719..5564c7a9 100644 --- a/libmemcached/verbosity.cc +++ b/libmemcached/verbosity.cc @@ -43,26 +43,23 @@ struct context_st const char *buffer; }; -static memcached_return_t _set_verbosity(const memcached_st *ptr, +static memcached_return_t _set_verbosity(const memcached_st *, const memcached_server_st *server, void *context) { - memcached_return_t rc; - memcached_st local_memc; - memcached_st *memc_ptr; - char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - struct context_st *execute= (struct context_st *)context; - (void)ptr; - memc_ptr= memcached_create(&local_memc); + memcached_st local_memc; + memcached_st *memc_ptr= memcached_create(&local_memc); - rc= memcached_server_add(memc_ptr, memcached_server_name(server), memcached_server_port(server)); + memcached_return_t rc= memcached_server_add(memc_ptr, memcached_server_name(server), memcached_server_port(server)); if (rc == MEMCACHED_SUCCESS) { - memcached_server_write_instance_st instance= - memcached_server_instance_fetch(memc_ptr, 0); + char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + + memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc_ptr, 0); + rc= memcached_do(instance, execute->buffer, execute->length, true); -- 2.30.2