[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D11F36F6-BF28-4DEB-8AED-4486477130F8@zytor.com>
Date: Wed, 06 May 2020 07:16:11 -0700
From: hpa@...or.com
To: Jason Yan <yanaijie@...wei.com>, davem@...emloft.net,
kuznet@....inr.ac.ru, yoshfuji@...ux-ipv6.org, udknight@...il.com,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
ast@...nel.org, daniel@...earbox.net, kafai@...com,
songliubraving@...com, yhs@...com, andriin@...com,
john.fastabend@...il.com, kpsingh@...omium.org,
lukenels@...washington.edu, xi.wang@...il.com,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] bpf, i386: remove unneeded conversion to bool
On May 6, 2020 7:03:52 AM PDT, Jason Yan <yanaijie@...wei.com> wrote:
>The '==' expression itself is bool, no need to convert it to bool
>again.
>This fixes the following coccicheck warning:
>
>arch/x86/net/bpf_jit_comp32.c:1478:50-55: WARNING: conversion to bool
>not needed here
>arch/x86/net/bpf_jit_comp32.c:1479:50-55: WARNING: conversion to bool
>not needed here
>
>Signed-off-by: Jason Yan <yanaijie@...wei.com>
>---
> v2: change the name 'x32' to 'i386'.
>
> arch/x86/net/bpf_jit_comp32.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/arch/x86/net/bpf_jit_comp32.c
>b/arch/x86/net/bpf_jit_comp32.c
>index 66cd150b7e54..96fde03aa987 100644
>--- a/arch/x86/net/bpf_jit_comp32.c
>+++ b/arch/x86/net/bpf_jit_comp32.c
>@@ -1475,8 +1475,8 @@ static int do_jit(struct bpf_prog *bpf_prog, int
>*addrs, u8 *image,
> for (i = 0; i < insn_cnt; i++, insn++) {
> const s32 imm32 = insn->imm;
> const bool is64 = BPF_CLASS(insn->code) == BPF_ALU64;
>- const bool dstk = insn->dst_reg == BPF_REG_AX ? false : true;
>- const bool sstk = insn->src_reg == BPF_REG_AX ? false : true;
>+ const bool dstk = insn->dst_reg != BPF_REG_AX;
>+ const bool sstk = insn->src_reg != BPF_REG_AX;
> const u8 code = insn->code;
> const u8 *dst = bpf2ia32[insn->dst_reg];
> const u8 *src = bpf2ia32[insn->src_reg];
"foo ? true : false" is also far better written !!foo when it isn't totally redundant.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Powered by blists - more mailing lists