simplify falsy comparisons
[m6w6/libmemcached] / src / bin / memaslap.c
index a5481bb851546ff859d3ab46d0e36df8b3d3bc82..6dd6ee62e5b8ad527a07d006a77ae1dac7091342 100644 (file)
@@ -117,7 +117,7 @@ static void ms_help_command(const char *command_name, const char *description) {
     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);
     }
   }
@@ -323,7 +323,7 @@ static int64_t ms_parse_size() {
   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);
   }
@@ -383,7 +383,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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);
       }
@@ -392,7 +392,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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);
       }
@@ -401,7 +401,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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);
       }
@@ -410,7 +410,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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");
@@ -431,7 +431,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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);
       }
@@ -513,7 +513,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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");
@@ -550,7 +550,7 @@ static void ms_options_parse(int argc, char *argv[]) {
     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");
@@ -580,12 +580,12 @@ static int ms_check_para() {
     }
   }
 
-  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;
   }