From: James Bottomley <jejb@linux.ibm.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Kees Cook <keescook@chromium.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Adaptec OEM Raid Solutions <aacraid@microsemi.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] scsi: aacraid: Replace one-element array with flexible-array member
Date: Tue, 13 Apr 2021 07:04:11 -0700 [thread overview]
Message-ID: <94bff1bedd0dfa957822a6a303b48eca787f9a21.camel@linux.ibm.com> (raw)
In-Reply-To: <aba7d5cb-79be-088d-d1f8-9309109e9afc@embeddedor.com>
On Tue, 2021-04-13 at 00:45 -0500, Gustavo A. R. Silva wrote:
> Hi Martin,
>
> On 4/12/21 23:52, Martin K. Petersen wrote:
>
> > Silencing analyzer warnings shouldn't be done at the expense of
> > human
> > readers. If it is imperative to switch to flex_array_size() to
> > quiesce
> > checker warnings, please add a comment in the code explaining that
> > the
> > size evaluates to nseg_new-1 sge_ieee1212 structs.
>
> Done:
>
> https://lore.kernel.org/lkml/20210413054032.GA276102@embeddedor/
I think the reason everyone gets confused is that they think the first
argument should do something. If flex_array_size had been defined
#define flex_array_size(p, count) \
array_size(count, \
sizeof(*(p)) + __must_be_array(p))
Then we could have used
flex_array_size(sge, nseg_new - 1)
or
flex_array_size(rio->sge, nseg_new - 1)
and everyone would have understood either expression. This would also
have been useful, as the first example demonstrates, when we have a
pointer rather than a flexible member ... although that means the macro
likely needs a new name.
However, perhaps just do
array_size(nseg_new - 1, sizeof(*sge));
And lose the comment?
James
prev parent reply other threads:[~2021-04-13 14:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 20:38 Gustavo A. R. Silva
2021-03-25 1:18 ` Martin K. Petersen
2021-03-25 0:46 ` Gustavo A. R. Silva
2021-03-26 3:34 ` Martin K. Petersen
2021-03-26 3:07 ` Gustavo A. R. Silva
2021-04-07 19:22 ` Kees Cook
2021-04-13 4:52 ` Martin K. Petersen
2021-04-13 5:45 ` Gustavo A. R. Silva
2021-04-13 14:04 ` James Bottomley [this message]
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=94bff1bedd0dfa957822a6a303b48eca787f9a21.camel@linux.ibm.com \
--to=jejb@linux.ibm.com \
--cc=aacraid@microsemi.com \
--cc=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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
all inboxes | Powered by JetHome®