From: Tokunori Ikegami Date: Wed, 8 Dec 2021 16:43:45 +0000 (+0900) Subject: MAINT: intel-nvme: Fix CI build stringop-overflow warning for issue #1246 X-Git-Tag: v2.0-rc0~34^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dc17d49af486320de1d3fa6a0522ed3a10c002cb;p=users%2Fsagi%2Fnvme-cli.git MAINT: intel-nvme: Fix CI build stringop-overflow warning for issue #1246 Signed-off-by: Tokunori Ikegami --- diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 06f909ea..0ec83047 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -560,13 +560,15 @@ enum inf_bound_type { * either of "-INF" or "+INF", respectively. */ static void set_unit_string(char *buffer, __u32 microseconds, - enum FormatUnit unit, enum inf_bound_type bound_type) + enum FormatUnit unit, + enum inf_bound_type bound_type) { + char *string; + if (bound_type != NOINF) { - snprintf(buffer, 5, "%s", bound_type ? "+INF" : "-INF"); + snprintf(buffer, BUFSIZE, "%s", bound_type ? "+INF" : "-INF"); return; } - char *string; switch (unit) { case US: @@ -582,8 +584,9 @@ static void set_unit_string(char *buffer, __u32 microseconds, string = "_s"; break; } - snprintf(buffer, 11, "%4.2f%s", - convert_seconds(microseconds), string); + + snprintf(buffer, BUFSIZE, "%4.2f%s", convert_seconds(microseconds), + string); } static void init_buffer(char *buffer, size_t size)