From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: Joe Perches <joe@perches.com>
Cc: Khalid Aziz <khalid@gonehiking.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 1/5] scsi: BusLogic: Fix missing `pr_cont' use
Date: Fri, 16 Apr 2021 12:48:42 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.2104161224300.44318@angie.orcam.me.uk> (raw)
In-Reply-To: <787aae5540612555a8bf92de2083c8fa74e52ce9.camel@perches.com>
On Thu, 15 Apr 2021, Joe Perches wrote:
> In patch 2, vscnprintf should probably be used to make sure it's
> 0 terminated.
Why? C99 has this[1]:
"The vsnprintf function is equivalent to snprintf, with the variable
argument list replaced by arg, which shall have been initialized by the
va_start macro (and possibly subsequent va_arg calls)."
and then[2]:
"The snprintf function is equivalent to fprintf, except that the output
is written into an array (specified by argument s) rather than to a
stream. If n is zero, nothing is written, and s may be a null pointer.
Otherwise, output characters beyond the n-1st are discarded rather than
being written to the array, and a null character is written at the end
of the characters actually written into the array."
therefore output from `vsnprintf' is always null-terminated.
> And while it's a lot more code, I'd prefer a solution that looks more
> like the other commonly used kernel logging extension mechanisms
> where adapter is placed before the format, ... in the argument list.
I agree having `adapter' as the second argument seems weird, so that is
fine with me as a follow-up cleanup. However as a user-visible change I
think the fix I propose here ought to be applied first (and backported
as suitable). Then any internal clean-ups can follow, applied to trunk
only.
> And there's a simple addition of a blogic_cont macro and extension
> to blogic_msg to simplify the logic and obviousness of the logging
> extension lines too.
I did this first actually, before I realised a simpler change suitable
for backporting could be done. I'm not sure if that complex message
routing via `blogic_msg' is worth having even, rather than calling
`printk' or suitable variants directly.
References:
[1] "Programming languages -- C", INTERNATIONAL STANDARD, ISO/IEC 9899,
Second edition, 1999-12-01, Section 7.19.6.12 "The vsnprintf
function", p.293
[2] same, 7.19.6.5 "The snprintf function", p.289
Maciej
next prev parent reply other threads:[~2021-04-16 10:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 22:38 [PATCH 0/5] Bring the BusLogic host bus adapter driver up to Y2021 Maciej W. Rozycki
2021-04-14 22:39 ` [PATCH 1/5] scsi: BusLogic: Fix missing `pr_cont' use Maciej W. Rozycki
2021-04-16 2:08 ` Joe Perches
2021-04-16 10:48 ` Maciej W. Rozycki [this message]
2021-04-16 14:02 ` Joe Perches
2021-04-16 14:28 ` Maciej W. Rozycki
2021-04-16 15:12 ` Joe Perches
2021-04-17 11:39 ` David Laight
2021-04-17 14:01 ` Maciej W. Rozycki
2021-04-16 20:41 ` Khalid Aziz
2021-04-17 0:09 ` Joe Perches
2021-04-16 19:34 ` Khalid Aziz
2021-04-14 22:39 ` [PATCH 2/5] scsi: BusLogic: Avoid unbounded `vsprintf' use Maciej W. Rozycki
2021-04-16 19:54 ` Khalid Aziz
2021-04-14 22:39 ` [PATCH 3/5] scsi: Provide for avoiding trailing allocation length with VPD inquiries Maciej W. Rozycki
2021-04-14 22:39 ` [PATCH 4/5] scsi: Avoid using reserved length byte " Maciej W. Rozycki
2021-04-14 22:39 ` [PATCH 5/5] scsi: Set allocation length to 255 for ATA Information VPD page Maciej W. Rozycki
2021-04-15 12:42 ` Nix
2021-04-16 15:18 ` Maciej W. Rozycki
2021-04-16 19:36 ` [PATCH 0/5] Bring the BusLogic host bus adapter driver up to Y2021 Khalid Aziz
2021-04-16 21:25 ` Maciej W. Rozycki
2021-04-18 20:21 ` Ondrej Zary
2021-04-19 15:06 ` Khalid Aziz
2021-04-19 16:01 ` Maciej W. Rozycki
2021-04-20 2:16 ` Khalid Aziz
2021-04-20 18:02 ` Maciej W. Rozycki
2021-04-22 2:36 ` Khalid Aziz
2021-04-22 16:27 ` Maciej W. Rozycki
2021-04-22 18:07 ` Khalid Aziz
2021-04-22 23:19 ` Maciej W. Rozycki
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=alpine.DEB.2.21.2104161224300.44318@angie.orcam.me.uk \
--to=macro@orcam.me.uk \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=joe@perches.com \
--cc=khalid@gonehiking.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).