All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-block@vger.kernel.org, Omar Sandoval <osandov@fb.com>
Cc: Omar Sandoval <osandov@osandov.com>
Subject: [PATCH blktests] blktests: Fix compilation warning
Date: Mon, 17 Dec 2018 14:51:08 +0900	[thread overview]
Message-ID: <20181217055108.11461-1-damien.lemoal@wdc.com> (raw)

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


             reply	other threads:[~2018-12-17  5:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-17  5:51 Damien Le Moal [this message]
2018-12-18 21:57 ` [PATCH blktests] blktests: Fix compilation warning Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181217055108.11461-1-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=osandov@osandov.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.