]> granicus.if.org Git - sysstat/commitdiff
Remove some "may be used uninitialized" warnings
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 13 Jul 2018 08:37:44 +0000 (10:37 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 13 Jul 2018 08:37:44 +0000 (10:37 +0200)
Explicitly set "item_name" variable before using it to avoid some
warnings by the compiler, e.g.:

svg_stats.c: In function ‘svg_print_net_dev_stats’:
svg_stats.c:2409:5: warning: ‘item_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     strncpy(item_name, sndc->interface, CHUNKSIZE);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
svg_stats.c

index 97bc55be0821238f4aaa8f70b0a1f406e48fdee9..5eba53998a803b47dec5e16c12160f5990e5eb45 100644 (file)
@@ -2404,6 +2404,7 @@ __print_funct_t svg_print_net_dev_stats(struct activity *a, int curr, int action
                        }
                        *unregistered = FALSE;
 
+                       item_name = *(out + pos + 8);
                        if (!item_name[0]) {
                                /* Save network interface name (if not already done) */
                                strncpy(item_name, sndc->interface, CHUNKSIZE);
@@ -2620,6 +2621,7 @@ __print_funct_t svg_print_net_edev_stats(struct activity *a, int curr, int actio
                        }
                        *unregistered = FALSE;
 
+                       item_name = *(out + pos + 9);
                        if (!item_name[0]) {
                                /* Save network interface name (if not already done) */
                                strncpy(item_name, snedc->interface, CHUNKSIZE);
@@ -4672,7 +4674,7 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       char *item_name = NULL;
+       char *item_name;
        double tval;
        int i, k, pos, restart;
 
@@ -4719,13 +4721,13 @@ __print_funct_t svg_print_filesystem_stats(struct activity *a, int curr, int act
                                        /* No free graph entry: Extend all buffers */
                                        reallocate_all_graph_lines(9 * svg_p->nr_max,
                                                                   &out, &outsize, &spmin, &spmax);
-                                       item_name = *(out + k * 9 + 7);
                                        svg_p->nr_max *= 2;
                                }
                        }
 
                        pos = k * 9;
 
+                       item_name = *(out + pos + 7);
                        if (!item_name[0]) {
                                /* Save filesystem name and mount point (if not already done) */
                                strncpy(item_name, sfc->fs_name, CHUNKSIZE);