From: Bart Van Assche Date: Tue, 18 Jun 2019 20:16:56 +0000 (-0700) Subject: Avoid using arrays with a variable length X-Git-Tag: v1.9~40^2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=df62ed9add9997514b9a503529ad974edccc51ed;p=users%2Fsagi%2Fnvme-cli.git Avoid using arrays with a variable length Since variable length arrays result in suboptimal code, avoid using variable length arrays. Cc: Patrick McCormick Signed-off-by: Bart Van Assche --- diff --git a/nvme-print.c b/nvme-print.c index ea8f7207..94222a3b 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -41,8 +42,9 @@ static long double int128_to_double(__u8 *data) void d(unsigned char *buf, int len, int width, int group) { int i, offset = 0, line_done = 0; - char ascii[width + 1]; + char ascii[32 + 1]; + assert(width < sizeof(ascii)); printf(" "); for (i = 0; i <= 15; i++) printf("%3x", i);