From: Sebastien GODARD Date: Fri, 13 Jul 2018 08:37:44 +0000 (+0200) Subject: Remove some "may be used uninitialized" warnings X-Git-Tag: v12.0.0~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c46cadf65a451298e9793ef6d53769d6fcd45ab8;p=sysstat Remove some "may be used uninitialized" warnings 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 --- diff --git a/svg_stats.c b/svg_stats.c index 97bc55b..5eba539 100644 --- a/svg_stats.c +++ b/svg_stats.c @@ -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);