From: Heiko Carstens <hca@linux.ibm.com>
To: David Laight <David.Laight@aculab.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: Re: [PATCH v1 1/1] s390: Use string_upper() instead of open coded variant
Date: Tue, 12 Oct 2021 11:12:13 +0200 [thread overview]
Message-ID: <YWVRbQrDk7jtYApD@osiris> (raw)
In-Reply-To: <985bbceb3ee046bbbee6199efcf7c90c@AcuMS.aculab.com>
On Tue, Oct 12, 2021 at 08:04:58AM +0000, David Laight wrote:
> From: Heiko Carstens
> > Sent: 11 October 2021 11:10
> >
> > On Mon, Oct 11, 2021 at 08:21:15AM +0000, David Laight wrote:
> > > ...
> > > > > + * This snprintf() call does two things:
> > > > > + * - makes a NUL-terminated copy of the input string
> > > > > + * - pads it with spaces
> > > > > + */
> > > > > + snprintf(tmp, sizeof(tmp), "%s ", name);
> > > >
> > > > I can't say I like code where I have to count spaces in order to
> > > > verify if the code is actually correct.
> > >
> > > What it wrong with "%-8.8s" ?
> >
> > There's nothing wrong with it, except lack of imagination on my side ;)
> > Andy, care to to send a separate patch just for extmem.c?
>
> Are any of the snprintf() versions actually correct at all?
> The implication of the comment is that the input string might
> not be NUL terminated - in which case it shouldn't be passed
> to snprintf().
> I don't think you can assume that the format processing doesn't
> do a strlen() of any %s argument - even if a maximum field
> width is given.
The input string is a NUL terminated ASCII string. The output string
is not. It is used to communicate with a hypervisor, which expects an
eight character EBCDIC non NUL terminated name, where the name is
either eight characters long or filled up with spaces.
So using snprintf here should be fine. On the other hand I really
don't see a pressing need to change anything here.
next prev parent reply other threads:[~2021-10-12 9:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 13:02 [PATCH v1 1/1] s390: Use string_upper() instead of open coded variant Andy Shevchenko
2021-10-04 20:31 ` Heiko Carstens
2021-10-05 8:18 ` Andy Shevchenko
2021-10-05 8:54 ` Heiko Carstens
2021-10-05 12:09 ` Andy Shevchenko
2021-10-11 8:21 ` David Laight
2021-10-11 10:09 ` Heiko Carstens
2021-10-12 8:04 ` David Laight
2021-10-12 9:12 ` Heiko Carstens [this message]
2021-10-07 18:07 ` Heiko Carstens
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=YWVRbQrDk7jtYApD@osiris \
--to=hca@linux.ibm.com \
--cc=David.Laight@aculab.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=borntraeger@de.ibm.com \
--cc=gor@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/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