Commit bbfddb9
committed
LoongArch: BPF: Avoid declare variables in switch-case
Not all compilers support declare variables in switch-case, so move
declarations to the beginning of a function. Otherwise we may get such
build errors:
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;
^~~
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>1 parent 4805a13 commit bbfddb9
1 file changed
+13
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
362 | | - | |
363 | | - | |
364 | 363 | | |
365 | 364 | | |
366 | 365 | | |
| |||
390 | 389 | | |
391 | 390 | | |
392 | 391 | | |
393 | | - | |
394 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
| |||
400 | 402 | | |
401 | 403 | | |
402 | 404 | | |
403 | | - | |
404 | | - | |
| 405 | + | |
| 406 | + | |
405 | 407 | | |
406 | 408 | | |
407 | 409 | | |
| |||
724 | 726 | | |
725 | 727 | | |
726 | 728 | | |
727 | | - | |
728 | 729 | | |
729 | 730 | | |
730 | 731 | | |
731 | | - | |
| 732 | + | |
732 | 733 | | |
733 | 734 | | |
734 | | - | |
| 735 | + | |
735 | 736 | | |
736 | 737 | | |
737 | 738 | | |
738 | | - | |
| 739 | + | |
739 | 740 | | |
740 | 741 | | |
741 | | - | |
| 742 | + | |
742 | 743 | | |
743 | 744 | | |
744 | | - | |
| 745 | + | |
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| |||
775 | 776 | | |
776 | 777 | | |
777 | 778 | | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | 779 | | |
783 | 780 | | |
784 | 781 | | |
| |||
811 | 808 | | |
812 | 809 | | |
813 | 810 | | |
814 | | - | |
815 | | - | |
816 | 811 | | |
817 | 812 | | |
818 | 813 | | |
| |||
0 commit comments