]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
fix style 716/head
authorMarek Schimara <Marek.Schimara@bull.net>
Mon, 27 Jun 2016 09:04:37 +0000 (11:04 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Mon, 27 Jun 2016 12:44:46 +0000 (14:44 +0200)
   src/rrd_cgi.c
   src/rrd_create.c
   src/rrd_daemon.c
   src/rrd_dump.c
   src/rrd_fetch.c
   src/rrd_first.c
   src/rrd_flushcached.c
   src/rrd_graph_helper.c
   src/rrd_info.c
   src/rrd_last.c
   src/rrd_lastupdate.c
   src/rrd_update.c

12 files changed:
src/rrd_cgi.c
src/rrd_create.c
src/rrd_daemon.c
src/rrd_dump.c
src/rrd_fetch.c
src/rrd_first.c
src/rrd_flushcached.c
src/rrd_graph_helper.c
src/rrd_info.c
src/rrd_last.c
src/rrd_lastupdate.c
src/rrd_update.c

index d1ebbb644c9c5c902eb0ab54951c3b15aa41b8d9..12e5eecf7cf8e62c43648130b09698561e255a13 100644 (file)
@@ -1407,7 +1407,7 @@ s_var   **rrdcgiReadVariables(
             if ((line = (char *) malloc(length + 2)) == NULL)
                 return NULL;
             if (fgets(line, length + 1, stdin) == NULL) {
-               free(line);
+                free(line);
                 return NULL;
             }
         } else
@@ -1435,8 +1435,9 @@ s_var   **rrdcgiReadVariables(
                     strncat(line, tmp, tmplen);
                 } else {
                     /* clean-up the storage allocated in previous iteration */
-                    if (line)
+                    if (line) {
                         free(line);
+                    }
 
                     if ((line = strdup(tmp)) == NULL)
                         return NULL;
@@ -1444,8 +1445,9 @@ s_var   **rrdcgiReadVariables(
             }
             memset(tmp, 0, sizeof(tmp));
         }
-        if (!line)
+        if (!line) {
             return NULL;
+        }
         if (line[strlen(line) - 1] == '&')
             line[strlen(line) - 1] = '\0';
     }
@@ -1577,8 +1579,9 @@ s_cgi    *rrdcgiInit(
     s_cgi    *res;
     s_var   **vars;
 
-    if ((res = (s_cgi *) malloc(sizeof(s_cgi))) == NULL)
+    if ((res = (s_cgi *) malloc(sizeof(s_cgi))) == NULL) {
         return NULL;
+    }
 
     vars = rrdcgiReadVariables();
 
index 1c11ac798ceafed68b33273c6f352420c436584b..c189855bd568086cb5d4699fa5240fea7b227414 100644 (file)
@@ -238,7 +238,9 @@ done:
         free(template);
         template = NULL;
     }
-    if (opt_daemon) free(opt_daemon);
+    if (opt_daemon != NULL) {
+       free(opt_daemon);
+    }
     return rc;
 }
 
index 87eb0520a84820908d48c071cd2a8760ea0d8953..115ebb418ad213084d17472dcd2a3b239264aeee 100644 (file)
@@ -2373,8 +2373,9 @@ done:
   free(file);
   free(sources);
   free(file_copy);
-  if (dir)
+  if (dir) {
     free(dir);
+  }
   free(dir2);
   return rc;
 } /* }}} static int handle_request_create  */
index 6aaa0962f81fd1b467c556da233f82a3b51b1abc..957ad858db775d4d6e4965c238074b6acee268f7 100644 (file)
@@ -540,8 +540,9 @@ int rrd_dump(
     while ((opt = optparse_long(&options, longopts, NULL)) != -1) {
         switch (opt) {
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                     free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -569,7 +570,9 @@ int rrd_dump(
                           "[--no-header|-n]\n"
                           "[--daemon|-d address]\n"
                           "file.rrd [file.xml]", options.argv[0]);
-            if (opt_daemon) free(opt_daemon);
+            if (opt_daemon != NULL) {
+               free(opt_daemon);
+            }
             return (-1);
             break;
         }
@@ -580,12 +583,16 @@ int rrd_dump(
                       "[--no-header|-n]\n"
                       "[--daemon|-d address]\n"
                        "file.rrd [file.xml]", options.argv[0]);
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return (-1);
     }
 
     rc = rrdc_flush_if_daemon(opt_daemon, options.argv[options.optind]);
-    if (opt_daemon) free(opt_daemon);
+    if (opt_daemon != NULL) {
+       free(opt_daemon);
+    }
     if (rc) return (rc);
 
     if ((options.argc - options.optind) == 2) {
index 0256af8e360eb2bb8d76906ca9f8467c55d40d34..9466d615b31294dc14e6660c94e94f08f8053f99 100644 (file)
@@ -101,14 +101,18 @@ int rrd_fetch(
         case 's':
             if ((parsetime_error = rrd_parsetime(options.optarg, &start_tv))) {
                 rrd_set_error("start time: %s", parsetime_error);
-                if (opt_daemon) free(opt_daemon);
+                if (opt_daemon != NULL) {
+                    free(opt_daemon);
+                }
                 return -1;
             }
             break;
         case 'e':
             if ((parsetime_error = rrd_parsetime(options.optarg, &end_tv))) {
                 rrd_set_error("end time: %s", parsetime_error);
-                if (opt_daemon) free(opt_daemon);
+                if (opt_daemon != NULL) {
+                    free(opt_daemon);
+                }
                 return -1;
             }
             break;
@@ -118,14 +122,17 @@ int rrd_fetch(
         case 'r':
             if ((parsetime_error = rrd_scaled_duration(options.optarg, 1, &step_tmp))) {
                 rrd_set_error("resolution: %s", parsetime_error);
-                if (opt_daemon) free(opt_daemon);
+                if (opt_daemon != NULL) {
+                    free(opt_daemon);
+                }
                 return -1;
             }
             break;
 
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                 free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -136,20 +143,26 @@ int rrd_fetch(
 
         case '?':
             rrd_set_error("%s", options.errmsg);
-            if (opt_daemon) free(opt_daemon);
+            if (opt_daemon != NULL) {
+               free(opt_daemon);
+            }
             return -1;
         }
     }
 
 
     if (rrd_proc_start_end(&start_tv, &end_tv, &start_tmp, &end_tmp) == -1) {
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return -1;
     }
 
     if (start_tmp < 3600 * 24 * 365 * 10) {
         rrd_set_error("the first entry to fetch should be after 1980");
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return (-1);
     }
 
@@ -162,7 +175,9 @@ int rrd_fetch(
     if (end_tmp < start_tmp) {
         rrd_set_error("start (%ld) should be less than end (%ld)", start_tmp,
                       end_tmp);
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return (-1);
     }
 
@@ -172,7 +187,9 @@ int rrd_fetch(
 
     if (options.optind + 1 >= options.argc) {
         rrd_set_error("Usage: rrdtool %s <file> <CF> [options]", options.argv[0]);
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return -1;
     }
 
@@ -187,7 +204,9 @@ int rrd_fetch(
            status = rrd_fetch_r(options.argv[options.optind],
                            cf, start, end, step, ds_cnt, ds_namv, data);
 
-    if (opt_daemon) free(opt_daemon);
+    if (opt_daemon != NULL) {
+       free(opt_daemon);
+    }
     if (status != 0)
         return (-1);
     return (0);
index 2c68f4796489207df0d5097df906895baf43613f..7beb5842215c4ac64b30177643aaa3a5ff382f1a 100644 (file)
@@ -33,13 +33,16 @@ time_t rrd_first(
             target_rraindex = strtol(options.optarg, &endptr, 0);
             if (target_rraindex < 0) {
                 rrd_set_error("invalid rraindex number");
-                if (opt_daemon != NULL) free (opt_daemon);
+                if (opt_daemon != NULL) {
+                    free (opt_daemon);
+                }
                 return (-1);
             }
             break;
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                     free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -49,7 +52,9 @@ time_t rrd_first(
             break;
         case '?':
             rrd_set_error("%s", options.errmsg);
-            if (opt_daemon != NULL) free (opt_daemon);
+            if (opt_daemon != NULL) {
+               free (opt_daemon);
+            }
             return -1;
         }
     }
@@ -63,10 +68,14 @@ time_t rrd_first(
 
     rrdc_connect (opt_daemon);
     if (rrdc_is_connected (opt_daemon)) {
-      if (opt_daemon != NULL) free (opt_daemon);
+      if (opt_daemon != NULL) {
+        free (opt_daemon);
+      }
       return rrdc_first(options.argv[options.optind], target_rraindex);
     } else {
-      if (opt_daemon != NULL) free (opt_daemon);
+      if (opt_daemon != NULL) {
+       free (opt_daemon);
+      }
       return rrd_first_r(options.argv[options.optind], target_rraindex);
        }
 }
index 515b84bdcd4040ecace2b0d510da34b05a054db8..5de127876bcc1ed1c5b91af489943f7b59bcca62 100644 (file)
@@ -51,7 +51,9 @@ int rrd_flushcached (int argc, char **argv)
 
             case '?':
                 rrd_set_error("%s", options.errmsg);
-                if (opt_daemon) free(opt_daemon);
+                if (opt_daemon != NULL) {
+                    free(opt_daemon);
+                }
                 return -1;
         }
     } /* while (opt!=-1) */
@@ -60,7 +62,9 @@ int rrd_flushcached (int argc, char **argv)
     {
         rrd_set_error("Usage: rrdtool %s [--daemon|-d <addr>] <file> [<file> ...]",
                       options.argv[0]);
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return -1;
     }
 
index 7b2a796c4ca937f7b262bc3721fd50e439471e35..4afd51d4bec5bcdc411160918606f34ca7c76611 100644 (file)
@@ -140,8 +140,9 @@ int getMappedKeyValueArgument(const char* key,int flag, parsedargs_t* pa,
 }
 
 int getLong(const char* v,long *val,char**extra,int base) {
-  if (extra == NULL)
+  if (extra == NULL) {
     return 0;
+  }
 
   /* try to execute the parser */
   /* NOTE that this may be a bit different from the original parser */
index da60ef32eaf9f66db7480502aa99589819699f85..c1a08806dbc1f603c7c01bbfc1f6671e9d30161f 100644 (file)
@@ -104,8 +104,9 @@ rrd_info_t *rrd_info(
     while ((opt = optparse_long(&options, longopts, NULL)) != -1) {
         switch (opt) {
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                 free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -120,7 +121,9 @@ rrd_info_t *rrd_info(
 
         case '?':
             rrd_set_error("%s", options.errmsg);
-            if (opt_daemon) free (opt_daemon);
+            if (opt_daemon != NULL) {
+               free (opt_daemon);
+            }
             return NULL;
         }
     } /* while (opt != -1) */
@@ -128,14 +131,18 @@ rrd_info_t *rrd_info(
     if (options.argc - options.optind != 1) {
         rrd_set_error ("Usage: rrdtool %s [--daemon |-d <addr> [--noflush|-F]] <file>",
                 options.argv[0]);
-        if (opt_daemon) free (opt_daemon);
+        if (opt_daemon != NULL) {
+            free (opt_daemon);
+        }
         return NULL;
     }
 
     if (flushfirst) {
         status = rrdc_flush_if_daemon(opt_daemon, options.argv[options.optind]);
         if (status) {
-            if (opt_daemon) free (opt_daemon);
+            if (opt_daemon != NULL) {
+               free (opt_daemon);
+            }
             return (NULL);
         }
     }
@@ -146,7 +153,9 @@ rrd_info_t *rrd_info(
     else
         info = rrd_info_r(options.argv[options.optind]);
 
-    if (opt_daemon) free(opt_daemon);
+    if (opt_daemon != NULL) {
+       free(opt_daemon);
+    }
     return (info);
 } /* rrd_info_t *rrd_info */
 
index 85a725d5c53b2177e22f5a8f89ea66ff89255489..d5267684a886eb5971fec4527d7b0ca9dde882ff 100644 (file)
@@ -26,8 +26,9 @@ time_t rrd_last(
     while ((opt = optparse_long(&options, longopts, NULL)) != -1) {
         switch (opt) {
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                     free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -38,7 +39,9 @@ time_t rrd_last(
 
         case '?':
             rrd_set_error("%s", options.errmsg);
-            if (opt_daemon) free (opt_daemon);
+            if (opt_daemon != NULL) {
+               free (opt_daemon);
+            }
             return -1;
         }
     }                   /* while (opt) */
@@ -46,7 +49,9 @@ time_t rrd_last(
     if ((options.argc - options.optind) != 1) {
         rrd_set_error ("Usage: rrdtool %s [--daemon|-d <addr>] <file>",
                 options.argv[0]);
-        if (opt_daemon) free (opt_daemon);
+        if (opt_daemon != NULL) {
+            free (opt_daemon);
+        }
         return -1;
     }
 
@@ -57,7 +62,9 @@ time_t rrd_last(
     else
         lastupdate = rrd_last_r(options.argv[options.optind]);
 
-    if (opt_daemon) free(opt_daemon);
+    if (opt_daemon != NULL) {
+       free(opt_daemon);
+    }
     return (lastupdate);
 }
 
index ddde70a69c68e240843dc85055219161970e888b..5f7aefcc41dc9217c540ed2b59a6af3a14c5bc65 100644 (file)
@@ -29,8 +29,9 @@ int rrd_lastupdate (int argc, char **argv)
     while ((opt = optparse_long(&options, longopts, NULL)) != -1) {
         switch (opt) {
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                     free (opt_daemon);
+            }
             opt_daemon = strdup(options.optarg);
             if (opt_daemon == NULL)
             {
@@ -41,7 +42,9 @@ int rrd_lastupdate (int argc, char **argv)
 
         case '?':
             rrd_set_error("%s", options.errmsg);
-            if (opt_daemon) free(opt_daemon);
+            if (opt_daemon != NULL) {
+               free(opt_daemon);
+            }
             return -1;
         }
     }                   /* while (opt!=-1) */
@@ -49,12 +52,16 @@ int rrd_lastupdate (int argc, char **argv)
     if ((options.argc - options.optind) != 1) {
         rrd_set_error ("Usage: rrdtool %s [--daemon|-d <addr>] <file>",
                 options.argv[0]);
-        if (opt_daemon) free(opt_daemon);
+        if (opt_daemon != NULL) {
+            free(opt_daemon);
+        }
         return (-1);
     }
 
     status = rrdc_flush_if_daemon(opt_daemon, options.argv[options.optind]);
-    if (opt_daemon) free (opt_daemon);
+    if (opt_daemon != NULL) {
+       free (opt_daemon);
+    }
     if (status) return (-1);
 
     status = rrd_lastupdate_r(options.argv[options.optind],
index 0fd85273f78117dee5701c337dc58236764bb97a..d4c696c501b2729bb145233ef5ce95c87d83a58f 100644 (file)
@@ -692,7 +692,9 @@ int rrd_update(
     while ((opt = optparse_long(&options,longopts,NULL)) != -1) {
         switch (opt) {
         case 't':
-            if (tmplt) free(tmplt);
+            if (tmplt != NULL) {
+               free(tmplt);
+            }
             tmplt = strdup(options.optarg);
             break;
 
@@ -701,8 +703,9 @@ int rrd_update(
             break;
 
         case 'd':
-            if (opt_daemon != NULL)
+            if (opt_daemon != NULL) {
                 free (opt_daemon);
+            }
             opt_daemon = strdup (options.optarg);
             if (opt_daemon == NULL)
             {