lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200421032328.fglmpdmnwnjts375@ast-mbp.dhcp.thefacebook.com>
Date:   Mon, 20 Apr 2020 20:23:28 -0700
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Song Liu <songliubraving@...com>
Cc:     Mao Wenan <maowenan@...wei.com>, "ast@...nel.org" <ast@...nel.org>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        Martin Lau <kafai@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        "john.fastabend@...il.com" <john.fastabend@...il.com>,
        "kpsingh@...omium.org" <kpsingh@...omium.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        kernel-team@...com
Subject: Re: [PATCH bpf-next v2] bpf: remove set but not used variable
 'dst_known'

On Sat, Apr 18, 2020 at 06:13:48AM +0000, Song Liu wrote:
> 
> 
> > On Apr 17, 2020, at 6:37 PM, Mao Wenan <maowenan@...wei.com> wrote:
> > 
> > Fixes gcc '-Wunused-but-set-variable' warning:
> > 
> > kernel/bpf/verifier.c:5603:18: warning: variable ‘dst_known’
> > set but not used [-Wunused-but-set-variable], delete this
> > variable.
> > 
> > Signed-off-by: Mao Wenan <maowenan@...wei.com>
> 
> Acked-by: Song Liu <songliubraving@...com>
> 
> With one nit below. 
> 
> > ---
> > v2: remove fixes tag in commit log. 
> > kernel/bpf/verifier.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index 04c6630cc18f..c9f50969a689 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -5600,7 +5600,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env,
> > {
> > 	struct bpf_reg_state *regs = cur_regs(env);
> > 	u8 opcode = BPF_OP(insn->code);
> > -	bool src_known, dst_known;
> > +	bool src_known;
> 
> This is not a hard rule, but we prefer to keep variable definition in 
> "reverse Christmas tree" order. Since we are on this function, let's 
> reorder these definitions to something like:
> 
>         u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32;
>         struct bpf_reg_state *regs = cur_regs(env);
>         u8 opcode = BPF_OP(insn->code);
>         u32 dst = insn->dst_reg;
>         s64 smin_val, smax_val;
>         u64 umin_val, umax_val;
>         bool src_known;
>         int ret;

I don't want folks to keep re-sorting variables and making patches difficult
to backport, do git blame, causing bpf vs bpf-next conflicts, etc.

reverse xmas tree is not mandatory. It's a style preference.
I personally do it for new code, but very rarely for fixes.
And certainly not for this kind of cleanup.

Applied. Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ