From: Marek Schimara Date: Wed, 15 Jun 2016 12:52:33 +0000 (+0200) Subject: src/rrd_graph.c: fix Coverity CID#32414 Array compared against 0 X-Git-Tag: v1.7.0~42^2~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29514a6866de3f6d74aa9956ae8d2efeac68829b;p=thirdparty%2Frrdtool-1.x.git src/rrd_graph.c: fix Coverity CID#32414 Array compared against 0 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. --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index ba34e18a..89024adf 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -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;