From: Daniel Axtens <dja@axtens.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kbuild test robot <lkp@intel.com>,
kbuild-all@lists.01.org, Johannes Weiner <hannes@cmpxchg.org>,
Dmitry Vyukov <dvyukov@google.com>,
Linux Memory Management List <linux-mm@kvack.org>,
linux-scsi@vger.kernel.org
Subject: Re: [hnaz-linux-mm:master 156/523] include/linux/string.h:307:9: note: in expansion of macro '__underlying_strncpy'
Date: Wed, 20 May 2020 13:57:16 +1000 [thread overview]
Message-ID: <875zcri7hf.fsf@dja-thinkpad.axtens.net> (raw)
In-Reply-To: <20200519184847.5affb9238b7358ac0d18c98e@linux-foundation.org>
> inqdata[0] = TYPE_PROCESSOR;
> /* Periph Qualifier & Periph Dev Type */
> inqdata[1] = 0;
> /* rem media bit & Dev Type Modifier */
> inqdata[2] = 0;
> /* ISO, ECMA, & ANSI versions */
> inqdata[4] = 31;
> /* length of additional data */
> strncpy(&inqdata[8], "Areca ", 8);
> /* Vendor Identification */
>>>> strncpy(&inqdata[16], "RAID controller ", 16);
> /* Product Identification */
> strncpy(&inqdata[32], "R001", 4); /* Product Revision */
> That strncpy() will indeed fail to copy the trailing null, but it looks
> like that null isn't appropriate in the inquiry data.
>
> So I suspect this is a valid usage of strncpy() and the checking is
> just too strict.
>
> otoh if this is the only place where we hit this issue then perhaps we
> can switch to memcpy() and get on with life ;)
Hmm, yes, I think you're right and gcc is being a bit ambitious here -
although I can understand the warning given that the behaviour relied
upon here is rarely going to be what the developer intendend!
We could build the file with -Wno-stringop-truncation, but I do wonder
if memcpy might make the semantics more obvious...
Regards,
Daniel
next prev parent reply other threads:[~2020-05-20 3:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 9:23 kbuild test robot
2020-05-19 14:42 ` Daniel Axtens
2020-05-20 1:48 ` Andrew Morton
2020-05-20 2:08 ` Martin K. Petersen
2020-05-20 3:57 ` Daniel Axtens [this message]
2020-05-19 14:42 ` Daniel Axtens
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=875zcri7hf.fsf@dja-thinkpad.axtens.net \
--to=dja@axtens.net \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=hannes@cmpxchg.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-mm@kvack.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lkp@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox