From: Michael Wallner Date: Fri, 23 Oct 2020 12:26:50 +0000 (+0200) Subject: clang-format: no single-line case X-Git-Tag: 1.1.0-beta1~171 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0f27cca46a4a529459ca988268972f480a9730c6;p=m6w6%2Flibmemcached clang-format: no single-line case --- diff --git a/.clang-format b/.clang-format index b86de6c1..7b77b814 100644 --- a/.clang-format +++ b/.clang-format @@ -12,9 +12,9 @@ AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false #AllowShortEnumsOnASingleLine: true (in v11) -AllowShortFunctionsOnASingleLine: Inline +AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: true diff --git a/src/bin/common/utilities.cc b/src/bin/common/utilities.cc index 0e21d709..ce7bd3d8 100644 --- a/src/bin/common/utilities.cc +++ b/src/bin/common/utilities.cc @@ -67,35 +67,64 @@ void close_stdio(void) { static const char *lookup_help(memcached_options option) { switch (option) { - case OPT_SERVERS: return ("List which servers you wish to connect to."); - case OPT_VERSION: return ("Display the version of the application and then exit."); - case OPT_HELP: return ("Display this message and then exit."); - case OPT_VERBOSE: return ("Give more details on the progression of the application."); - case OPT_QUIET: return ("stderr and stdin will be closed at application startup."); - case OPT_DEBUG: return ("Provide output only useful for debugging."); - case OPT_FLAG: return ("Provide flag information for storage operation."); - case OPT_EXPIRE: return ("Set the expire option for the object."); - case OPT_SET: return ("Use set command with memcached when storing."); - case OPT_REPLACE: return ("Use replace command with memcached when storing."); - case OPT_ADD: return ("Use add command with memcached when storing."); - case OPT_SLAP_EXECUTE_NUMBER: return ("Number of times to execute the given test."); - case OPT_SLAP_INITIAL_LOAD: return ("Number of key pairs to load before executing tests."); - case OPT_SLAP_TEST: return ("Test to run (currently \"get\" or \"set\")."); - case OPT_SLAP_CONCURRENCY: return ("Number of users to simulate with load."); - case OPT_SLAP_NON_BLOCK: return ("Set TCP up to use non-blocking IO."); - case OPT_SLAP_TCP_NODELAY: return ("Set TCP socket up to use nodelay."); - case OPT_FLUSH: return ("Flush servers before running tests."); - case OPT_HASH: return ("Select hash type."); - case OPT_BINARY: return ("Switch to binary protocol."); - case OPT_ANALYZE: return ("Analyze the provided servers."); - case OPT_UDP: return ("Use UDP protocol when communicating with server."); - case OPT_BUFFER: return ("Enable request buffering."); - case OPT_USERNAME: return "Username to use for SASL authentication"; - case OPT_PASSWD: return "Password to use for SASL authentication"; - case OPT_FILE: return "Path to file in which to save result"; - case OPT_STAT_ARGS: return "Argument for statistics"; - case OPT_SERVER_VERSION: return "Memcached daemon software version"; - default: break; + case OPT_SERVERS: + return ("List which servers you wish to connect to."); + case OPT_VERSION: + return ("Display the version of the application and then exit."); + case OPT_HELP: + return ("Display this message and then exit."); + case OPT_VERBOSE: + return ("Give more details on the progression of the application."); + case OPT_QUIET: + return ("stderr and stdin will be closed at application startup."); + case OPT_DEBUG: + return ("Provide output only useful for debugging."); + case OPT_FLAG: + return ("Provide flag information for storage operation."); + case OPT_EXPIRE: + return ("Set the expire option for the object."); + case OPT_SET: + return ("Use set command with memcached when storing."); + case OPT_REPLACE: + return ("Use replace command with memcached when storing."); + case OPT_ADD: + return ("Use add command with memcached when storing."); + case OPT_SLAP_EXECUTE_NUMBER: + return ("Number of times to execute the given test."); + case OPT_SLAP_INITIAL_LOAD: + return ("Number of key pairs to load before executing tests."); + case OPT_SLAP_TEST: + return ("Test to run (currently \"get\" or \"set\")."); + case OPT_SLAP_CONCURRENCY: + return ("Number of users to simulate with load."); + case OPT_SLAP_NON_BLOCK: + return ("Set TCP up to use non-blocking IO."); + case OPT_SLAP_TCP_NODELAY: + return ("Set TCP socket up to use nodelay."); + case OPT_FLUSH: + return ("Flush servers before running tests."); + case OPT_HASH: + return ("Select hash type."); + case OPT_BINARY: + return ("Switch to binary protocol."); + case OPT_ANALYZE: + return ("Analyze the provided servers."); + case OPT_UDP: + return ("Use UDP protocol when communicating with server."); + case OPT_BUFFER: + return ("Enable request buffering."); + case OPT_USERNAME: + return "Username to use for SASL authentication"; + case OPT_PASSWD: + return "Password to use for SASL authentication"; + case OPT_FILE: + return "Path to file in which to save result"; + case OPT_STAT_ARGS: + return "Argument for statistics"; + case OPT_SERVER_VERSION: + return "Memcached daemon software version"; + default: + break; }; assert(0); diff --git a/src/bin/memaslap.c b/src/bin/memaslap.c index 05919611..a5481bb8 100644 --- a/src/bin/memaslap.c +++ b/src/bin/memaslap.c @@ -204,9 +204,11 @@ static const char *ms_lookup_help(ms_options_t option) { return "List one or more servers to connect. Servers count must be less than\n" " threads count. e.g.: --servers=localhost:1234,localhost:11211"; - case OPT_VERSION: return "Display the version of the application and then exit."; + case OPT_VERSION: + return "Display the version of the application and then exit."; - case OPT_HELP: return "Display this message and then exit."; + case OPT_HELP: + return "Display this message and then exit."; case OPT_EXECUTE_NUMBER: return "Number of operations(get and set) to execute for the\n" @@ -215,13 +217,17 @@ static const char *ms_lookup_help(ms_options_t option) { case OPT_THREAD_NUMBER: return "Number of threads to startup, better equal to CPU numbers. Default 8."; - case OPT_CONCURRENCY: return "Number of concurrency to simulate with load. Default 128."; + case OPT_CONCURRENCY: + return "Number of concurrency to simulate with load. Default 128."; - case OPT_FIXED_LTH: return "Fixed length of value."; + case OPT_FIXED_LTH: + return "Fixed length of value."; - case OPT_VERIFY: return "The proportion of date verification, e.g.: --verify=0.01"; + case OPT_VERIFY: + return "The proportion of date verification, e.g.: --verify=0.01"; - case OPT_GETS_DIVISION: return "Number of keys to multi-get once. Default 1, means single get."; + case OPT_GETS_DIVISION: + return "Number of keys to multi-get once. Default 1, means single get."; case OPT_TIME: return "How long the test to run, suffix: s-seconds, m-minutes, h-hours,\n" @@ -250,11 +256,14 @@ static const char *ms_lookup_help(ms_options_t option) { return "Frequency of dumping statistic information. suffix: s-seconds,\n" " m-minutes, e.g.: --resp_freq=10s."; - case OPT_SOCK_PER_CONN: return "Number of TCP socks per concurrency. Default 1."; + case OPT_SOCK_PER_CONN: + return "Number of TCP socks per concurrency. Default 1."; - case OPT_RECONNECT: return "Reconnect support, when connection is closed it will be reconnected."; + case OPT_RECONNECT: + return "Reconnect support, when connection is closed it will be reconnected."; - case OPT_VERBOSE: return "Whether it outputs detailed information when verification fails."; + case OPT_VERBOSE: + return "Whether it outputs detailed information when verification fails."; case OPT_FACEBOOK_TEST: return "Whether it enables facebook test feature, set with TCP and multi-get with UDP."; @@ -262,11 +271,14 @@ static const char *ms_lookup_help(ms_options_t option) { case OPT_BINARY_PROTOCOL: return "Whether it enables binary protocol. Default with ASCII protocol."; - case OPT_TPS: return "Expected throughput, suffix: K, e.g.: --tps=10k."; + case OPT_TPS: + return "Expected throughput, suffix: K, e.g.: --tps=10k."; - case OPT_REP_WRITE_SRV: return "The first nth servers can write data, e.g.: --rep_write=2."; + case OPT_REP_WRITE_SRV: + return "The first nth servers can write data, e.g.: --rep_write=2."; - default: return "Forgot to document this option :)"; + default: + return "Forgot to document this option :)"; } /* switch */ } /* ms_lookup_help */ @@ -292,9 +304,12 @@ static int64_t ms_parse_time() { ret *= 60; /* fall through */ case 's': - case 'S': break; + case 'S': + break; - default: ret = -1; break; + default: + ret = -1; + break; } /* switch */ return ret; @@ -315,15 +330,23 @@ static int64_t ms_parse_size() { switch (unit) { case 'k': - case 'K': ret *= 1024; break; + case 'K': + ret *= 1024; + break; case 'm': - case 'M': ret *= 1024 * 1024; break; + case 'M': + ret *= 1024 * 1024; + break; case 'g': - case 'G': ret *= 1024 * 1024 * 1024; break; + case 'G': + ret *= 1024 * 1024 * 1024; + break; - default: ret = -1; break; + default: + ret = -1; + break; } /* switch */ return ret; @@ -341,16 +364,21 @@ static void ms_options_parse(int argc, char *argv[]) { != -1) { switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_VERSION: /* --version or -V */ ms_version_command(PROGRAM_NAME); break; + case OPT_VERSION: /* --version or -V */ + ms_version_command(PROGRAM_NAME); + break; case OPT_HELP: /* --help or -h */ ms_help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION); exit(0); break; - case OPT_SERVERS: /* --servers or -s */ ms_setting.srv_str = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + ms_setting.srv_str = strdup(optarg); + break; case OPT_CONCURRENCY: /* --concurrency or -c */ errno = 0; @@ -425,7 +453,9 @@ static void ms_options_parse(int argc, char *argv[]) { } break; - case OPT_CONFIG_CMD: /* --cfg_cmd or -F */ ms_setting.cfg_file = strdup(optarg); break; + case OPT_CONFIG_CMD: /* --cfg_cmd or -F */ + ms_setting.cfg_file = strdup(optarg); + break; case OPT_WINDOW_SIZE: /* --win_size or -w */ ms_setting.win_size = (size_t) ms_parse_size(); @@ -437,7 +467,9 @@ static void ms_options_parse(int argc, char *argv[]) { } break; - case OPT_UDP: /* --udp or -U*/ ms_setting.udp = true; break; + case OPT_UDP: /* --udp or -U*/ + ms_setting.udp = true; + break; case OPT_EXPIRE: /* --exp_verify or -e */ ms_setting.exp_ver_per = atof(optarg); @@ -489,13 +521,21 @@ static void ms_options_parse(int argc, char *argv[]) { } break; - case OPT_RECONNECT: /* --reconnect or -R */ ms_setting.reconnect = true; break; + case OPT_RECONNECT: /* --reconnect or -R */ + ms_setting.reconnect = true; + break; - case OPT_VERBOSE: /* --verbose or -b */ ms_setting.verbose = true; break; + case OPT_VERBOSE: /* --verbose or -b */ + ms_setting.verbose = true; + break; - case OPT_FACEBOOK_TEST: /* --facebook or -a */ ms_setting.facebook_test = true; break; + case OPT_FACEBOOK_TEST: /* --facebook or -a */ + ms_setting.facebook_test = true; + break; - case OPT_BINARY_PROTOCOL: /* --binary or -B */ ms_setting.binary_prot_ = true; break; + case OPT_BINARY_PROTOCOL: /* --binary or -B */ + ms_setting.binary_prot_ = true; + break; case OPT_TPS: /* --tps or -P */ ms_setting.expected_tps = (int) ms_parse_size(); @@ -522,7 +562,8 @@ static void ms_options_parse(int argc, char *argv[]) { /* getopt_long already printed an error message. */ exit(1); - default: abort(); + default: + abort(); } /* switch */ } } /* ms_options_parse */ diff --git a/src/bin/memaslap/ms_conn.c b/src/bin/memaslap/ms_conn.c index 815c67ff..dade7090 100644 --- a/src/bin/memaslap/ms_conn.c +++ b/src/bin/memaslap/ms_conn.c @@ -1006,7 +1006,9 @@ static int ms_ascii_process_line(ms_conn_t *c, char *command) { break; - case 'O': /* OK */ c->currcmd.retstat = MCD_SUCCESS; break; + case 'O': /* OK */ + c->currcmd.retstat = MCD_SUCCESS; + break; case 'S': /* STORED STATS SERVER_ERROR */ if (buffer[2] == 'A') /* STORED STATS */ { /* STATS*/ @@ -1064,7 +1066,9 @@ static int ms_ascii_process_line(ms_conn_t *c, char *command) { c->currcmd.retstat = MCD_CLIENT_ERROR; break; - default: c->currcmd.retstat = MCD_UNKNOWN_READ_FAILURE; break; + default: + c->currcmd.retstat = MCD_UNKNOWN_READ_FAILURE; + break; } /* switch */ return ret; @@ -2200,16 +2204,21 @@ static void ms_drive_machine(ms_conn_t *c) { stop = true; break; - case TRANSMIT_INCOMPLETE: c->ctnwrite = true; break; /* Continue in state machine. */ + case TRANSMIT_INCOMPLETE: + c->ctnwrite = true; + break; /* Continue in state machine. */ - case TRANSMIT_HARD_ERROR: c->ctnwrite = false; break; + case TRANSMIT_HARD_ERROR: + c->ctnwrite = false; + break; case TRANSMIT_SOFT_ERROR: c->ctnwrite = true; stop = true; break; - default: break; + default: + break; } /* switch */ break; @@ -2242,7 +2251,8 @@ static void ms_drive_machine(ms_conn_t *c) { break; } - default: assert(0); + default: + assert(0); } /* switch */ } } /* ms_drive_machine */ @@ -2362,7 +2372,8 @@ static int ms_update_conn_sock_event(ms_conn_t *c) { } break; - default: break; + default: + break; } /* switch */ if (!c->udp && (c->total_sfds > 1)) { @@ -2692,7 +2703,9 @@ static int ms_bin_process_response(ms_conn_t *c) { c->currcmd.retstat = MCD_PROTOCOL_ERROR; break; - case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: errstr = "Data exists for key."; break; + case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: + errstr = "Data exists for key."; + break; case PROTOCOL_BINARY_RESPONSE_E2BIG: errstr = "Too large."; diff --git a/src/bin/memaslap/ms_setting.c b/src/bin/memaslap/ms_setting.c index adab65a1..76101ba0 100644 --- a/src/bin/memaslap/ms_setting.c +++ b/src/bin/memaslap/ms_setting.c @@ -446,7 +446,9 @@ static void ms_parse_cfg_file(char *cfg_file) { } break; - default: assert(0); break; + default: + assert(0); + break; } /* switch */ } @@ -527,7 +529,8 @@ static int ms_shuffle_distr(ms_distr_t *distr, int length) { distr[i].value_size = tmp_size; break; - default: break; + default: + break; } /* switch */ } diff --git a/src/bin/memaslap/ms_task.c b/src/bin/memaslap/ms_task.c index 638fb485..89754ec6 100644 --- a/src/bin/memaslap/ms_task.c +++ b/src/bin/memaslap/ms_task.c @@ -793,7 +793,8 @@ static void ms_update_set_result(ms_conn_t *c, ms_task_item_t *item) { break; case MCD_SERVER_ERROR: - default: break; + default: + break; } /* switch */ } } /* ms_update_set_result */ @@ -817,7 +818,9 @@ static void ms_update_stat_result(ms_conn_t *c) { pthread_mutex_lock(&ms_statistic.stat_mutex); switch (c->precmd.cmd) { - case CMD_SET: ms_record_event(&ms_statistic.set_stat, time_diff, false); break; + case CMD_SET: + ms_record_event(&ms_statistic.set_stat, time_diff, false); + break; case CMD_GET: if (c->curr_task.get_miss) { @@ -826,7 +829,8 @@ static void ms_update_stat_result(ms_conn_t *c) { ms_record_event(&ms_statistic.get_stat, time_diff, get_miss); break; - default: break; + default: + break; } /* switch */ ms_record_event(&ms_statistic.total_stat, time_diff, get_miss); diff --git a/src/bin/memcapable.cc b/src/bin/memcapable.cc index feda49df..7b3b7c92 100644 --- a/src/bin/memcapable.cc +++ b/src/bin/memcapable.cc @@ -302,9 +302,11 @@ static enum test_return retry_read(void *buf, size_t len) { verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN); break; - case 0: return TEST_FAIL; + case 0: + return TEST_FAIL; - default: offset += (size_t) nr; + default: + offset += (size_t) nr; } } while (offset < len); @@ -465,7 +467,8 @@ static enum test_return do_validate_response_header(response *rsp, uint8_t cc, u case PROTOCOL_BINARY_CMD_SETQ: verify("Quiet command shouldn't return on success" == NULL); /* fall through */ - default: break; + default: + break; } switch (cc) { @@ -1828,19 +1831,33 @@ int main(int argc, char **argv) { } break; - case 'v': verbose = true; break; + case 'v': + verbose = true; + break; - case 'c': do_core = true; break; + case 'c': + do_core = true; + break; - case 'h': hostname = optarg; break; + case 'h': + hostname = optarg; + break; - case 'p': port = optarg; break; + case 'p': + port = optarg; + break; - case 'q': close_stdio(); break; + case 'q': + close_stdio(); + break; - case 'P': prompt = true; break; + case 'P': + prompt = true; + break; - case 'T': testname = optarg; break; + case 'T': + testname = optarg; + break; default: fprintf(stderr, diff --git a/src/bin/memcat.cc b/src/bin/memcat.cc index 6ebcf7fd..84de35ed 100644 --- a/src/bin/memcat.cc +++ b/src/bin/memcat.cc @@ -193,26 +193,48 @@ void options_parse(int argc, char *argv[]) { if (option_rv == -1) break; switch (option_rv) { - case 0: break; - case OPT_BINARY: opt_binary = 1; break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; - case OPT_VERSION: /* --version or -V */ version_command(PROGRAM_NAME); break; + case 0: + break; + case OPT_BINARY: + opt_binary = 1; + break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; + case OPT_VERSION: /* --version or -V */ + version_command(PROGRAM_NAME); + break; case OPT_HELP: /* --help or -h */ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; - case OPT_HASH: opt_hash = strdup(optarg); break; - case OPT_USERNAME: opt_username = optarg; break; - case OPT_PASSWD: opt_passwd = optarg; break; - case OPT_FILE: opt_file = optarg; break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; + case OPT_USERNAME: + opt_username = optarg; + break; + case OPT_PASSWD: + opt_passwd = optarg; + break; + case OPT_FILE: + opt_file = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: abort(); + default: + abort(); } } } diff --git a/src/bin/memcp.cc b/src/bin/memcp.cc index c0815dac..feb4dcd1 100644 --- a/src/bin/memcp.cc +++ b/src/bin/memcp.cc @@ -296,19 +296,32 @@ static void options_parse(int argc, char *argv[]) { break; switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; case OPT_FLAG: /* --flag */ { @@ -330,28 +343,47 @@ static void options_parse(int argc, char *argv[]) { } } break; - case OPT_SET: opt_method = OPT_SET; break; + case OPT_SET: + opt_method = OPT_SET; + break; - case OPT_REPLACE: opt_method = OPT_REPLACE; break; + case OPT_REPLACE: + opt_method = OPT_REPLACE; + break; - case OPT_ADD: opt_method = OPT_ADD; break; + case OPT_ADD: + opt_method = OPT_ADD; + break; - case OPT_HASH: opt_hash = strdup(optarg); break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; - case OPT_UDP: opt_udp = true; break; + case OPT_UDP: + opt_udp = true; + break; - case OPT_BUFFER: opt_buffer = true; break; + case OPT_BUFFER: + opt_buffer = true; + break; case '?': /* getopt_long already printed an error message. */ exit(1); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memdump.cc b/src/bin/memdump.cc index aa75f8a8..6d31780c 100644 --- a/src/bin/memdump.cc +++ b/src/bin/memdump.cc @@ -156,32 +156,54 @@ static void options_parse(int argc, char *argv[]) { break; switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_verbose = true; break; + case OPT_VERSION: /* --version or -V */ + opt_verbose = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; - case OPT_HASH: opt_hash = strdup(optarg); break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(1); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memerror.cc b/src/bin/memerror.cc index c35684ad..2580550f 100644 --- a/src/bin/memerror.cc +++ b/src/bin/memerror.cc @@ -84,17 +84,23 @@ void options_parse(int argc, char *argv[]) { } switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: exit(EXIT_FAILURE); + default: + exit(EXIT_FAILURE); } } diff --git a/src/bin/memexist.cc b/src/bin/memexist.cc index eec39abf..8fb69d47 100644 --- a/src/bin/memexist.cc +++ b/src/bin/memexist.cc @@ -155,33 +155,55 @@ static void options_parse(int argc, char *argv[]) { } switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = 1; break; + case OPT_BINARY: + opt_binary = 1; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; - case OPT_HASH: opt_hash = strdup(optarg); break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_SUCCESS); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memflush.cc b/src/bin/memflush.cc index baa552d1..b87521c3 100644 --- a/src/bin/memflush.cc +++ b/src/bin/memflush.cc @@ -119,19 +119,32 @@ void options_parse(int argc, char *argv[]) { if (option_rv == -1) break; switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; case OPT_EXPIRE: /* --expire */ errno = 0; @@ -142,17 +155,24 @@ void options_parse(int argc, char *argv[]) { } break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memping.cc b/src/bin/memping.cc index 184647b2..ba9c1ab2 100644 --- a/src/bin/memping.cc +++ b/src/bin/memping.cc @@ -116,21 +116,32 @@ void options_parse(int argc, char *argv[]) { break; switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ version_command(PROGRAM_NAME); break; + case OPT_VERSION: /* --version or -V */ + version_command(PROGRAM_NAME); + break; case OPT_HELP: /* --help or -h */ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; case OPT_EXPIRE: /* --expire */ errno = 0; @@ -146,14 +157,19 @@ void options_parse(int argc, char *argv[]) { opt_binary = true; break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(1); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memrm.cc b/src/bin/memrm.cc index 7bd35132..c2b4a36f 100644 --- a/src/bin/memrm.cc +++ b/src/bin/memrm.cc @@ -160,19 +160,32 @@ static void options_parse(int argc, char *argv[]) { } switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = 1; break; + case OPT_BINARY: + opt_binary = 1; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; case OPT_EXPIRE: /* --expire */ errno = 0; @@ -183,19 +196,28 @@ static void options_parse(int argc, char *argv[]) { } break; - case OPT_HASH: opt_hash = strdup(optarg); break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_SUCCESS); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memslap.cc b/src/bin/memslap.cc index b7b606e9..a8ecf2d1 100644 --- a/src/bin/memslap.cc +++ b/src/bin/memslap.cc @@ -80,7 +80,9 @@ struct thread_context_st { , memc(NULL) , root(memc_arg) {} - void init() { memc = memcached_clone(NULL, root); } + void init() { + memc = memcached_clone(NULL, root); + } ~thread_context_st() { if (execute_pairs) { @@ -143,7 +145,9 @@ static __attribute__((noreturn)) void *run_task(void *p) { execute_set(context->memc, context->execute_pairs, context->execute_number); break; - case GET_TEST: execute_get(context->memc, context->initial_pairs, context->initial_number); break; + case GET_TEST: + execute_get(context->memc, context->initial_pairs, context->initial_number); + break; case MGET_TEST: execute_mget(context->memc, (const char *const *) context->keys, context->key_lengths, @@ -345,7 +349,8 @@ void options_parse(int argc, char *argv[]) { break; switch (option_rv) { - case 0: break; + case 0: + break; case OPT_UDP: if (opt_test == GET_TEST) { @@ -357,17 +362,29 @@ void options_parse(int argc, char *argv[]) { opt_udp_io = true; break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; case OPT_SLAP_TEST: if (strcmp(optarg, "get") == 0) { @@ -415,13 +432,16 @@ void options_parse(int argc, char *argv[]) { } break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memstat.cc b/src/bin/memstat.cc index b7f75679..be2fe4a8 100644 --- a/src/bin/memstat.cc +++ b/src/bin/memstat.cc @@ -332,42 +332,64 @@ static void options_parse(int argc, char *argv[]) { break; switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = true; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = true; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = true; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = true; + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_SERVER_VERSION: opt_server_version = true; break; + case OPT_SERVER_VERSION: + opt_server_version = true; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; - case OPT_STAT_ARGS: stat_args = strdup(optarg); break; + case OPT_STAT_ARGS: + stat_args = strdup(optarg); + break; case OPT_ANALYZE: /* --analyze or -a */ opt_analyze = true; analyze_mode = (optarg) ? strdup(optarg) : NULL; break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case OPT_USERNAME: opt_username = optarg; opt_binary = true; break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; case '?': /* getopt_long already printed an error message. */ exit(1); - default: abort(); + default: + abort(); } } diff --git a/src/bin/memtouch.cc b/src/bin/memtouch.cc index 1de4b92f..e160e6a3 100644 --- a/src/bin/memtouch.cc +++ b/src/bin/memtouch.cc @@ -158,25 +158,44 @@ void options_parse(int argc, char *argv[]) { } switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_BINARY: opt_binary = true; break; + case OPT_BINARY: + opt_binary = true; + break; - case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_VERBOSE: /* --verbose or -v */ + opt_verbose = OPT_VERBOSE; + break; - case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_DEBUG: /* --debug or -d */ + opt_verbose = OPT_DEBUG; + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; - case OPT_SERVERS: /* --servers or -s */ opt_servers = strdup(optarg); break; + case OPT_SERVERS: /* --servers or -s */ + opt_servers = strdup(optarg); + break; - case OPT_HASH: opt_hash = strdup(optarg); break; + case OPT_HASH: + opt_hash = strdup(optarg); + break; - case OPT_USERNAME: opt_username = optarg; break; + case OPT_USERNAME: + opt_username = optarg; + break; - case OPT_PASSWD: opt_passwd = optarg; break; + case OPT_PASSWD: + opt_passwd = optarg; + break; case OPT_EXPIRE: errno = 0; @@ -187,13 +206,16 @@ void options_parse(int argc, char *argv[]) { } break; - case OPT_QUIET: close_stdio(); break; + case OPT_QUIET: + close_stdio(); + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: abort(); + default: + abort(); } } diff --git a/src/libhashkit/digest.cc b/src/libhashkit/digest.cc index 3ea5588f..6ca176a6 100644 --- a/src/libhashkit/digest.cc +++ b/src/libhashkit/digest.cc @@ -22,20 +22,28 @@ uint32_t hashkit_digest(const hashkit_st *self, const char *key, size_t key_leng uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algorithm_t hash_algorithm) { switch (hash_algorithm) { - case HASHKIT_HASH_DEFAULT: return libhashkit_one_at_a_time(key, key_length); - case HASHKIT_HASH_MD5: return libhashkit_md5(key, key_length); - case HASHKIT_HASH_CRC: return libhashkit_crc32(key, key_length); - case HASHKIT_HASH_FNV1_64: return libhashkit_fnv1_64(key, key_length); - case HASHKIT_HASH_FNV1A_64: return libhashkit_fnv1a_64(key, key_length); - case HASHKIT_HASH_FNV1_32: return libhashkit_fnv1_32(key, key_length); - case HASHKIT_HASH_FNV1A_32: return libhashkit_fnv1a_32(key, key_length); + case HASHKIT_HASH_DEFAULT: + return libhashkit_one_at_a_time(key, key_length); + case HASHKIT_HASH_MD5: + return libhashkit_md5(key, key_length); + case HASHKIT_HASH_CRC: + return libhashkit_crc32(key, key_length); + case HASHKIT_HASH_FNV1_64: + return libhashkit_fnv1_64(key, key_length); + case HASHKIT_HASH_FNV1A_64: + return libhashkit_fnv1a_64(key, key_length); + case HASHKIT_HASH_FNV1_32: + return libhashkit_fnv1_32(key, key_length); + case HASHKIT_HASH_FNV1A_32: + return libhashkit_fnv1a_32(key, key_length); case HASHKIT_HASH_HSIEH: #ifdef HAVE_HSIEH_HASH return libhashkit_hsieh(key, key_length); #else return 1; #endif - case HASHKIT_HASH_MURMUR3: return libhashkit_murmur3(key, key_length); + case HASHKIT_HASH_MURMUR3: + return libhashkit_murmur3(key, key_length); case HASHKIT_HASH_MURMUR: #ifdef HAVE_MURMUR_HASH @@ -43,7 +51,8 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, #else return 1; #endif - case HASHKIT_HASH_JENKINS: return libhashkit_jenkins(key, key_length); + case HASHKIT_HASH_JENKINS: + return libhashkit_jenkins(key, key_length); case HASHKIT_HASH_CUSTOM: case HASHKIT_HASH_MAX: default: diff --git a/src/libhashkit/function.cc b/src/libhashkit/function.cc index f66a63ea..67bb9947 100644 --- a/src/libhashkit/function.cc +++ b/src/libhashkit/function.cc @@ -22,9 +22,13 @@ static hashkit_return_t _set_function(struct hashkit_st::hashkit_function_st *se } switch (hash_algorithm) { - case HASHKIT_HASH_MD5: self->function = hashkit_md5; break; + case HASHKIT_HASH_MD5: + self->function = hashkit_md5; + break; - case HASHKIT_HASH_CRC: self->function = hashkit_crc32; break; + case HASHKIT_HASH_CRC: + self->function = hashkit_crc32; + break; case HASHKIT_HASH_FNV1_64: if (libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64)) { @@ -40,9 +44,13 @@ static hashkit_return_t _set_function(struct hashkit_st::hashkit_function_st *se } return HASHKIT_INVALID_ARGUMENT; - case HASHKIT_HASH_FNV1_32: self->function = hashkit_fnv1_32; break; + case HASHKIT_HASH_FNV1_32: + self->function = hashkit_fnv1_32; + break; - case HASHKIT_HASH_FNV1A_32: self->function = hashkit_fnv1a_32; break; + case HASHKIT_HASH_FNV1A_32: + self->function = hashkit_fnv1a_32; + break; case HASHKIT_HASH_HSIEH: if (libhashkit_has_algorithm(HASHKIT_HASH_HSIEH)) { @@ -64,13 +72,20 @@ static hashkit_return_t _set_function(struct hashkit_st::hashkit_function_st *se } return HASHKIT_INVALID_ARGUMENT; - case HASHKIT_HASH_JENKINS: self->function = hashkit_jenkins; break; + case HASHKIT_HASH_JENKINS: + self->function = hashkit_jenkins; + break; - case HASHKIT_HASH_CUSTOM: return HASHKIT_INVALID_ARGUMENT; + case HASHKIT_HASH_CUSTOM: + return HASHKIT_INVALID_ARGUMENT; - case HASHKIT_HASH_DEFAULT: self->function = hashkit_one_at_a_time; break; + case HASHKIT_HASH_DEFAULT: + self->function = hashkit_one_at_a_time; + break; - case HASHKIT_HASH_MAX: self->function = hashkit_one_at_a_time; return HASHKIT_INVALID_HASH; + case HASHKIT_HASH_MAX: + self->function = hashkit_one_at_a_time; + return HASHKIT_INVALID_HASH; } self->context = NULL; diff --git a/src/libhashkit/has.cc b/src/libhashkit/has.cc index 60e5af00..1a2dd762 100644 --- a/src/libhashkit/has.cc +++ b/src/libhashkit/has.cc @@ -46,9 +46,11 @@ bool libhashkit_has_algorithm(const hashkit_hash_algorithm_t algo) { case HASHKIT_HASH_MD5: case HASHKIT_HASH_CRC: case HASHKIT_HASH_JENKINS: - case HASHKIT_HASH_CUSTOM: return true; + case HASHKIT_HASH_CUSTOM: + return true; - case HASHKIT_HASH_MAX: break; + case HASHKIT_HASH_MAX: + break; } return false; diff --git a/src/libhashkit/hsieh.cc b/src/libhashkit/hsieh.cc index 6fc4fbb4..3a8baf89 100644 --- a/src/libhashkit/hsieh.cc +++ b/src/libhashkit/hsieh.cc @@ -62,7 +62,8 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *) { hash += (unsigned char) (*key); hash ^= hash << 10; hash += hash >> 1; - default: break; + default: + break; } /* Force "avalanching" of final 127 bits */ diff --git a/src/libhashkit/jenkins.cc b/src/libhashkit/jenkins.cc index b07509b9..64595f69 100644 --- a/src/libhashkit/jenkins.cc +++ b/src/libhashkit/jenkins.cc @@ -155,12 +155,22 @@ hashkit_jenkins(const char *key, size_t length, void *) { b += k[1] & 0xff; a += k[0]; break; - case 4: a += k[0]; break; - case 3: a += k[0] & 0xffffff; break; - case 2: a += k[0] & 0xffff; break; - case 1: a += k[0] & 0xff; break; - case 0: return c; /* zero length strings require no mixing */ - default: return c; + case 4: + a += k[0]; + break; + case 3: + a += k[0] & 0xffffff; + break; + case 2: + a += k[0] & 0xffff; + break; + case 1: + a += k[0] & 0xff; + break; + case 0: + return c; /* zero length strings require no mixing */ + default: + return c; } } else if ((u.i & 0x1) == 0) { @@ -210,14 +220,22 @@ hashkit_jenkins(const char *key, size_t length, void *) { case 5: b += k8[4]; /* fall through */ - case 4: a += k[0] + (((uint32_t) k[1]) << 16); break; + case 4: + a += k[0] + (((uint32_t) k[1]) << 16); + break; case 3: a += ((uint32_t) k8[2]) << 16; /* fall through */ - case 2: a += k[0]; break; - case 1: a += k8[0]; break; - case 0: return c; /* zero length requires no mixing */ - default: return c; + case 2: + a += k[0]; + break; + case 1: + a += k8[0]; + break; + case 0: + return c; /* zero length requires no mixing */ + default: + return c; } } else { /* need to read the key one byte at a time */ @@ -278,9 +296,13 @@ hashkit_jenkins(const char *key, size_t length, void *) { case 2: a += ((uint32_t) k[1]) << 8; /* fall through */ - case 1: a += k[0]; break; - case 0: return c; - default: return c; + case 1: + a += k[0]; + break; + case 0: + return c; + default: + return c; } #if !WORDS_BIGENDIAN } diff --git a/src/libhashkit/str_algorithm.cc b/src/libhashkit/str_algorithm.cc index 1a34653e..9c3bc3cd 100644 --- a/src/libhashkit/str_algorithm.cc +++ b/src/libhashkit/str_algorithm.cc @@ -17,19 +17,32 @@ const char *libhashkit_string_hash(hashkit_hash_algorithm_t type) { switch (type) { - case HASHKIT_HASH_DEFAULT: return "DEFAULT"; - case HASHKIT_HASH_MD5: return "MD5"; - case HASHKIT_HASH_CRC: return "CRC"; - case HASHKIT_HASH_FNV1_64: return "FNV1_64"; - case HASHKIT_HASH_FNV1A_64: return "FNV1A_64"; - case HASHKIT_HASH_FNV1_32: return "FNV1_32"; - case HASHKIT_HASH_FNV1A_32: return "FNV1A_32"; - case HASHKIT_HASH_HSIEH: return "HSIEH"; - case HASHKIT_HASH_MURMUR: return "MURMUR"; - case HASHKIT_HASH_MURMUR3: return "MURMUR3"; - case HASHKIT_HASH_JENKINS: return "JENKINS"; - case HASHKIT_HASH_CUSTOM: return "CUSTOM"; + case HASHKIT_HASH_DEFAULT: + return "DEFAULT"; + case HASHKIT_HASH_MD5: + return "MD5"; + case HASHKIT_HASH_CRC: + return "CRC"; + case HASHKIT_HASH_FNV1_64: + return "FNV1_64"; + case HASHKIT_HASH_FNV1A_64: + return "FNV1A_64"; + case HASHKIT_HASH_FNV1_32: + return "FNV1_32"; + case HASHKIT_HASH_FNV1A_32: + return "FNV1A_32"; + case HASHKIT_HASH_HSIEH: + return "HSIEH"; + case HASHKIT_HASH_MURMUR: + return "MURMUR"; + case HASHKIT_HASH_MURMUR3: + return "MURMUR3"; + case HASHKIT_HASH_JENKINS: + return "JENKINS"; + case HASHKIT_HASH_CUSTOM: + return "CUSTOM"; default: - case HASHKIT_HASH_MAX: return "INVALID"; + case HASHKIT_HASH_MAX: + return "INVALID"; } } diff --git a/src/libhashkit/strerror.cc b/src/libhashkit/strerror.cc index 997aff26..022fb22c 100644 --- a/src/libhashkit/strerror.cc +++ b/src/libhashkit/strerror.cc @@ -18,12 +18,18 @@ const char *hashkit_strerror(hashkit_st *ptr, hashkit_return_t rc) { (void) ptr; switch (rc) { - case HASHKIT_SUCCESS: return "SUCCESS"; - case HASHKIT_FAILURE: return "FAILURE"; - case HASHKIT_MEMORY_ALLOCATION_FAILURE: return "MEMORY ALLOCATION FAILURE"; - case HASHKIT_INVALID_ARGUMENT: return "INVALID ARGUMENT"; - case HASHKIT_INVALID_HASH: return "INVALID hashkit_hash_algorithm_t"; + case HASHKIT_SUCCESS: + return "SUCCESS"; + case HASHKIT_FAILURE: + return "FAILURE"; + case HASHKIT_MEMORY_ALLOCATION_FAILURE: + return "MEMORY ALLOCATION FAILURE"; + case HASHKIT_INVALID_ARGUMENT: + return "INVALID ARGUMENT"; + case HASHKIT_INVALID_HASH: + return "INVALID hashkit_hash_algorithm_t"; case HASHKIT_MAXIMUM_RETURN: - default: return "INVALID hashkit_return_t"; + default: + return "INVALID hashkit_return_t"; } } diff --git a/src/libmemcached/behavior.cc b/src/libmemcached/behavior.cc index 08f86f94..576ec883 100644 --- a/src/libmemcached/behavior.cc +++ b/src/libmemcached/behavior.cc @@ -25,12 +25,14 @@ bool memcached_is_consistent_distribution(const Memcached *memc) { case MEMCACHED_DISTRIBUTION_CONSISTENT: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: - case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return true; + case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: + return true; case MEMCACHED_DISTRIBUTION_MODULA: case MEMCACHED_DISTRIBUTION_RANDOM: case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: - case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: break; + case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: + break; } return false; @@ -50,19 +52,33 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b } switch (flag) { - case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: ptr->number_of_replicas = (uint32_t) data; break; + case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: + ptr->number_of_replicas = (uint32_t) data; + break; - case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: ptr->io_msg_watermark = (uint32_t) data; break; + case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: + ptr->io_msg_watermark = (uint32_t) data; + break; - case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: ptr->io_bytes_watermark = (uint32_t) data; break; + case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: + ptr->io_bytes_watermark = (uint32_t) data; + break; - case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: ptr->io_key_prefetch = (uint32_t) data; break; + case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: + ptr->io_key_prefetch = (uint32_t) data; + break; - case MEMCACHED_BEHAVIOR_SND_TIMEOUT: ptr->snd_timeout = (int32_t) data; break; + case MEMCACHED_BEHAVIOR_SND_TIMEOUT: + ptr->snd_timeout = (int32_t) data; + break; - case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: ptr->rcv_timeout = (int32_t) data; break; + case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: + ptr->rcv_timeout = (int32_t) data; + break; - case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: ptr->flags.auto_eject_hosts = bool(data); break; + case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: + ptr->flags.auto_eject_hosts = bool(data); + break; case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: if (data == 0) { @@ -74,7 +90,9 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b ptr->server_failure_limit = uint32_t(data); break; - case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: ptr->server_timeout_limit = uint32_t(data); break; + case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: + ptr->server_timeout_limit = uint32_t(data); + break; case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: send_quit( @@ -85,7 +103,9 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b ptr->flags.binary_protocol = bool(data); break; - case MEMCACHED_BEHAVIOR_SUPPORT_CAS: ptr->flags.support_cas = bool(data); break; + case MEMCACHED_BEHAVIOR_SUPPORT_CAS: + ptr->flags.support_cas = bool(data); + break; case MEMCACHED_BEHAVIOR_NO_BLOCK: ptr->flags.no_block = bool(data); @@ -176,13 +196,21 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b return run_distribution(ptr); } - case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: ptr->poll_timeout = (int32_t) data; break; + case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: + ptr->poll_timeout = (int32_t) data; + break; - case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: ptr->connect_timeout = (int32_t) data; break; + case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: + ptr->connect_timeout = (int32_t) data; + break; - case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: ptr->retry_timeout = int32_t(data); break; + case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: + ptr->retry_timeout = int32_t(data); + break; - case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: ptr->dead_timeout = int32_t(data); break; + case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: + ptr->dead_timeout = int32_t(data); + break; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: ptr->send_size = (int32_t) data; @@ -203,7 +231,9 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b return memcached_set_error(*ptr, MEMCACHED_DEPRECATED, MEMCACHED_AT, memcached_literal_param("MEMCACHED_BEHAVIOR_USER_DATA deprecated.")); - case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: ptr->flags.hash_with_namespace = bool(data); break; + case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: + ptr->flags.hash_with_namespace = bool(data); + break; case MEMCACHED_BEHAVIOR_NOREPLY: if (memcached_is_udp(ptr) and bool(data) == false) { @@ -217,7 +247,9 @@ memcached_return_t memcached_behavior_set(memcached_st *shell, const memcached_b ptr->flags.reply = bool(data) ? false : true; break; - case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: ptr->flags.auto_eject_hosts = bool(data); break; + case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: + ptr->flags.auto_eject_hosts = bool(data); + break; case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: srandom((uint32_t) time(NULL)); @@ -259,29 +291,41 @@ uint64_t memcached_behavior_get(memcached_st *shell, const memcached_behavior_t } switch (flag) { - case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: return ptr->number_of_replicas; + case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: + return ptr->number_of_replicas; - case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: return ptr->io_msg_watermark; + case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: + return ptr->io_msg_watermark; - case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: return ptr->io_bytes_watermark; + case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: + return ptr->io_bytes_watermark; - case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: return ptr->io_key_prefetch; + case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: + return ptr->io_key_prefetch; - case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: return ptr->flags.binary_protocol; + case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: + return ptr->flags.binary_protocol; - case MEMCACHED_BEHAVIOR_SUPPORT_CAS: return ptr->flags.support_cas; + case MEMCACHED_BEHAVIOR_SUPPORT_CAS: + return ptr->flags.support_cas; - case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return true; + case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: + return true; - case MEMCACHED_BEHAVIOR_NO_BLOCK: return ptr->flags.no_block; + case MEMCACHED_BEHAVIOR_NO_BLOCK: + return ptr->flags.no_block; - case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: return ptr->flags.buffer_requests; + case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: + return ptr->flags.buffer_requests; - case MEMCACHED_BEHAVIOR_USE_UDP: return memcached_is_udp(ptr); + case MEMCACHED_BEHAVIOR_USE_UDP: + return memcached_is_udp(ptr); - case MEMCACHED_BEHAVIOR_TCP_NODELAY: return ptr->flags.tcp_nodelay; + case MEMCACHED_BEHAVIOR_TCP_NODELAY: + return ptr->flags.tcp_nodelay; - case MEMCACHED_BEHAVIOR_VERIFY_KEY: return ptr->flags.verify_key; + case MEMCACHED_BEHAVIOR_VERIFY_KEY: + return ptr->flags.verify_key; case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: if (memcached_is_consistent_distribution(ptr)) { @@ -289,35 +333,50 @@ uint64_t memcached_behavior_get(memcached_st *shell, const memcached_behavior_t } return false; - case MEMCACHED_BEHAVIOR_DISTRIBUTION: return ptr->distribution; + case MEMCACHED_BEHAVIOR_DISTRIBUTION: + return ptr->distribution; - case MEMCACHED_BEHAVIOR_KETAMA: return memcached_is_consistent_distribution(ptr); + case MEMCACHED_BEHAVIOR_KETAMA: + return memcached_is_consistent_distribution(ptr); - case MEMCACHED_BEHAVIOR_HASH: return hashkit_get_function(&ptr->hashkit); + case MEMCACHED_BEHAVIOR_HASH: + return hashkit_get_function(&ptr->hashkit); - case MEMCACHED_BEHAVIOR_KETAMA_HASH: return hashkit_get_distribution_function(&ptr->hashkit); + case MEMCACHED_BEHAVIOR_KETAMA_HASH: + return hashkit_get_distribution_function(&ptr->hashkit); - case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: return ptr->flags.auto_eject_hosts; + case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: + return ptr->flags.auto_eject_hosts; - case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: return ptr->server_failure_limit; + case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: + return ptr->server_failure_limit; - case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: return ptr->server_timeout_limit; + case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: + return ptr->server_timeout_limit; - case MEMCACHED_BEHAVIOR_SORT_HOSTS: return ptr->flags.use_sort_hosts; + case MEMCACHED_BEHAVIOR_SORT_HOSTS: + return ptr->flags.use_sort_hosts; - case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: return (uint64_t) ptr->poll_timeout; + case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: + return (uint64_t) ptr->poll_timeout; - case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: return (uint64_t) ptr->connect_timeout; + case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: + return (uint64_t) ptr->connect_timeout; - case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: return (uint64_t) ptr->retry_timeout; + case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: + return (uint64_t) ptr->retry_timeout; - case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: return uint64_t(ptr->dead_timeout); + case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: + return uint64_t(ptr->dead_timeout); - case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return (uint64_t) ptr->snd_timeout; + case MEMCACHED_BEHAVIOR_SND_TIMEOUT: + return (uint64_t) ptr->snd_timeout; - case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return (uint64_t) ptr->rcv_timeout; + case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: + return (uint64_t) ptr->rcv_timeout; - case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: return (uint64_t) ptr->tcp_keepidle; + case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: + return (uint64_t) ptr->tcp_keepidle; case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: { int sock_size = 0; @@ -387,13 +446,17 @@ uint64_t memcached_behavior_get(memcached_st *shell, const memcached_behavior_t memcached_literal_param("MEMCACHED_BEHAVIOR_USER_DATA deprecated.")); return 0; - case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: return ptr->flags.hash_with_namespace; + case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: + return ptr->flags.hash_with_namespace; - case MEMCACHED_BEHAVIOR_NOREPLY: return ptr->flags.reply ? false : true; + case MEMCACHED_BEHAVIOR_NOREPLY: + return ptr->flags.reply ? false : true; - case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: return ptr->flags.auto_eject_hosts; + case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: + return ptr->flags.auto_eject_hosts; - case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: return ptr->flags.randomize_replica_read; + case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: + return ptr->flags.randomize_replica_read; case MEMCACHED_BEHAVIOR_CORK: #ifdef HAVE_MSG_MORE @@ -402,12 +465,16 @@ uint64_t memcached_behavior_get(memcached_st *shell, const memcached_behavior_t return false; #endif - case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return ptr->flags.tcp_keepalive; + case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: + return ptr->flags.tcp_keepalive; - case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return bool(memcached_parse_filename(ptr)); + case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: + return bool(memcached_parse_filename(ptr)); case MEMCACHED_BEHAVIOR_MAX: - default: assert_msg(0, "Invalid behavior passed to memcached_behavior_get()"); return 0; + default: + assert_msg(0, "Invalid behavior passed to memcached_behavior_get()"); + return 0; } /* NOTREACHED */ @@ -418,20 +485,26 @@ memcached_return_t memcached_behavior_set_distribution(memcached_st *shell, Memcached *ptr = memcached2Memcached(shell); if (ptr) { switch (type) { - case MEMCACHED_DISTRIBUTION_MODULA: break; + case MEMCACHED_DISTRIBUTION_MODULA: + break; case MEMCACHED_DISTRIBUTION_CONSISTENT: - case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: memcached_set_weighted_ketama(ptr, false); break; + case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: + memcached_set_weighted_ketama(ptr, false); + break; - case MEMCACHED_DISTRIBUTION_RANDOM: break; + case MEMCACHED_DISTRIBUTION_RANDOM: + break; - case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: break; + case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: + break; case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: memcached_set_weighted_ketama(ptr, true); break; - case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: break; + case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: + break; default: case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: @@ -507,63 +580,107 @@ memcached_hash_t memcached_behavior_get_distribution_hash(memcached_st *shell) { const char *libmemcached_string_behavior(const memcached_behavior_t flag) { switch (flag) { - case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: return "MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT"; - case MEMCACHED_BEHAVIOR_NO_BLOCK: return "MEMCACHED_BEHAVIOR_NO_BLOCK"; - case MEMCACHED_BEHAVIOR_TCP_NODELAY: return "MEMCACHED_BEHAVIOR_TCP_NODELAY"; - case MEMCACHED_BEHAVIOR_HASH: return "MEMCACHED_BEHAVIOR_HASH"; - case MEMCACHED_BEHAVIOR_KETAMA: return "MEMCACHED_BEHAVIOR_KETAMA"; - case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE"; - case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: return "MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE"; - case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: return "MEMCACHED_BEHAVIOR_CACHE_LOOKUPS"; - case MEMCACHED_BEHAVIOR_SUPPORT_CAS: return "MEMCACHED_BEHAVIOR_SUPPORT_CAS"; - case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: return "MEMCACHED_BEHAVIOR_POLL_TIMEOUT"; - case MEMCACHED_BEHAVIOR_DISTRIBUTION: return "MEMCACHED_BEHAVIOR_DISTRIBUTION"; - case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: return "MEMCACHED_BEHAVIOR_BUFFER_REQUESTS"; - case MEMCACHED_BEHAVIOR_USER_DATA: return "MEMCACHED_BEHAVIOR_USER_DATA"; - case MEMCACHED_BEHAVIOR_SORT_HOSTS: return "MEMCACHED_BEHAVIOR_SORT_HOSTS"; - case MEMCACHED_BEHAVIOR_VERIFY_KEY: return "MEMCACHED_BEHAVIOR_VERIFY_KEY"; - case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: return "MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT"; - case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: return "MEMCACHED_BEHAVIOR_RETRY_TIMEOUT"; - case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: return "MEMCACHED_BEHAVIOR_DEAD_TIMEOUT"; - case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: return "MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED"; - case MEMCACHED_BEHAVIOR_KETAMA_HASH: return "MEMCACHED_BEHAVIOR_KETAMA_HASH"; - case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: return "MEMCACHED_BEHAVIOR_BINARY_PROTOCOL"; - case MEMCACHED_BEHAVIOR_SND_TIMEOUT: return "MEMCACHED_BEHAVIOR_SND_TIMEOUT"; - case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: return "MEMCACHED_BEHAVIOR_RCV_TIMEOUT"; - case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: return "MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT"; - case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK"; - case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: return "MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK"; - case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: return "MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH"; - case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: return "MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY"; - case MEMCACHED_BEHAVIOR_NOREPLY: return "MEMCACHED_BEHAVIOR_NOREPLY"; - case MEMCACHED_BEHAVIOR_USE_UDP: return "MEMCACHED_BEHAVIOR_USE_UDP"; - case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: return "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS"; - case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: return "MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS"; - case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: return "MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS"; + case MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT: + return "MEMCACHED_BEHAVIOR_SERVER_TIMEOUT_LIMIT"; + case MEMCACHED_BEHAVIOR_NO_BLOCK: + return "MEMCACHED_BEHAVIOR_NO_BLOCK"; + case MEMCACHED_BEHAVIOR_TCP_NODELAY: + return "MEMCACHED_BEHAVIOR_TCP_NODELAY"; + case MEMCACHED_BEHAVIOR_HASH: + return "MEMCACHED_BEHAVIOR_HASH"; + case MEMCACHED_BEHAVIOR_KETAMA: + return "MEMCACHED_BEHAVIOR_KETAMA"; + case MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE: + return "MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE"; + case MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE: + return "MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE"; + case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: + return "MEMCACHED_BEHAVIOR_CACHE_LOOKUPS"; + case MEMCACHED_BEHAVIOR_SUPPORT_CAS: + return "MEMCACHED_BEHAVIOR_SUPPORT_CAS"; + case MEMCACHED_BEHAVIOR_POLL_TIMEOUT: + return "MEMCACHED_BEHAVIOR_POLL_TIMEOUT"; + case MEMCACHED_BEHAVIOR_DISTRIBUTION: + return "MEMCACHED_BEHAVIOR_DISTRIBUTION"; + case MEMCACHED_BEHAVIOR_BUFFER_REQUESTS: + return "MEMCACHED_BEHAVIOR_BUFFER_REQUESTS"; + case MEMCACHED_BEHAVIOR_USER_DATA: + return "MEMCACHED_BEHAVIOR_USER_DATA"; + case MEMCACHED_BEHAVIOR_SORT_HOSTS: + return "MEMCACHED_BEHAVIOR_SORT_HOSTS"; + case MEMCACHED_BEHAVIOR_VERIFY_KEY: + return "MEMCACHED_BEHAVIOR_VERIFY_KEY"; + case MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT: + return "MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT"; + case MEMCACHED_BEHAVIOR_RETRY_TIMEOUT: + return "MEMCACHED_BEHAVIOR_RETRY_TIMEOUT"; + case MEMCACHED_BEHAVIOR_DEAD_TIMEOUT: + return "MEMCACHED_BEHAVIOR_DEAD_TIMEOUT"; + case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: + return "MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED"; + case MEMCACHED_BEHAVIOR_KETAMA_HASH: + return "MEMCACHED_BEHAVIOR_KETAMA_HASH"; + case MEMCACHED_BEHAVIOR_BINARY_PROTOCOL: + return "MEMCACHED_BEHAVIOR_BINARY_PROTOCOL"; + case MEMCACHED_BEHAVIOR_SND_TIMEOUT: + return "MEMCACHED_BEHAVIOR_SND_TIMEOUT"; + case MEMCACHED_BEHAVIOR_RCV_TIMEOUT: + return "MEMCACHED_BEHAVIOR_RCV_TIMEOUT"; + case MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT: + return "MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT"; + case MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK: + return "MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK"; + case MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK: + return "MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK"; + case MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH: + return "MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH"; + case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: + return "MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY"; + case MEMCACHED_BEHAVIOR_NOREPLY: + return "MEMCACHED_BEHAVIOR_NOREPLY"; + case MEMCACHED_BEHAVIOR_USE_UDP: + return "MEMCACHED_BEHAVIOR_USE_UDP"; + case MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS: + return "MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS"; + case MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS: + return "MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS"; + case MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS: + return "MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS"; case MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ: return "MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ"; - case MEMCACHED_BEHAVIOR_CORK: return "MEMCACHED_BEHAVIOR_CORK"; - case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: return "MEMCACHED_BEHAVIOR_TCP_KEEPALIVE"; - case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: return "MEMCACHED_BEHAVIOR_TCP_KEEPIDLE"; - case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: return "MEMCACHED_BEHAVIOR_LOAD_FROM_FILE"; + case MEMCACHED_BEHAVIOR_CORK: + return "MEMCACHED_BEHAVIOR_CORK"; + case MEMCACHED_BEHAVIOR_TCP_KEEPALIVE: + return "MEMCACHED_BEHAVIOR_TCP_KEEPALIVE"; + case MEMCACHED_BEHAVIOR_TCP_KEEPIDLE: + return "MEMCACHED_BEHAVIOR_TCP_KEEPIDLE"; + case MEMCACHED_BEHAVIOR_LOAD_FROM_FILE: + return "MEMCACHED_BEHAVIOR_LOAD_FROM_FILE"; default: - case MEMCACHED_BEHAVIOR_MAX: return "INVALID memcached_behavior_t"; + case MEMCACHED_BEHAVIOR_MAX: + return "INVALID memcached_behavior_t"; } } const char *libmemcached_string_distribution(const memcached_server_distribution_t flag) { switch (flag) { - case MEMCACHED_DISTRIBUTION_MODULA: return "MEMCACHED_DISTRIBUTION_MODULA"; - case MEMCACHED_DISTRIBUTION_CONSISTENT: return "MEMCACHED_DISTRIBUTION_CONSISTENT"; - case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA"; - case MEMCACHED_DISTRIBUTION_RANDOM: return "MEMCACHED_DISTRIBUTION_RANDOM"; + case MEMCACHED_DISTRIBUTION_MODULA: + return "MEMCACHED_DISTRIBUTION_MODULA"; + case MEMCACHED_DISTRIBUTION_CONSISTENT: + return "MEMCACHED_DISTRIBUTION_CONSISTENT"; + case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: + return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA"; + case MEMCACHED_DISTRIBUTION_RANDOM: + return "MEMCACHED_DISTRIBUTION_RANDOM"; case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: return "MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY"; case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return "MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED"; - case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: return "MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET"; + case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: + return "MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET"; default: - case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: return "INVALID memcached_server_distribution_t"; + case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: + return "INVALID memcached_server_distribution_t"; } } diff --git a/src/libmemcached/callback.cc b/src/libmemcached/callback.cc index eaa54568..fbbf68d7 100644 --- a/src/libmemcached/callback.cc +++ b/src/libmemcached/callback.cc @@ -136,7 +136,8 @@ void *memcached_callback_get(memcached_st *shell, const memcached_callback_t fla return *(void **) &ptr->delete_trigger; } - case MEMCACHED_CALLBACK_MAX: break; + case MEMCACHED_CALLBACK_MAX: + break; } assert_msg(0, "Invalid callback passed to memcached_callback_get()"); diff --git a/src/libmemcached/connect.cc b/src/libmemcached/connect.cc index 04b86f62..3648a242 100644 --- a/src/libmemcached/connect.cc +++ b/src/libmemcached/connect.cc @@ -65,7 +65,8 @@ static memcached_return_t connect_poll(memcached_instance_st *server, const int #ifdef __linux__ case ERESTART: #endif - case EINTR: continue; + case EINTR: + continue; case EFAULT: case ENOMEM: @@ -422,9 +423,13 @@ static memcached_return_t unix_socket_connect(memcached_instance_st *server) { switch (errno) { case EINPROGRESS: case EALREADY: - case EAGAIN: server->events(POLLOUT); break; + case EAGAIN: + server->events(POLLOUT); + break; - case EINTR: server->reset_socket(); continue; + case EINTR: + server->reset_socket(); + continue; case EISCONN: /* We were spinning waiting on connect */ { @@ -509,7 +514,9 @@ static memcached_return_t network_connect(memcached_instance_st *server) { /* An error occurred */ int local_error = get_socket_errno(); switch (local_error) { - case ETIMEDOUT: timeout_error_occured = true; break; + case ETIMEDOUT: + timeout_error_occured = true; + break; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: @@ -544,7 +551,9 @@ static memcached_return_t network_connect(memcached_instance_st *server) { case ECONNREFUSED: // Probably not running service - default: memcached_set_errno(*server, local_error, MEMCACHED_AT); break; + default: + memcached_set_errno(*server, local_error, MEMCACHED_AT); + break; } WATCHPOINT_ASSERT(server->fd != INVALID_SOCKET); @@ -672,7 +681,8 @@ static memcached_return_t _memcached_connect(memcached_instance_st *server, /* We need to clean up the multi startup piece */ switch (server->type) { case MEMCACHED_CONNECTION_UDP: - case MEMCACHED_CONNECTION_TCP: rc = network_connect(server); + case MEMCACHED_CONNECTION_TCP: + rc = network_connect(server); #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) if (LIBMEMCACHED_WITH_SASL_SUPPORT) { @@ -687,7 +697,9 @@ static memcached_return_t _memcached_connect(memcached_instance_st *server, #endif break; - case MEMCACHED_CONNECTION_UNIX_SOCKET: rc = unix_socket_connect(server); break; + case MEMCACHED_CONNECTION_UNIX_SOCKET: + rc = unix_socket_connect(server); + break; } if (memcached_success(rc)) { diff --git a/src/libmemcached/csl/context.h b/src/libmemcached/csl/context.h index 2fa62407..4339f9e5 100644 --- a/src/libmemcached/csl/context.h +++ b/src/libmemcached/csl/context.h @@ -41,7 +41,9 @@ public: memcached_string_create(memc, &_string_buffer, 1024); } - bool end() { return _end; } + bool end() { + return _end; + } void start(); @@ -52,17 +54,25 @@ public: bool set_hash(memcached_hash_t hash); - void set_server() { _is_server = true; } + void set_server() { + _is_server = true; + } - void unset_server() { _is_server = false; } + void unset_server() { + _is_server = false; + } - bool is_server() const { return _is_server; } + bool is_server() const { + return _is_server; + } void hostname(const char *, size_t, server_t &); bool string_buffer(const char *, size_t, memcached_string_t &); - const char *hostname() const { return _hostname; } + const char *hostname() const { + return _hostname; + } void abort(const char *, config_tokentype, const char *); void error(const char *, config_tokentype, const char *); diff --git a/src/libmemcached/flag.cc b/src/libmemcached/flag.cc index c17ea4e0..dec8266c 100644 --- a/src/libmemcached/flag.cc +++ b/src/libmemcached/flag.cc @@ -17,35 +17,50 @@ bool memcached_flag(const memcached_st &memc, const memcached_flag_t flag) { switch (flag) { - case MEMCACHED_FLAG_AUTO_EJECT_HOSTS: return memcached_is_auto_eject_hosts(&memc); + case MEMCACHED_FLAG_AUTO_EJECT_HOSTS: + return memcached_is_auto_eject_hosts(&memc); - case MEMCACHED_FLAG_BINARY_PROTOCOL: return memcached_is_binary(&memc); + case MEMCACHED_FLAG_BINARY_PROTOCOL: + return memcached_is_binary(&memc); - case MEMCACHED_FLAG_BUFFER_REQUESTS: return memcached_is_buffering(&memc); + case MEMCACHED_FLAG_BUFFER_REQUESTS: + return memcached_is_buffering(&memc); - case MEMCACHED_FLAG_HASH_WITH_NAMESPACE: return memcached_is_hash_with_namespace(&memc); + case MEMCACHED_FLAG_HASH_WITH_NAMESPACE: + return memcached_is_hash_with_namespace(&memc); - case MEMCACHED_FLAG_NO_BLOCK: return memcached_is_no_block(&memc); + case MEMCACHED_FLAG_NO_BLOCK: + return memcached_is_no_block(&memc); - case MEMCACHED_FLAG_REPLY: return memcached_is_replying(&memc); + case MEMCACHED_FLAG_REPLY: + return memcached_is_replying(&memc); - case MEMCACHED_FLAG_RANDOMIZE_REPLICA_READ: return memcached_is_randomize_replica_read(&memc); + case MEMCACHED_FLAG_RANDOMIZE_REPLICA_READ: + return memcached_is_randomize_replica_read(&memc); - case MEMCACHED_FLAG_SUPPORT_CAS: return memcached_is_cas(&memc); + case MEMCACHED_FLAG_SUPPORT_CAS: + return memcached_is_cas(&memc); - case MEMCACHED_FLAG_TCP_NODELAY: return memcached_is_tcp_nodelay(&memc); + case MEMCACHED_FLAG_TCP_NODELAY: + return memcached_is_tcp_nodelay(&memc); - case MEMCACHED_FLAG_USE_SORT_HOSTS: return memcached_is_use_sort_hosts(&memc); + case MEMCACHED_FLAG_USE_SORT_HOSTS: + return memcached_is_use_sort_hosts(&memc); - case MEMCACHED_FLAG_USE_UDP: return memcached_is_udp(&memc); + case MEMCACHED_FLAG_USE_UDP: + return memcached_is_udp(&memc); - case MEMCACHED_FLAG_VERIFY_KEY: return memcached_is_verify_key(&memc); + case MEMCACHED_FLAG_VERIFY_KEY: + return memcached_is_verify_key(&memc); - case MEMCACHED_FLAG_TCP_KEEPALIVE: return memcached_is_use_sort_hosts(&memc); + case MEMCACHED_FLAG_TCP_KEEPALIVE: + return memcached_is_use_sort_hosts(&memc); - case MEMCACHED_FLAG_IS_AES: return memcached_is_aes(&memc); + case MEMCACHED_FLAG_IS_AES: + return memcached_is_aes(&memc); - case MEMCACHED_FLAG_IS_FETCHING_VERSION: return memcached_is_fetching_version(&memc); + case MEMCACHED_FLAG_IS_FETCHING_VERSION: + return memcached_is_fetching_version(&memc); } abort(); @@ -53,36 +68,64 @@ bool memcached_flag(const memcached_st &memc, const memcached_flag_t flag) { void memcached_flag(memcached_st &memc, const memcached_flag_t flag, const bool arg) { switch (flag) { - case MEMCACHED_FLAG_AUTO_EJECT_HOSTS: memcached_set_auto_eject_hosts(memc, arg); break; + case MEMCACHED_FLAG_AUTO_EJECT_HOSTS: + memcached_set_auto_eject_hosts(memc, arg); + break; - case MEMCACHED_FLAG_BINARY_PROTOCOL: memcached_set_binary(memc, arg); break; + case MEMCACHED_FLAG_BINARY_PROTOCOL: + memcached_set_binary(memc, arg); + break; - case MEMCACHED_FLAG_BUFFER_REQUESTS: memcached_set_buffering(memc, arg); break; + case MEMCACHED_FLAG_BUFFER_REQUESTS: + memcached_set_buffering(memc, arg); + break; - case MEMCACHED_FLAG_HASH_WITH_NAMESPACE: memcached_set_hash_with_namespace(memc, arg); break; + case MEMCACHED_FLAG_HASH_WITH_NAMESPACE: + memcached_set_hash_with_namespace(memc, arg); + break; - case MEMCACHED_FLAG_NO_BLOCK: memcached_set_no_block(memc, arg); break; + case MEMCACHED_FLAG_NO_BLOCK: + memcached_set_no_block(memc, arg); + break; - case MEMCACHED_FLAG_REPLY: memcached_set_replying(memc, arg); break; + case MEMCACHED_FLAG_REPLY: + memcached_set_replying(memc, arg); + break; case MEMCACHED_FLAG_RANDOMIZE_REPLICA_READ: memcached_set_randomize_replica_read(memc, arg); break; - case MEMCACHED_FLAG_SUPPORT_CAS: memcached_set_cas(memc, arg); break; + case MEMCACHED_FLAG_SUPPORT_CAS: + memcached_set_cas(memc, arg); + break; - case MEMCACHED_FLAG_TCP_NODELAY: memcached_set_tcp_nodelay(memc, arg); break; + case MEMCACHED_FLAG_TCP_NODELAY: + memcached_set_tcp_nodelay(memc, arg); + break; - case MEMCACHED_FLAG_USE_SORT_HOSTS: memcached_set_use_sort_hosts(memc, arg); break; + case MEMCACHED_FLAG_USE_SORT_HOSTS: + memcached_set_use_sort_hosts(memc, arg); + break; - case MEMCACHED_FLAG_USE_UDP: memcached_set_udp(memc, arg); break; + case MEMCACHED_FLAG_USE_UDP: + memcached_set_udp(memc, arg); + break; - case MEMCACHED_FLAG_VERIFY_KEY: memcached_set_verify_key(memc, arg); break; + case MEMCACHED_FLAG_VERIFY_KEY: + memcached_set_verify_key(memc, arg); + break; - case MEMCACHED_FLAG_TCP_KEEPALIVE: memcached_set_use_sort_hosts(memc, arg); break; + case MEMCACHED_FLAG_TCP_KEEPALIVE: + memcached_set_use_sort_hosts(memc, arg); + break; - case MEMCACHED_FLAG_IS_AES: memcached_set_aes(memc, arg); break; + case MEMCACHED_FLAG_IS_AES: + memcached_set_aes(memc, arg); + break; - case MEMCACHED_FLAG_IS_FETCHING_VERSION: memcached_set_fetching_version(memc, arg); break; + case MEMCACHED_FLAG_IS_FETCHING_VERSION: + memcached_set_fetching_version(memc, arg); + break; } } diff --git a/src/libmemcached/hash.cc b/src/libmemcached/hash.cc index 33766b5f..e062e4e7 100644 --- a/src/libmemcached/hash.cc +++ b/src/libmemcached/hash.cc @@ -52,8 +52,10 @@ static uint32_t dispatch_host(const Memcached *ptr, uint32_t hash) { right = begin; return right->index; } - case MEMCACHED_DISTRIBUTION_MODULA: return hash % memcached_server_count(ptr); - case MEMCACHED_DISTRIBUTION_RANDOM: return (uint32_t) random() % memcached_server_count(ptr); + case MEMCACHED_DISTRIBUTION_MODULA: + return hash % memcached_server_count(ptr); + case MEMCACHED_DISTRIBUTION_RANDOM: + return (uint32_t) random() % memcached_server_count(ptr); case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: { return memcached_virtual_bucket_get(ptr, hash); } diff --git a/src/libmemcached/hosts.cc b/src/libmemcached/hosts.cc index 8afbdb25..0ce66130 100644 --- a/src/libmemcached/hosts.cc +++ b/src/libmemcached/hosts.cc @@ -51,15 +51,20 @@ memcached_return_t run_distribution(Memcached *ptr) { case MEMCACHED_DISTRIBUTION_CONSISTENT: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: - case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return update_continuum(ptr); + case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: + return update_continuum(ptr); case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: - case MEMCACHED_DISTRIBUTION_MODULA: break; + case MEMCACHED_DISTRIBUTION_MODULA: + break; - case MEMCACHED_DISTRIBUTION_RANDOM: srandom((uint32_t) time(NULL)); break; + case MEMCACHED_DISTRIBUTION_RANDOM: + srandom((uint32_t) time(NULL)); + break; case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: - default: assert_msg(0, "Invalid distribution type passed to run_distribution()"); + default: + assert_msg(0, "Invalid distribution type passed to run_distribution()"); } return MEMCACHED_SUCCESS; diff --git a/src/libmemcached/io.cc b/src/libmemcached/io.cc index 087ae606..8e5d93b7 100644 --- a/src/libmemcached/io.cc +++ b/src/libmemcached/io.cc @@ -56,7 +56,8 @@ static bool repack_input_buffer(memcached_instance_st *instance) { memcached_set_error(*instance, MEMCACHED_CONNECTION_FAILURE, MEMCACHED_AT); } else { switch (get_socket_errno()) { - case EINTR: continue; + case EINTR: + continue; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: @@ -67,7 +68,8 @@ static bool repack_input_buffer(memcached_instance_st *instance) { #endif break; // No IO is fine, we can just move on - default: memcached_set_errno(*instance, get_socket_errno(), MEMCACHED_AT); + default: + memcached_set_errno(*instance, get_socket_errno(), MEMCACHED_AT); } } @@ -213,7 +215,8 @@ static memcached_return_t io_wait(memcached_instance_st *instance, const short e #ifdef __linux case ERESTART: #endif - case EINTR: continue; + case EINTR: + continue; case EFAULT: case ENOMEM: @@ -293,7 +296,8 @@ static bool io_flush(memcached_instance_st *instance, const bool with_flush, WATCHPOINT_NUMBER(get_socket_errno()); #endif switch (get_socket_errno()) { - case ENOBUFS: continue; + case ENOBUFS: + continue; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: @@ -515,7 +519,8 @@ memcached_return_t memcached_io_slurp(memcached_instance_st *instance) { case EINVAL: case EFAULT: case ECONNREFUSED: - default: return MEMCACHED_CONNECTION_FAILURE; // We want this! + default: + return MEMCACHED_CONNECTION_FAILURE; // We want this! } } } while (data_read > 0); @@ -694,7 +699,8 @@ memcached_instance_st *memcached_io_get_readable_server(Memcached *memc, memcach case -1: memcached_set_errno(*memc, get_socket_errno(), MEMCACHED_AT); /* FALLTHROUGH */ - case 0: break; + case 0: + break; default: for (nfds_t x = 0; x < host_index; ++x) { diff --git a/src/libmemcached/purge.cc b/src/libmemcached/purge.cc index a347e9cb..ae3961b2 100644 --- a/src/libmemcached/purge.cc +++ b/src/libmemcached/purge.cc @@ -24,7 +24,9 @@ public: memcached_set_purging(_memc, true); } - ~Purge() { memcached_set_purging(_memc, false); } + ~Purge() { + memcached_set_purging(_memc, false); + } private: Memcached *_memc; @@ -38,7 +40,9 @@ public: _origin = ms; } - ~PollTimeout() { _origin = _timeout; } + ~PollTimeout() { + _origin = _timeout; + } private: int32_t _timeout; diff --git a/src/libmemcached/response.cc b/src/libmemcached/response.cc index ffd361e3..174ed957 100644 --- a/src/libmemcached/response.cc +++ b/src/libmemcached/response.cc @@ -421,7 +421,8 @@ static memcached_return_t textual_read_one_response(memcached_instance_st *insta return MEMCACHED_SUCCESS; } - default: break; + default: + break; } buffer[total_read] = 0; @@ -691,28 +692,44 @@ static memcached_return_t binary_read_one_response(memcached_instance_st *instan case PROTOCOL_BINARY_CMD_ADDQ: case PROTOCOL_BINARY_CMD_REPLACEQ: case PROTOCOL_BINARY_CMD_APPENDQ: - case PROTOCOL_BINARY_CMD_PREPENDQ: return MEMCACHED_FETCH_NOTFINISHED; + case PROTOCOL_BINARY_CMD_PREPENDQ: + return MEMCACHED_FETCH_NOTFINISHED; - default: break; + default: + break; } } rc = MEMCACHED_SUCCESS; if (header.response.status != 0) { switch (header.response.status) { - case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: rc = MEMCACHED_NOTFOUND; break; + case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: + rc = MEMCACHED_NOTFOUND; + break; - case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: rc = MEMCACHED_DATA_EXISTS; break; + case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: + rc = MEMCACHED_DATA_EXISTS; + break; - case PROTOCOL_BINARY_RESPONSE_NOT_STORED: rc = MEMCACHED_NOTSTORED; break; + case PROTOCOL_BINARY_RESPONSE_NOT_STORED: + rc = MEMCACHED_NOTSTORED; + break; - case PROTOCOL_BINARY_RESPONSE_E2BIG: rc = MEMCACHED_E2BIG; break; + case PROTOCOL_BINARY_RESPONSE_E2BIG: + rc = MEMCACHED_E2BIG; + break; - case PROTOCOL_BINARY_RESPONSE_ENOMEM: rc = MEMCACHED_MEMORY_ALLOCATION_FAILURE; break; + case PROTOCOL_BINARY_RESPONSE_ENOMEM: + rc = MEMCACHED_MEMORY_ALLOCATION_FAILURE; + break; - case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: rc = MEMCACHED_AUTH_CONTINUE; break; + case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: + rc = MEMCACHED_AUTH_CONTINUE; + break; - case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: rc = MEMCACHED_AUTH_FAILURE; break; + case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: + rc = MEMCACHED_AUTH_FAILURE; + break; case PROTOCOL_BINARY_RESPONSE_EINVAL: case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: diff --git a/src/libmemcached/sasl.cc b/src/libmemcached/sasl.cc index 637ceeef..a190c5b7 100644 --- a/src/libmemcached/sasl.cc +++ b/src/libmemcached/sasl.cc @@ -394,7 +394,8 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st switch (source->sasl.callbacks[total].id) { case SASL_CB_USER: case SASL_CB_AUTHNAME: - case SASL_CB_PASS: break; + case SASL_CB_PASS: + break; default: /* I don't know how to deal with this... */ return MEMCACHED_NOT_SUPPORTED; diff --git a/src/libmemcached/server.cc b/src/libmemcached/server.cc index bf028621..e038196a 100644 --- a/src/libmemcached/server.cc +++ b/src/libmemcached/server.cc @@ -188,11 +188,14 @@ uint32_t memcached_server_response_count(const memcached_instance_st *self) { const char *memcached_server_type(const memcached_instance_st *ptr) { if (ptr) { switch (ptr->type) { - case MEMCACHED_CONNECTION_TCP: return "TCP"; + case MEMCACHED_CONNECTION_TCP: + return "TCP"; - case MEMCACHED_CONNECTION_UDP: return "UDP"; + case MEMCACHED_CONNECTION_UDP: + return "UDP"; - case MEMCACHED_CONNECTION_UNIX_SOCKET: return "SOCKET"; + case MEMCACHED_CONNECTION_UNIX_SOCKET: + return "SOCKET"; } } diff --git a/src/libmemcached/storage.cc b/src/libmemcached/storage.cc index 0700c055..0404b193 100644 --- a/src/libmemcached/storage.cc +++ b/src/libmemcached/storage.cc @@ -20,17 +20,23 @@ enum memcached_storage_action_t { SET_OP, REPLACE_OP, ADD_OP, PREPEND_OP, APPEND /* Inline this */ static inline const char *storage_op_string(memcached_storage_action_t verb) { switch (verb) { - case REPLACE_OP: return "replace "; + case REPLACE_OP: + return "replace "; - case ADD_OP: return "add "; + case ADD_OP: + return "add "; - case PREPEND_OP: return "prepend "; + case PREPEND_OP: + return "prepend "; - case APPEND_OP: return "append "; + case APPEND_OP: + return "append "; - case CAS_OP: return "cas "; + case CAS_OP: + return "cas "; - case SET_OP: break; + case SET_OP: + break; } return "set "; @@ -41,10 +47,12 @@ static inline bool can_by_encrypted(const memcached_storage_action_t verb) { case SET_OP: case ADD_OP: case CAS_OP: - case REPLACE_OP: return true; + case REPLACE_OP: + return true; case APPEND_OP: - case PREPEND_OP: break; + case PREPEND_OP: + break; } return false; @@ -53,30 +61,40 @@ static inline bool can_by_encrypted(const memcached_storage_action_t verb) { static inline uint8_t get_com_code(const memcached_storage_action_t verb, const bool reply) { if (reply == false) { switch (verb) { - case SET_OP: return PROTOCOL_BINARY_CMD_SETQ; + case SET_OP: + return PROTOCOL_BINARY_CMD_SETQ; - case ADD_OP: return PROTOCOL_BINARY_CMD_ADDQ; + case ADD_OP: + return PROTOCOL_BINARY_CMD_ADDQ; case CAS_OP: /* FALLTHROUGH */ - case REPLACE_OP: return PROTOCOL_BINARY_CMD_REPLACEQ; + case REPLACE_OP: + return PROTOCOL_BINARY_CMD_REPLACEQ; - case APPEND_OP: return PROTOCOL_BINARY_CMD_APPENDQ; + case APPEND_OP: + return PROTOCOL_BINARY_CMD_APPENDQ; - case PREPEND_OP: return PROTOCOL_BINARY_CMD_PREPENDQ; + case PREPEND_OP: + return PROTOCOL_BINARY_CMD_PREPENDQ; } } switch (verb) { - case SET_OP: break; + case SET_OP: + break; - case ADD_OP: return PROTOCOL_BINARY_CMD_ADD; + case ADD_OP: + return PROTOCOL_BINARY_CMD_ADD; case CAS_OP: /* FALLTHROUGH */ - case REPLACE_OP: return PROTOCOL_BINARY_CMD_REPLACE; + case REPLACE_OP: + return PROTOCOL_BINARY_CMD_REPLACE; - case APPEND_OP: return PROTOCOL_BINARY_CMD_APPEND; + case APPEND_OP: + return PROTOCOL_BINARY_CMD_APPEND; - case PREPEND_OP: return PROTOCOL_BINARY_CMD_PREPEND; + case PREPEND_OP: + return PROTOCOL_BINARY_CMD_PREPEND; } return PROTOCOL_BINARY_CMD_SET; diff --git a/src/libmemcached/strerror.cc b/src/libmemcached/strerror.cc index 3dc89811..24a5e44d 100644 --- a/src/libmemcached/strerror.cc +++ b/src/libmemcached/strerror.cc @@ -17,109 +17,155 @@ const char *memcached_strerror(const memcached_st *, memcached_return_t rc) { switch (rc) { - case MEMCACHED_SUCCESS: return "SUCCESS"; + case MEMCACHED_SUCCESS: + return "SUCCESS"; - case MEMCACHED_FAILURE: return "FAILURE"; + case MEMCACHED_FAILURE: + return "FAILURE"; case MEMCACHED_HOST_LOOKUP_FAILURE: // getaddrinfo only return "getaddrinfo() or getnameinfo() HOSTNAME LOOKUP FAILURE"; - case MEMCACHED_CONNECTION_FAILURE: return "CONNECTION FAILURE"; + case MEMCACHED_CONNECTION_FAILURE: + return "CONNECTION FAILURE"; case MEMCACHED_CONNECTION_BIND_FAILURE: // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE return "CONNECTION BIND FAILURE"; - case MEMCACHED_READ_FAILURE: return "READ FAILURE"; + case MEMCACHED_READ_FAILURE: + return "READ FAILURE"; - case MEMCACHED_UNKNOWN_READ_FAILURE: return "UNKNOWN READ FAILURE"; + case MEMCACHED_UNKNOWN_READ_FAILURE: + return "UNKNOWN READ FAILURE"; - case MEMCACHED_PROTOCOL_ERROR: return "PROTOCOL ERROR"; + case MEMCACHED_PROTOCOL_ERROR: + return "PROTOCOL ERROR"; - case MEMCACHED_CLIENT_ERROR: return "CLIENT ERROR"; + case MEMCACHED_CLIENT_ERROR: + return "CLIENT ERROR"; - case MEMCACHED_SERVER_ERROR: return "SERVER ERROR"; + case MEMCACHED_SERVER_ERROR: + return "SERVER ERROR"; - case MEMCACHED_WRITE_FAILURE: return "WRITE FAILURE"; + case MEMCACHED_WRITE_FAILURE: + return "WRITE FAILURE"; - case MEMCACHED_ERROR: return "ERROR was returned by server"; + case MEMCACHED_ERROR: + return "ERROR was returned by server"; - case MEMCACHED_DATA_EXISTS: return "CONNECTION DATA EXISTS"; + case MEMCACHED_DATA_EXISTS: + return "CONNECTION DATA EXISTS"; - case MEMCACHED_DATA_DOES_NOT_EXIST: return "CONNECTION DATA DOES NOT EXIST"; + case MEMCACHED_DATA_DOES_NOT_EXIST: + return "CONNECTION DATA DOES NOT EXIST"; - case MEMCACHED_NOTSTORED: return "NOT STORED"; + case MEMCACHED_NOTSTORED: + return "NOT STORED"; - case MEMCACHED_STORED: return "STORED"; + case MEMCACHED_STORED: + return "STORED"; - case MEMCACHED_NOTFOUND: return "NOT FOUND"; + case MEMCACHED_NOTFOUND: + return "NOT FOUND"; - case MEMCACHED_MEMORY_ALLOCATION_FAILURE: return "MEMORY ALLOCATION FAILURE"; + case MEMCACHED_MEMORY_ALLOCATION_FAILURE: + return "MEMORY ALLOCATION FAILURE"; - case MEMCACHED_PARTIAL_READ: return "PARTIAL READ"; + case MEMCACHED_PARTIAL_READ: + return "PARTIAL READ"; - case MEMCACHED_SOME_ERRORS: return "SOME ERRORS WERE REPORTED"; + case MEMCACHED_SOME_ERRORS: + return "SOME ERRORS WERE REPORTED"; - case MEMCACHED_NO_SERVERS: return "NO SERVERS DEFINED"; + case MEMCACHED_NO_SERVERS: + return "NO SERVERS DEFINED"; - case MEMCACHED_END: return "SERVER END"; + case MEMCACHED_END: + return "SERVER END"; - case MEMCACHED_DELETED: return "SERVER DELETE"; + case MEMCACHED_DELETED: + return "SERVER DELETE"; - case MEMCACHED_VALUE: return "SERVER VALUE"; + case MEMCACHED_VALUE: + return "SERVER VALUE"; - case MEMCACHED_STAT: return "STAT VALUE"; + case MEMCACHED_STAT: + return "STAT VALUE"; - case MEMCACHED_ITEM: return "ITEM VALUE"; + case MEMCACHED_ITEM: + return "ITEM VALUE"; - case MEMCACHED_ERRNO: return "SYSTEM ERROR"; + case MEMCACHED_ERRNO: + return "SYSTEM ERROR"; - case MEMCACHED_FAIL_UNIX_SOCKET: return "COULD NOT OPEN UNIX SOCKET"; + case MEMCACHED_FAIL_UNIX_SOCKET: + return "COULD NOT OPEN UNIX SOCKET"; - case MEMCACHED_NOT_SUPPORTED: return "ACTION NOT SUPPORTED"; + case MEMCACHED_NOT_SUPPORTED: + return "ACTION NOT SUPPORTED"; - case MEMCACHED_FETCH_NOTFINISHED: return "FETCH WAS NOT COMPLETED"; + case MEMCACHED_FETCH_NOTFINISHED: + return "FETCH WAS NOT COMPLETED"; - case MEMCACHED_NO_KEY_PROVIDED: return "A KEY LENGTH OF ZERO WAS PROVIDED"; + case MEMCACHED_NO_KEY_PROVIDED: + return "A KEY LENGTH OF ZERO WAS PROVIDED"; - case MEMCACHED_BUFFERED: return "ACTION QUEUED"; + case MEMCACHED_BUFFERED: + return "ACTION QUEUED"; - case MEMCACHED_TIMEOUT: return "A TIMEOUT OCCURRED"; + case MEMCACHED_TIMEOUT: + return "A TIMEOUT OCCURRED"; - case MEMCACHED_BAD_KEY_PROVIDED: return "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"; + case MEMCACHED_BAD_KEY_PROVIDED: + return "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"; case MEMCACHED_INVALID_HOST_PROTOCOL: return "THE HOST TRANSPORT PROTOCOL DOES NOT MATCH THAT OF THE CLIENT"; - case MEMCACHED_SERVER_MARKED_DEAD: return "SERVER IS MARKED DEAD"; + case MEMCACHED_SERVER_MARKED_DEAD: + return "SERVER IS MARKED DEAD"; - case MEMCACHED_UNKNOWN_STAT_KEY: return "ENCOUNTERED AN UNKNOWN STAT KEY"; + case MEMCACHED_UNKNOWN_STAT_KEY: + return "ENCOUNTERED AN UNKNOWN STAT KEY"; - case MEMCACHED_E2BIG: return "ITEM TOO BIG"; + case MEMCACHED_E2BIG: + return "ITEM TOO BIG"; - case MEMCACHED_INVALID_ARGUMENTS: return "INVALID ARGUMENTS"; + case MEMCACHED_INVALID_ARGUMENTS: + return "INVALID ARGUMENTS"; - case MEMCACHED_KEY_TOO_BIG: return "KEY RETURNED FROM SERVER WAS TOO LARGE"; + case MEMCACHED_KEY_TOO_BIG: + return "KEY RETURNED FROM SERVER WAS TOO LARGE"; - case MEMCACHED_AUTH_PROBLEM: return "FAILED TO SEND AUTHENTICATION TO SERVER"; + case MEMCACHED_AUTH_PROBLEM: + return "FAILED TO SEND AUTHENTICATION TO SERVER"; - case MEMCACHED_AUTH_FAILURE: return "AUTHENTICATION FAILURE"; + case MEMCACHED_AUTH_FAILURE: + return "AUTHENTICATION FAILURE"; - case MEMCACHED_AUTH_CONTINUE: return "CONTINUE AUTHENTICATION"; + case MEMCACHED_AUTH_CONTINUE: + return "CONTINUE AUTHENTICATION"; - case MEMCACHED_PARSE_ERROR: return "ERROR OCCURED WHILE PARSING"; + case MEMCACHED_PARSE_ERROR: + return "ERROR OCCURED WHILE PARSING"; - case MEMCACHED_PARSE_USER_ERROR: return "USER INITIATED ERROR OCCURED WHILE PARSING"; + case MEMCACHED_PARSE_USER_ERROR: + return "USER INITIATED ERROR OCCURED WHILE PARSING"; - case MEMCACHED_DEPRECATED: return "DEPRECATED"; + case MEMCACHED_DEPRECATED: + return "DEPRECATED"; - case MEMCACHED_IN_PROGRESS: return "OPERATION IN PROCESS"; + case MEMCACHED_IN_PROGRESS: + return "OPERATION IN PROCESS"; case MEMCACHED_SERVER_TEMPORARILY_DISABLED: return "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"; - case MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE: return "SERVER FAILED TO ALLOCATE OBJECT"; + case MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE: + return "SERVER FAILED TO ALLOCATE OBJECT"; default: - case MEMCACHED_MAXIMUM_RETURN: return "INVALID memcached_return_t"; + case MEMCACHED_MAXIMUM_RETURN: + return "INVALID memcached_return_t"; } } diff --git a/src/libmemcachedprotocol/ascii_handler.c b/src/libmemcachedprotocol/ascii_handler.c index 83a71828..f5d8e22c 100644 --- a/src/libmemcachedprotocol/ascii_handler.c +++ b/src/libmemcachedprotocol/ascii_handler.c @@ -24,40 +24,74 @@ static void print_ascii_command(memcached_protocol_client_st *client) { if (client->is_verbose) { switch (client->ascii_command) { - case SET_CMD: fprintf(stderr, "%s:%d SET_CMD\n", __FILE__, __LINE__); break; + case SET_CMD: + fprintf(stderr, "%s:%d SET_CMD\n", __FILE__, __LINE__); + break; - case ADD_CMD: fprintf(stderr, "%s:%d ADD_CMD\n", __FILE__, __LINE__); break; + case ADD_CMD: + fprintf(stderr, "%s:%d ADD_CMD\n", __FILE__, __LINE__); + break; - case REPLACE_CMD: fprintf(stderr, "%s:%d REPLACE_CMD\n", __FILE__, __LINE__); break; + case REPLACE_CMD: + fprintf(stderr, "%s:%d REPLACE_CMD\n", __FILE__, __LINE__); + break; - case CAS_CMD: fprintf(stderr, "%s:%d CAS_CMD\n", __FILE__, __LINE__); break; + case CAS_CMD: + fprintf(stderr, "%s:%d CAS_CMD\n", __FILE__, __LINE__); + break; - case APPEND_CMD: fprintf(stderr, "%s:%d APPEND_CMD\n", __FILE__, __LINE__); break; + case APPEND_CMD: + fprintf(stderr, "%s:%d APPEND_CMD\n", __FILE__, __LINE__); + break; - case PREPEND_CMD: fprintf(stderr, "%s:%d PREPEND_CMD\n", __FILE__, __LINE__); break; + case PREPEND_CMD: + fprintf(stderr, "%s:%d PREPEND_CMD\n", __FILE__, __LINE__); + break; - case DELETE_CMD: fprintf(stderr, "%s:%d DELETE_CMD\n", __FILE__, __LINE__); break; + case DELETE_CMD: + fprintf(stderr, "%s:%d DELETE_CMD\n", __FILE__, __LINE__); + break; - case INCR_CMD: /* FALLTHROUGH */ fprintf(stderr, "%s:%d INCR_CMD\n", __FILE__, __LINE__); break; + case INCR_CMD: /* FALLTHROUGH */ + fprintf(stderr, "%s:%d INCR_CMD\n", __FILE__, __LINE__); + break; - case DECR_CMD: fprintf(stderr, "%s:%d DECR_CMD\n", __FILE__, __LINE__); break; + case DECR_CMD: + fprintf(stderr, "%s:%d DECR_CMD\n", __FILE__, __LINE__); + break; - case STATS_CMD: fprintf(stderr, "%s:%d STATS_CMD\n", __FILE__, __LINE__); break; + case STATS_CMD: + fprintf(stderr, "%s:%d STATS_CMD\n", __FILE__, __LINE__); + break; - case FLUSH_ALL_CMD: fprintf(stderr, "%s:%d FLUSH_ALL_CMD\n", __FILE__, __LINE__); break; + case FLUSH_ALL_CMD: + fprintf(stderr, "%s:%d FLUSH_ALL_CMD\n", __FILE__, __LINE__); + break; - case VERSION_CMD: fprintf(stderr, "%s:%d VERSION_CMD\n", __FILE__, __LINE__); break; + case VERSION_CMD: + fprintf(stderr, "%s:%d VERSION_CMD\n", __FILE__, __LINE__); + break; - case QUIT_CMD: fprintf(stderr, "%s:%d QUIT_CMD\n", __FILE__, __LINE__); break; + case QUIT_CMD: + fprintf(stderr, "%s:%d QUIT_CMD\n", __FILE__, __LINE__); + break; - case VERBOSITY_CMD: fprintf(stderr, "%s:%d VERBOSITY_CMD\n", __FILE__, __LINE__); break; + case VERBOSITY_CMD: + fprintf(stderr, "%s:%d VERBOSITY_CMD\n", __FILE__, __LINE__); + break; - case GET_CMD: fprintf(stderr, "%s:%d GET_CMD\n", __FILE__, __LINE__); break; + case GET_CMD: + fprintf(stderr, "%s:%d GET_CMD\n", __FILE__, __LINE__); + break; - case GETS_CMD: fprintf(stderr, "%s:%d GETS_CMD\n", __FILE__, __LINE__); break; + case GETS_CMD: + fprintf(stderr, "%s:%d GETS_CMD\n", __FILE__, __LINE__); + break; default: - case UNKNOWN_CMD: fprintf(stderr, "%s:%d UNKNOWN_CMD\n", __FILE__, __LINE__); break; + case UNKNOWN_CMD: + fprintf(stderr, "%s:%d UNKNOWN_CMD\n", __FILE__, __LINE__); + break; } } } @@ -639,7 +673,8 @@ static inline int process_storage_command(memcached_protocol_client_st *client, case QUIT_CMD: case VERBOSITY_CMD: case UNKNOWN_CMD: - default: abort(); /* impossible */ + default: + abort(); /* impossible */ } if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS) { @@ -807,15 +842,21 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz print_ascii_command(client); switch (client->ascii_command) { - case SET_CMD: error = process_set_command(client, tokens, ntokens, ptr, &end, *length); break; + case SET_CMD: + error = process_set_command(client, tokens, ntokens, ptr, &end, *length); + break; - case ADD_CMD: error = process_add_command(client, tokens, ntokens, ptr, &end, *length); break; + case ADD_CMD: + error = process_add_command(client, tokens, ntokens, ptr, &end, *length); + break; case REPLACE_CMD: error = process_replace_command(client, tokens, ntokens, ptr, &end, *length); break; - case CAS_CMD: error = process_cas_command(client, tokens, ntokens, ptr, &end, *length); break; + case CAS_CMD: + error = process_cas_command(client, tokens, ntokens, ptr, &end, *length); + break; case APPEND_CMD: error = process_append_command(client, tokens, ntokens, ptr, &end, *length); @@ -825,10 +866,14 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz error = process_prepend_command(client, tokens, ntokens, ptr, &end, *length); break; - case DELETE_CMD: process_delete(client, tokens, ntokens); break; + case DELETE_CMD: + process_delete(client, tokens, ntokens); + break; case INCR_CMD: /* FALLTHROUGH */ - case DECR_CMD: process_arithmetic(client, tokens, ntokens); break; + case DECR_CMD: + process_arithmetic(client, tokens, ntokens); + break; case STATS_CMD: if (client->mute) { @@ -839,7 +884,9 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz } break; - case FLUSH_ALL_CMD: process_flush(client, tokens, ntokens); break; + case FLUSH_ALL_CMD: + process_flush(client, tokens, ntokens); + break; case VERSION_CMD: if (client->mute) { @@ -869,7 +916,9 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz } break; - case UNKNOWN_CMD: send_command_usage(client); break; + case UNKNOWN_CMD: + send_command_usage(client); + break; case GET_CMD: case GETS_CMD: diff --git a/src/libmemcachedprotocol/binary_handler.c b/src/libmemcachedprotocol/binary_handler.c index 51fa60be..c7a76b3f 100644 --- a/src/libmemcachedprotocol/binary_handler.c +++ b/src/libmemcachedprotocol/binary_handler.c @@ -265,7 +265,8 @@ static void print_cmd(protocol_binary_command cmd) { case PROTOCOL_BINARY_CMD_SCRUB: fprintf(stderr, "%s:%d PROTOCOL_BINARY_CMD_SCRUB\n", __FILE__, __LINE__); return; - default: abort(); + default: + abort(); } } diff --git a/src/libmemcachedprotocol/pedantic.c b/src/libmemcachedprotocol/pedantic.c index 85624f24..b6e7a002 100644 --- a/src/libmemcachedprotocol/pedantic.c +++ b/src/libmemcachedprotocol/pedantic.c @@ -139,7 +139,8 @@ bool memcached_binary_protocol_pedantic_check_response( case PROTOCOL_BINARY_CMD_SETQ: /* Quiet command shouldn't return on success */ return false; - default: break; + default: + break; } switch (opcode) { diff --git a/src/libmemcachedutil/pool.cc b/src/libmemcachedutil/pool.cc index 44852651..718be8b2 100644 --- a/src/libmemcachedutil/pool.cc +++ b/src/libmemcachedutil/pool.cc @@ -44,7 +44,9 @@ struct memcached_pool_st { _timeout.tv_nsec = 0; } - const struct timespec &timeout() const { return _timeout; } + const struct timespec &timeout() const { + return _timeout; + } bool release(memcached_st *, memcached_return_t &rc); @@ -74,13 +76,17 @@ struct memcached_pool_st { } } - void increment_version() { ++master->configure.version; } + void increment_version() { + ++master->configure.version; + } bool compare_version(const memcached_st *arg) const { return (arg->configure.version == version()); } - int32_t version() const { return master->configure.version; } + int32_t version() const { + return master->configure.version; + } }; /**