Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2921051rwd; Fri, 16 Jun 2023 09:49:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NYElqvnDQHQfQgvdNxAFMl8+DFx3h1SNvflG4ZLTO0VmJ0eZ3nkLyu0ieUnubSZ8eJizO X-Received: by 2002:a17:902:e747:b0:1b3:ec39:f40d with SMTP id p7-20020a170902e74700b001b3ec39f40dmr2349478plf.50.1686934174043; Fri, 16 Jun 2023 09:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686934174; cv=none; d=google.com; s=arc-20160816; b=dAdQkj2SXaREH0KD+QIU2eg9C+PlsAOIm2o1Iig/TSKETtRQ6tJ5/yImmy1smJD+2s AM8CTYx0WRtohA12pLw4ruSBaD6si4dWcXgdgVO0Jf49hKfIbG1Htzzz/3Xwo3fOYr2z zJNYNZDX/hg5nAkR3+ltYXZL1DHZaLl/zgJIJJITeyAfqr/b5oKw4RhDigJ7JOrpCd8l lkIbXs2P3xA0wOv73PHO1AZPkUvXDpeVOGRh8BAY2Rn9sGTsyIus/wMmiIuNPJIaeE9b LbNMJTqY02+gj1xntnwt71JI7vYgPTbzuCk2wty+ycpWEOre1EwdSB6I2kwjWZYjAo+i nX0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ciLmmISBnAmBNpL57ZkiVLZdSgI5RvZx0KnVLxEMLQA=; b=OOp54W0+jQ4fzj53KqSCUh/KZP0xNu//veTNCj2fyzqsGJXjd0AVf4mHpZVErc/Qkc w1sF9NWku9IOB5a5wR61EjUqVTJ7Gw/+s2cDU1ENtvVDsLonrBgVDmp2kb5wcJ1JzFLW 3EUR1oaQ9zQQhfWj94re443Jb5yR4ZbfaJcTlQqqtxIt0uZOGI4yRFy5ai9Imsk6xvp/ Sp+7DNGzP0sVjZY/vugRkb5q+kmyanOWmQZBiI7EwtnOKpHK8tngtA6o2lEssm6BmFWO XHbDlPASysj3rd2Et2WyINHar8w0OnVuBJ+q3iTxLDOAEZJ36LbjMxztkwULf0C7kU9w azow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rZLz4t1B; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a170902d2cb00b001b3adfffd22si12609110plc.58.2023.06.16.09.49.19; Fri, 16 Jun 2023 09:49:34 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rZLz4t1B; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344677AbjFPQe1 (ORCPT + 99 others); Fri, 16 Jun 2023 12:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244776AbjFPQeY (ORCPT ); Fri, 16 Jun 2023 12:34:24 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 480983592; Fri, 16 Jun 2023 09:34:11 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2b4470e1500so13043871fa.1; Fri, 16 Jun 2023 09:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686933249; x=1689525249; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ciLmmISBnAmBNpL57ZkiVLZdSgI5RvZx0KnVLxEMLQA=; b=rZLz4t1BzNZQb2SDswJNFyGKJ8WIjGulQ96rA0XoBDm4CuASgdXM+yqAoyEvUyqtHT HQWx1TQ+0gU2JHhVssNB+mTm91uyQi9uuNjL+RXBTzL2nZbUgpD2W8KqgnSGCWQx6lfw 7Pl0ZXWHfB796z+BD7TlgijK0JO2Di1hrwUCddN/eAihOU9J7fWczr35jdc6zE790oiB XPFOD+noWYH9QUkPeCRdEpHxFKrmZEXzbZD6Sve+moKkU1bsgRsLXeFPntmOZ9EOQhrM Co/guy3EFea7xzzxX/oJT+42XAeaPS0tKXNAB+jSEQzhDW4YSmkv6iro7T8Fb7uBEPZE WvFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686933249; x=1689525249; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ciLmmISBnAmBNpL57ZkiVLZdSgI5RvZx0KnVLxEMLQA=; b=QjkhlluKxFXFalHT1yyj3JpXGfaT/Z/FuSlQOiS245TrUuB0dSnnceCsInm9T4bQIx 2cYWX1gNgZL9qpBApISC9FpXxP42ih446Q8gvFmUnOmZAKqvfodpHfvSovNKX1JpXy2A 5qfK2L7XC0mWl/rOFqLHof6FBORt9BnAYFL4NC5ZVel5OQEfmVcqkldi9RaKTfqfPSR0 +FiPqjd/RBf+g491P7uiN+jFDgdlo83+wzPTAQFSp2JNd3uUtQs/CXXcQBHhyU3lWToO YJmMvUluynlgyocpShQRftdgFYPO61BO9tn8BuSAEwj9A810NMIol5eMg08LYcqUuVl0 VvjA== X-Gm-Message-State: AC+VfDyb49F18n9U3XqJmyS4EnoSq0fTfLsUssVg/FHVN3Dyzz7tabMV KqokagEMZlVEY+Kj0N/3Z8Gmz4AK2qcgqcsSQAo= X-Received: by 2002:a2e:8756:0:b0:2b1:ae75:2781 with SMTP id q22-20020a2e8756000000b002b1ae752781mr2023912ljj.27.1686933249196; Fri, 16 Jun 2023 09:34:09 -0700 (PDT) MIME-Version: 1.0 References: <20230614073443.4894-1-zhanglibing@cdjrlc.com> <7f34bd3ce377d9d89626c2df8fa584e0@208suo.com> <0b12a94a-e3e9-e2a2-389e-48a588d5ad6b@meta.com> In-Reply-To: <0b12a94a-e3e9-e2a2-389e-48a588d5ad6b@meta.com> From: Andrii Nakryiko Date: Fri, 16 Jun 2023 09:33:57 -0700 Message-ID: Subject: Re: [PATCH] selftests/bpf: Fix the address is NULL To: Yonghong Song Cc: wuyonggang001@208suo.com, andrii@kernel.org, shuah@kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 14, 2023 at 7:09=E2=80=AFAM Yonghong Song wrote: > > > > On 6/14/23 12:42 AM, wuyonggang001@208suo.com wrote: > > Fix the following coccicheck error: > > > > tools/testing/selftests/bpf/progs/test_ksyms_weak.c:53:6-20: ERROR: tes= t > > of a variable/field address > > I didn't see clang/gcc compiler warns about this. Maybe need some > additional flags beyond what current selftest/bpf already has > in order to trigger this warning? > If you feel this warning has some merit, could you propose > it to gcc/llvm community? bpf_link_fops2 is a weak symbol, this check is totally valid and reasonable= . There are two problems here, though: a) coccicheck shouldn't warn about "test of a variable/field address" for weak symbols, because they can be NULL. b) this patch is not even fixing that warning, it does a no-op change from implicit non-NULL check to explicit non-NULL check. And the former is actually the preferred style. So this patch is doubly wrong. > > > > > Signed-off-by: Yonggang Wu > > --- > > tools/testing/selftests/bpf/progs/test_ksyms_weak.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/bpf/progs/test_ksyms_weak.c > > b/tools/testing/selftests/bpf/progs/test_ksyms_weak.c > > index d00268c91e19..768a4d6ee6f5 100644 > > --- a/tools/testing/selftests/bpf/progs/test_ksyms_weak.c > > +++ b/tools/testing/selftests/bpf/progs/test_ksyms_weak.c > > @@ -50,7 +50,7 @@ int pass_handler(const void *ctx) > > /* tests non-existent symbols. */ > > out__non_existent_typed =3D (__u64)&bpf_link_fops2; > > > > - if (&bpf_link_fops2) /* can't happen */ > > + if (&bpf_link_fops2 !=3D NULL) /* can't happen */ > > out__non_existent_typed =3D > > (__u64)bpf_per_cpu_ptr(&bpf_link_fops2, 0); > > > > if (!bpf_ksym_exists(bpf_task_acquire)) > >