From: Damien Le Moal Date: Mon, 17 Dec 2018 05:51:08 +0000 (+0900) Subject: blktests: Fix compilation warning X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2ddd30d4a9a47003efc3ffb5edf8130691edc66c;p=users%2Fsagi%2Fblktests.git blktests: Fix compilation warning Fix strncpy length to "sizeof(buf) - 1" to avoid the compiler warning: cc -O2 -Wall -Wshadow -o sg/syzkaller1 sg/syzkaller1.c sg/syzkaller1.c: In function ‘syz_open_dev.constprop’: sg/syzkaller1.c:204:16: warning: ‘strncpy’ specified bound 1024 equals destination size [-Wstringop-truncation] NONFAILING(strncpy(buf, (char*)a0, sizeof(buf))); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sg/syzkaller1.c:143:7: note: in definition of macro ‘NONFAILING’ __VA_ARGS__; \ ^~~~~~~~~~~ Since the last character of buf is forced set to 0, there is no functional change introduced by this patch. Signed-off-by: Damien Le Moal --- diff --git a/src/sg/syzkaller1.c b/src/sg/syzkaller1.c index 60bd9a6..743859a 100644 --- a/src/sg/syzkaller1.c +++ b/src/sg/syzkaller1.c @@ -201,7 +201,7 @@ static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) } else { char buf[1024]; char* hash; - NONFAILING(strncpy(buf, (char*)a0, sizeof(buf))); + NONFAILING(strncpy(buf, (char*)a0, sizeof(buf) - 1)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10);