]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
MAINT: intel-nvme: Fix CI build stringop-overflow warning for issue #1246
authorTokunori Ikegami <ikegami.t@gmail.com>
Wed, 8 Dec 2021 16:43:45 +0000 (01:43 +0900)
committerTokunori Ikegami <ikegami.t@gmail.com>
Wed, 8 Dec 2021 16:43:45 +0000 (01:43 +0900)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/intel/intel-nvme.c

index 06f909ea9e9c9c217d8e618a88609cc1fef5a11f..0ec83047ffd3eb7af3357947c9f7aee94df8e38f 100644 (file)
@@ -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)