public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: sdf@google.com
Cc: wangkailong@jari.cn, linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH] samples/seccomp: fix array_size.cocci warning
Date: Thu, 17 Nov 2022 16:54:33 -0800	[thread overview]
Message-ID: <202211171653.0E3BA8E71B@keescook> (raw)
In-Reply-To: <Y3J3t/ieGaOG8Qjl@google.com>

On Mon, Nov 14, 2022 at 09:15:35AM -0800, sdf@google.com wrote:
> On 11/13, wangkailong@jari.cn wrote:
> > Fix following coccicheck warning:
> 
> > samples/seccomp/bpf-fancy.c:83:39-40: WARNING: Use ARRAY_SIZE
> > samples/seccomp/bpf-fancy.c:86:44-45: WARNING: Use ARRAY_SIZE
> 
> Not sure this should go via bpf tree. CC'ed Kees
> 
> > Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
> > ---
> >   samples/seccomp/bpf-fancy.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> > diff --git a/samples/seccomp/bpf-fancy.c b/samples/seccomp/bpf-fancy.c
> > index 1ccb435025b6..548f038924d6 100644
> > --- a/samples/seccomp/bpf-fancy.c
> > +++ b/samples/seccomp/bpf-fancy.c
> > @@ -80,10 +80,10 @@ int main(int argc, char **argv)
> >   	};
> >   	struct sock_fprog prog = {
> >   		.filter = filter,
> > -		.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
> > +		.len = (unsigned short)(ARRAY_SIZE(filter)),
> >   	};
> >   	ssize_t bytes;
> > -	bpf_resolve_jumps(&l, filter, sizeof(filter)/sizeof(*filter));
> > +	bpf_resolve_jumps(&l, filter, ARRAY_SIZE(filter));

Hm, this is the "samples" tree, so this was intentionally avoiding these
kinds of kernel-isms, but perhaps that doesn't realistically matter?

-Kees

> 
> >   	if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
> >   		perror("prctl(NO_NEW_PRIVS)");
> > --
> > 2.25.1

-- 
Kees Cook

  reply	other threads:[~2022-11-18  0:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-13  9:58 [PATCH] samples/seccomp: fix array_size.cocci warning wangkailong
2022-11-13 15:52 ` kernel test robot
2022-11-14 17:15 ` sdf
2022-11-18  0:54   ` Kees Cook [this message]
2022-11-22 10:38 ` kernel test robot

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=202211171653.0E3BA8E71B@keescook \
    --to=keescook@chromium.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=wangkailong@jari.cn \
    /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