printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name,
long_options[x].has_arg ? '=' : ' ');
- if ((help_message = (char *) ms_lookup_help(long_options[x].val)) != NULL) {
+ if ((help_message = (char *) ms_lookup_help(long_options[x].val))) {
printf(" %s\n", help_message);
}
}
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"
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"
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.";
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 */
ret *= 60;
/* fall through */
case 's':
- case 'S': break;
+ case 'S':
+ break;
- default: ret = -1; break;
+ default:
+ ret = -1;
+ break;
} /* switch */
return ret;
optarg[strlen(optarg) - 1] = '\0';
errno = 0;
ret = strtoll(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "strtoll(optarg,..): %s\n", strerror(errno));
exit(1);
}
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;
!= -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;
ms_setting.nconns = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nconns <= 0 || errno != 0) {
+ if (ms_setting.nconns <= 0 || errno) {
fprintf(stderr, "Concurrency must be greater than 0.:-)\n");
exit(1);
}
case OPT_EXECUTE_NUMBER: /* --execute_number or -x */
errno = 0;
ms_setting.exec_num = (int) strtol(optarg, (char **) NULL, 10);
- if (ms_setting.exec_num <= 0 || errno != 0) {
+ if (ms_setting.exec_num <= 0 || errno) {
fprintf(stderr, "Execute number must be greater than 0.:-)\n");
exit(1);
}
case OPT_THREAD_NUMBER: /* --threads or -T */
errno = 0;
ms_setting.nthreads = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nthreads <= 0 || errno != 0) {
+ if (ms_setting.nthreads <= 0 || errno) {
fprintf(stderr, "Threads number must be greater than 0.:-)\n");
exit(1);
}
case OPT_FIXED_LTH: /* --fixed_size or -X */
errno = 0;
ms_setting.fixed_value_size = (size_t) strtoull(optarg, (char **) NULL, 10);
- if ((ms_setting.fixed_value_size <= 0 || errno != 0)
+ if ((ms_setting.fixed_value_size <= 0 || errno)
|| (ms_setting.fixed_value_size > MAX_VALUE_SIZE))
{
fprintf(stderr, "Value size must be between 0 and 1M.:-)\n");
case OPT_GETS_DIVISION: /* --division or -d */
errno = 0;
ms_setting.mult_key_num = (int) strtol(optarg, (char **) NULL, 10);
- if (ms_setting.mult_key_num <= 0 || errno != 0) {
+ if (ms_setting.mult_key_num <= 0 || errno) {
fprintf(stderr, "Multi-get key number must be greater than 0.:-)\n");
exit(1);
}
}
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();
}
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);
case OPT_SOCK_PER_CONN: /* --conn_sock or -n */
errno = 0;
ms_setting.sock_per_conn = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.sock_per_conn <= 0 || errno != 0) {
+ if (ms_setting.sock_per_conn <= 0 || errno) {
fprintf(stderr,
"Number of socks of each concurrency "
"must be greater than 0.:-)\n");
}
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();
case OPT_REP_WRITE_SRV: /* --rep_write or -p */
errno = 0;
ms_setting.rep_write_srv = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.rep_write_srv <= 0 || errno != 0) {
+ if (ms_setting.rep_write_srv <= 0 || errno) {
fprintf(stderr,
"Number of replication writing server must be greater "
"than 0.:-)\n");
/* getopt_long already printed an error message. */
exit(1);
- default: abort();
+ default:
+ abort();
} /* switch */
}
} /* ms_options_parse */
}
}
- if (ms_setting.nconns % (uint32_t) ms_setting.nthreads != 0) {
+ if (ms_setting.nconns % (uint32_t) ms_setting.nthreads) {
fprintf(stderr, "Concurrency must be the multiples of threads count.\n");
return -1;
}
- if (ms_setting.win_size % UNIT_ITEMS_COUNT != 0) {
+ if (ms_setting.win_size % UNIT_ITEMS_COUNT) {
fprintf(stderr, "Window size must be the multiples of 1024.\n\n");
return -1;
}