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] [thread-next>] [day] [month] [year] [list]
Message-ID: <e228a9ce-7801-ae00-001e-12f4ac4d2a81@loongson.cn>
Date:   Fri, 14 Oct 2022 09:45:34 +0800
From:   Tiezhu Yang <yangtiezhu@...ngson.cn>
To:     Huacai Chen <chenhuacai@...ngson.cn>,
        Huacai Chen <chenhuacai@...nel.org>
Cc:     loongarch@...ts.linux.dev, Xuefeng Li <lixuefeng@...ngson.cn>,
        Guo Ren <guoren@...nel.org>, Xuerui Wang <kernel@...0n.name>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] LoongArch: BPF: Avoid declare variables in switch-case



On 10/13/2022 11:40 PM, Huacai Chen wrote:
> Not all compilers support declare variables in switch-case, so move

We know that gcc 13 has no problem, it is better to point out the
compiler version explicitly in the commit message so that the users
can know how to reproduce the build errors.

> declarations to the beginning of a function. Otherwise we may get such
> build errors:

We can resolve the errors by adding a pair of curly braces around
the statements of the case, like this:

switch (...) {
case ...:
     {
         int ...;
         ...
         break;
     }
}

>
> arch/loongarch/net/bpf_jit.c: In function ‘emit_atomic’:
> arch/loongarch/net/bpf_jit.c:362:3: error: a label can only be part of a statement and a declaration is not a statement
>    u8 r0 = regmap[BPF_REG_0];
>    ^~
> arch/loongarch/net/bpf_jit.c: In function ‘build_insn’:
> arch/loongarch/net/bpf_jit.c:727:3: error: a label can only be part of a statement and a declaration is not a statement
>    u8 t7 = -1;
>    ^~
> arch/loongarch/net/bpf_jit.c:778:3: error: a label can only be part of a statement and a declaration is not a statement
>    int ret;
>    ^~~
> arch/loongarch/net/bpf_jit.c:779:3: error: expected expression before ‘u64’
>    u64 func_addr;
>    ^~~
> arch/loongarch/net/bpf_jit.c:780:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
>    bool func_addr_fixed;
>    ^~~~
> arch/loongarch/net/bpf_jit.c:784:11: error: ‘func_addr’ undeclared (first use in this function); did you mean ‘in_addr’?
>           &func_addr, &func_addr_fixed);
>            ^~~~~~~~~
>            in_addr
> arch/loongarch/net/bpf_jit.c:784:11: note: each undeclared identifier is reported only once for each function it appears in
> arch/loongarch/net/bpf_jit.c:814:3: error: a label can only be part of a statement and a declaration is not a statement
>    u64 imm64 = (u64)(insn + 1)->imm << 32 | (u32)insn->imm;
>    ^~~
>

Thanks,
Tiezhu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ