* [PATCH blktests] blktests: Fix compilation warning
@ 2018-12-17 5:51 Damien Le Moal
2018-12-18 21:57 ` Omar Sandoval
0 siblings, 1 reply; 2+ messages in thread
From: Damien Le Moal @ 2018-12-17 5:51 UTC (permalink / raw)
To: linux-block, Omar Sandoval; +Cc: Omar Sandoval
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 <damien.lemoal@wdc.com>
---
src/sg/syzkaller1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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);
--
2.19.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH blktests] blktests: Fix compilation warning
2018-12-17 5:51 [PATCH blktests] blktests: Fix compilation warning Damien Le Moal
@ 2018-12-18 21:57 ` Omar Sandoval
0 siblings, 0 replies; 2+ messages in thread
From: Omar Sandoval @ 2018-12-18 21:57 UTC (permalink / raw)
To: Damien Le Moal; +Cc: linux-block, Omar Sandoval
On Mon, Dec 17, 2018 at 02:51:08PM +0900, Damien Le Moal wrote:
> 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 <damien.lemoal@wdc.com>
Applied, thanks, Damien.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-18 21:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17 5:51 [PATCH blktests] blktests: Fix compilation warning Damien Le Moal
2018-12-18 21:57 ` Omar Sandoval
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox