Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1972031pxb; Mon, 23 Aug 2021 08:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF+eA5BL3oFZkBXWWG2PrASv/+pbN+398zAw6HNg7Mr3599H4CG6rGtUgBTKYJuDQ9upCW X-Received: by 2002:a17:906:d20a:: with SMTP id w10mr37583298ejz.426.1629734185112; Mon, 23 Aug 2021 08:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629734185; cv=none; d=google.com; s=arc-20160816; b=0VsOSZ2bknKCBWrTqWWwIzsE7+tcAZsHX+BLMKBBqzT+AC9n6R9ZBOfjyBAW9X08pu XS3r2+XQJWa6f6j4YBZaIt73waaKPnt4B3mgfILOt5pPHBKfKBZ6EizTws3GnVbaRMeG aSXaktTZhBITdfJcXmpUwwDKaFkowP8ehojpiBVHwBrwlLseO3VP7q7W+CxsRKKR7JO5 5QCih/5R1BEHam/NdMx4AnqGWUMCTGTni+bgDAGTrh8ayKBfrAzzHYDG5kwMnbvJwELb iSc3l5lMKLhQsIeCJbpkvOe2l8MdahszwtaEUNakxy2fdJb0adQ9qzmGb5UBjhjxN8xY kxfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Sjns47w+tuI9zXRTZHWmSDIXTuSX5+8qFotOB4Q8pr8=; b=M1FY4MChhpxJcKQ5NOXUdh/xvk94wuQXyCzP/VYqghEBGDTst3I60VZFui8+D10QJG 1UnpcSUCT/VRx+WkFzNbDrVVBRyMVh1xt7wEuYT3jzke1UEVFqGQtV4jnwe+vJuOM9tE 7wspUkb/GxjlbHm3k65RTuWjVe1aKXLaxNbqgQGmoVEvURBPxqZwejX88JTM+MwaeEe6 OeI8SomX1IafgF8JvvIKix3MvvEmFpd0fYKPaeWlLkakxfW66Nu0QYnVE06o3ZfeMne+ /V7HfJNaOVRgDa4+X1uFYDNqZxPnJXau/1xVR6DP8zFU0aDYWwZ7qrBEUeOf2dZ7PZa+ z57A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si17559559ejd.203.2021.08.23.08.56.00; Mon, 23 Aug 2021 08:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbhHWPzH (ORCPT + 99 others); Mon, 23 Aug 2021 11:55:07 -0400 Received: from www62.your-server.de ([213.133.104.62]:35630 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbhHWPzG (ORCPT ); Mon, 23 Aug 2021 11:55:06 -0400 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mICH7-0007Np-Gb; Mon, 23 Aug 2021 17:54:13 +0200 Received: from [85.5.47.65] (helo=linux.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mICH6-000KwX-Tj; Mon, 23 Aug 2021 17:54:13 +0200 Subject: Re: [PATCH linux-next] tools: fix warning comparing pointer to 0 To: CGEL , Shuah Khan Cc: Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Andrei Matei , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, jing yangyang , Zeal Robot References: <20210820033057.13063-1-jing.yangyang@zte.com.cn> From: Daniel Borkmann Message-ID: <491f06b5-3680-012a-f1d0-9831aa18e56a@iogearbox.net> Date: Mon, 23 Aug 2021 17:54:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20210820033057.13063-1-jing.yangyang@zte.com.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.2/26272/Mon Aug 23 10:21:13 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/20/21 5:30 AM, CGEL wrote: > From: jing yangyang > > Fix the following coccicheck warning: > ./tools/testing/selftests/bpf/progs/profiler.inc.h:364:18-22:WARNING > comparing pointer to 0 > ./tools/testing/selftests/bpf/progs/profiler.inc.h:537:23-27:WARNING > comparing pointer to 0 > ./tools/testing/selftests/bpf/progs/profiler.inc.h:544:21-25:WARNING > comparing pointer to 0 > ./tools/testing/selftests/bpf/progs/profiler.inc.h:770:13-17:WARNING > comparing pointer to 0 > > Reported-by: Zeal Robot > Signed-off-by: jing yangyang Please properly explain in the commit message what this 'fixes' exactly and why it is needed. > --- > tools/testing/selftests/bpf/progs/profiler.inc.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/bpf/progs/profiler.inc.h b/tools/testing/selftests/bpf/progs/profiler.inc.h > index 4896fdf..5c0bdab 100644 > --- a/tools/testing/selftests/bpf/progs/profiler.inc.h > +++ b/tools/testing/selftests/bpf/progs/profiler.inc.h > @@ -361,7 +361,7 @@ static INLINE void* populate_var_metadata(struct var_metadata_t* metadata, > int zero = 0; > struct var_kill_data_t* kill_data = bpf_map_lookup_elem(&data_heap, &zero); > > - if (kill_data == NULL) > + if (!kill_dat) And please don't send broken stuff like this. > return NULL; > struct task_struct* task = (struct task_struct*)bpf_get_current_task(); > > @@ -534,14 +534,14 @@ static INLINE bool is_dentry_allowed_for_filemod(struct dentry* file_dentry, > *device_id = dev_id; > bool* allowed_device = bpf_map_lookup_elem(&allowed_devices, &dev_id); > > - if (allowed_device == NULL) > + if (!allowed_device) > return false; > > u64 ino = BPF_CORE_READ(file_dentry, d_inode, i_ino); > *file_ino = ino; > bool* allowed_file = bpf_map_lookup_elem(&allowed_file_inodes, &ino); > > - if (allowed_file == NULL) > + if (!allowed_fil) ... same. You did not bother to compile test even. > if (!is_ancestor_in_allowed_inodes(BPF_CORE_READ(file_dentry, d_parent))) > return false; > return true; > @@ -689,7 +689,7 @@ int raw_tracepoint__sched_process_exec(struct bpf_raw_tracepoint_args* ctx) > u64 inode = BPF_CORE_READ(bprm, file, f_inode, i_ino); > > bool* should_filter_binprm = bpf_map_lookup_elem(&disallowed_exec_inodes, &inode); > - if (should_filter_binprm != NULL) > + if (should_filter_binprm) > goto out; > > int zero = 0; >