Message ID | 2b3f2420.130.184706d34e6.Coremail.wangkailong@jari.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1621908wru; Sun, 13 Nov 2022 02:11:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4h4wQ+Qkv14nT3wJZO89CivW11k0aLxjAFF7Wk/aKQXuSvOV2Gre+olC9kIGKdtWUg3Va6 X-Received: by 2002:a63:ef0e:0:b0:45f:c9d5:d490 with SMTP id u14-20020a63ef0e000000b0045fc9d5d490mr8055460pgh.392.1668334297776; Sun, 13 Nov 2022 02:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668334297; cv=none; d=google.com; s=arc-20160816; b=Nhd9uWWaZ0larqT8OfCbWM7q5SJWrue3WKqUUIhDJPBXD1q07UBn+e/QaX5EsbNRlT /KNMktqzjd14keoRaznT26MfHtfHgfc8KZjqELFl92bkukbRqU5VVYvBVrGps3rdqA1e Asb3ZkmEY9SVZEDKcFgInFBjb9rtSkpfSobTnYqR49Eoian9KbFcwl5Tr1ec58xeCs4F qNJIEQGbWxdJNL1fhZCW8tr7h4J4QVkWDb2/Od0iJN/5gSyb3ocSW/yIOuOPvnRynr0V PGVxRgHJCZvNDrEVLKl5Ki6IJ95vpmiQuGzbTrIz8kzXgc4saxnerP/08zPwl+im32/y OdbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:to:from:date; bh=gRlV938spXVtoECNctXgHod5EeecJHEXqvR9Py5QSLA=; b=KS4VYIr7jjJiPqJXeh0a37fgjoJYYI0zs88uCWrbvsb53HJWSh/Lj+UTttuYowmDv0 3kRM9QynJ2cv0GdyuSW9gw4ez/nzDLM60hTbiKWnSpPnrWgBeGhfA5n1/LwKBelDpEiz MKM2L9YkKOs5K/8uWrjLrjbVzN2AsY3lMUI2np/JDqJ4KuB4lZkLBvCxbEkDPUTwmvvq mVeaqF4N00S53yhuJeDRbTcFELMQ2njqFPOHSNdDPwDOy+LdHWdGl+mVKa/+UDaa6MiZ VASfL5/mSHWMhXnaiuwh2UuQ9L69Rs4LPYamTjC21UsmabxYy2IhFtv9Lo8kq02zGysT 0UAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a1709027c8200b00188b297f39bsi4527712pll.216.2022.11.13.02.10.58; Sun, 13 Nov 2022 02:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235185AbiKMKDf (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Sun, 13 Nov 2022 05:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbiKMKDd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 13 Nov 2022 05:03:33 -0500 Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E0735F40; Sun, 13 Nov 2022 02:03:31 -0800 (PST) Received: by ajax-webmail-localhost.localdomain (Coremail) ; Sun, 13 Nov 2022 17:58:36 +0800 (GMT+08:00) X-Originating-IP: [182.148.14.167] Date: Sun, 13 Nov 2022 17:58:36 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: wangkailong@jari.cn To: linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH] samples/seccomp: fix array_size.cocci warning X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT6.0.1 build 20210329(c53f3fee) Copyright (c) 2002-2022 www.mailtech.cn mispb-4e503810-ca60-4ec8-a188-7102c18937cf-zhkzyfz.cn Content-Transfer-Encoding: base64 Content-Type: text/plain; charset=UTF-8 MIME-Version: 1.0 Message-ID: <2b3f2420.130.184706d34e6.Coremail.wangkailong@jari.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwCnu+HMv3BjEh0DAA--.78W X-CM-SenderInfo: 5zdqwypdlo00nj6mt2flof0/1tbiAQAEB2FEYx0DfwAds4 X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,RCVD_IN_PBL,RDNS_NONE, T_SPF_HELO_PERMERROR,T_SPF_PERMERROR,XPRIO autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749375304729965003?= X-GMAIL-MSGID: =?utf-8?q?1749375304729965003?= |
Series |
samples/seccomp: fix array_size.cocci warning
|
|
Commit Message
KaiLong Wang
Nov. 13, 2022, 9:58 a.m. UTC
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
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
samples/seccomp/bpf-fancy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
Hi, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v6.1-rc4 next-20221111] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/wangkailong-jari-cn/samples-seccomp-fix-array_size-cocci-warning/20221113-180424 patch link: https://lore.kernel.org/r/2b3f2420.130.184706d34e6.Coremail.wangkailong%40jari.cn patch subject: [PATCH] samples/seccomp: fix array_size.cocci warning config: i386-allyesconfig compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/ee8a383f3aac9a380696920bd2b5a80c6a92e6e9 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review wangkailong-jari-cn/samples-seccomp-fix-array_size-cocci-warning/20221113-180424 git checkout ee8a383f3aac9a380696920bd2b5a80c6a92e6e9 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All error/warnings (new ones prefixed by >>): samples/seccomp/bpf-fancy.c: In function 'main': >> samples/seccomp/bpf-fancy.c:83:41: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration] 83 | .len = (unsigned short)(ARRAY_SIZE(filter)), | ^~~~~~~~~~ -- /usr/bin/ld: samples/seccomp/bpf-fancy.o: in function `main': >> bpf-fancy.c:(.text.startup+0x4f2): undefined reference to `ARRAY_SIZE' >> /usr/bin/ld: bpf-fancy.c:(.text.startup+0x507): undefined reference to `ARRAY_SIZE' collect2: error: ld returned 1 exit status
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)); > if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { > perror("prctl(NO_NEW_PRIVS)"); > -- > 2.25.1
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
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.1-rc6 next-20221121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/wangkailong-jari-cn/samples-seccomp-fix-array_size-cocci-warning/20221113-180424
patch link: https://lore.kernel.org/r/2b3f2420.130.184706d34e6.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] samples/seccomp: fix array_size.cocci warning
config: x86_64-allyesconfig
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/ee8a383f3aac9a380696920bd2b5a80c6a92e6e9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review wangkailong-jari-cn/samples-seccomp-fix-array_size-cocci-warning/20221113-180424
git checkout ee8a383f3aac9a380696920bd2b5a80c6a92e6e9
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
/usr/bin/ld: samples/seccomp/bpf-fancy.o: in function `main':
bpf-fancy.c:(.text.startup+0x7a7): undefined reference to `ARRAY_SIZE'
/usr/bin/ld: bpf-fancy.c:(.text.startup+0x7bb): undefined reference to `ARRAY_SIZE'
>> collect2: error: ld returned 1 exit status
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)); if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { perror("prctl(NO_NEW_PRIVS)");