From: Brian Aker Date: Wed, 18 May 2011 21:45:13 +0000 (-0700) Subject: Small style cleanup X-Git-Tag: 0.51~10^2~16 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=fd151d70d25ba4cae4f90a1e57435a8cc72e9c09;p=awesomized%2Flibmemcached Small style cleanup --- diff --git a/libmemcached/server.cc b/libmemcached/server.cc index 02078860..30cc611f 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -1,11 +1,37 @@ -/* LibMemcached - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker All rights reserved. * - * Summary: String structure used for libmemcached. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -13,6 +39,7 @@ This is a partial implementation for fetching/creating memcached_server_st objects. */ #include +#include static inline void _server_init(memcached_server_st *self, const memcached_st *root, const char *hostname, in_port_t port, @@ -108,6 +135,7 @@ memcached_server_st *memcached_server_create_with(const memcached_st *memc, void memcached_server_free(memcached_server_st *self) { + assert(self); memcached_quit_server(self, false); if (self->cached_server_error) @@ -140,7 +168,7 @@ memcached_server_st *memcached_server_clone(memcached_server_st *destination, const memcached_server_st *source) { /* We just do a normal create if source is missing */ - if (source == NULL) + if (not source) return NULL; destination= memcached_server_create_with(source->root, destination, @@ -164,7 +192,7 @@ memcached_return_t memcached_server_cursor(const memcached_st *ptr, uint32_t number_of_callbacks) { memcached_return_t rc; - if ((rc= initialize_const_query(ptr)) != MEMCACHED_SUCCESS) + if (memcached_failed(rc= initialize_const_query(ptr))) { return rc; } @@ -194,12 +222,9 @@ memcached_return_t memcached_server_execute(memcached_st *ptr, { for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - memcached_server_write_instance_st instance= - memcached_server_instance_fetch(ptr, x); + memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); - unsigned int iferror; - - iferror= (*callback)(ptr, instance, context); + unsigned int iferror= (*callback)(ptr, instance, context); if (iferror) continue; @@ -214,26 +239,26 @@ memcached_server_instance_st memcached_server_by_key(const memcached_st *ptr, memcached_return_t *error) { memcached_return_t rc; + memcached_return_t unused; + + if (not error) + error= &unused; + if (memcached_failed(rc= initialize_const_query(ptr))) { - if (error) - *error= rc; - + *error= rc; return NULL; } if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol))) { - if (error) - *error= rc; - + *error= rc; return NULL; } if (ptr->flags.verify_key && (memcached_key_test((const char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)) { - if (error) - *error= MEMCACHED_BAD_KEY_PROVIDED; + *error= MEMCACHED_BAD_KEY_PROVIDED; return NULL; }