]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_graph.c: fix Coverity CID#32414 Array compared against 0
authorMarek Schimara <Marek.Schimara@bull.net>
Wed, 15 Jun 2016 12:52:33 +0000 (14:52 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:33 +0000 (16:32 +0200)
        CWE-398 / https://cwe.mitre.org/data/definitions/398.html

        'im' declared as:      image_desc_t *im
        im->gdes[i] is:        graph_desc_t *gdes; /* points to an array of graph elements */
        im->gdes[i].format is: char format[FMT_LEG_LEN + 5];  /* format for PRINT AND GPRINT */

        Comparing a stack variable to NULL doesn't make sense.

src/rrd_graph.c

index ba34e18a08c122e5099683692fdd217a15b1694f..89024adf81db423cf38e623c9a3534bbcae79689 100644 (file)
@@ -1913,7 +1913,7 @@ int print_calc(
                             prline.u_str = sprintf_alloc("%.0f", printval);
                         } else {
                             const char *fmt;
-                            if (im->gdes[i].format == NULL || im->gdes[i].format[0] == '\0')
+                            if (im->gdes[i].format[0] == '\0')
                                 fmt = default_timestamp_fmt;
                             else
                                 fmt = im->gdes[i].format;
@@ -1931,7 +1931,7 @@ int print_calc(
                             prline.u_str = sprintf_alloc("%f", printval);
                         } else {
                             const char *fmt;
-                            if (im->gdes[i].format == NULL || im->gdes[i].format[0] == '\0')
+                            if (im->gdes[i].format[0] == '\0')
                                 fmt = default_duration_fmt;
                             else
                                 fmt = im->gdes[i].format;
@@ -1980,7 +1980,7 @@ int print_calc(
                             snprintf(im->gdes[i].legend, FMT_LEG_LEN, "%.0f", printval);
                         } else {
                             const char *fmt;
-                            if (im->gdes[i].format == NULL || im->gdes[i].format[0] == '\0')
+                            if (im->gdes[i].format[0] == '\0')
                                 fmt = default_timestamp_fmt;
                             else
                                 fmt = im->gdes[i].format;
@@ -1993,7 +1993,7 @@ int print_calc(
                             snprintf(im->gdes[i].legend, FMT_LEG_LEN, "%f", printval);
                         } else {
                             const char *fmt;
-                            if (im->gdes[i].format == NULL || im->gdes[i].format[0] == '\0')
+                            if (im->gdes[i].format[0] == '\0')
                                 fmt = default_duration_fmt;
                             else
                                 fmt = im->gdes[i].format;