BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@meta.com>
To: "Daniel T. Lee" <danieltimlee@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup
Date: Sat, 17 Dec 2022 09:49:31 -0800	[thread overview]
Message-ID: <c0d20556-cfb2-ed5e-3aa3-af34bb348b5b@meta.com> (raw)
In-Reply-To: <20221217153821.2285-4-danieltimlee@gmail.com>



On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> Currently, compiling samples/bpf with LLVM warns about the uninitialized
> use of variable with test_current_task_under_cgroup.
> 
>      ./samples/bpf/test_current_task_under_cgroup_user.c:57:6:
>      warning: variable 'cg2' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> 	    if (setup_cgroup_environment())
> 		^~~~~~~~~~~~~~~~~~~~~~~~~~
>      ./samples/bpf/test_current_task_under_cgroup_user.c:106:8:
>      note: uninitialized use occurs here
> 	    close(cg2);
> 		  ^~~
>      ./samples/bpf/test_current_task_under_cgroup_user.c:57:2:
>      note: remove the 'if' if its condition is always false
> 	    if (setup_cgroup_environment())
> 	    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      ./samples/bpf/test_current_task_under_cgroup_user.c:19:9:
>      note: initialize the variable 'cg2' to silence this warning
> 	    int cg2, idx = 0, rc = 1;
> 		   ^
> 		    = 0
>      1 warning generated.
> 
> This commit resolve this compiler warning by pre-initialize the variable
> with error for safeguard.
> 
> Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>

Acked-by: Yonghong Song <yhs@fb.com>

  reply	other threads:[~2022-12-17 17:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17 15:38 [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Daniel T. Lee
2022-12-17 15:38 ` [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
2022-12-17 17:48   ` Yonghong Song
2022-12-17 15:38 ` [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
2022-12-17 17:49   ` Yonghong Song
2022-12-17 15:38 ` [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
2022-12-17 17:49   ` Yonghong Song [this message]
2022-12-17 17:48 ` [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Yonghong Song
2022-12-18  0:08   ` Daniel T. Lee

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=c0d20556-cfb2-ed5e-3aa3-af34bb348b5b@meta.com \
    --to=yhs@meta.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danieltimlee@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.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