From cc9c19b0302a83be6520c38a0a9944314ccc6962 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 26 Jun 2021 22:03:14 -0400 Subject: [PATCH] sim: bpf: fix mixed decls & code warnings (and style) --- sim/bpf/ChangeLog | 5 +++++ sim/bpf/bpf-helpers.c | 3 ++- sim/bpf/mloop.in | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sim/bpf/ChangeLog b/sim/bpf/ChangeLog index 7ac04664a91..7c48d289b30 100644 --- a/sim/bpf/ChangeLog +++ b/sim/bpf/ChangeLog @@ -1,3 +1,8 @@ +2021-06-27 Mike Frysinger + + * bpf-helpers.c (bpf_trace_printk): Move value decl to top of scope. + * mloop.in: Move off16 & imm32 decls to top of scope. + 2021-06-22 Mike Frysinger * configure: Regenerate. diff --git a/sim/bpf/bpf-helpers.c b/sim/bpf/bpf-helpers.c index c308812ab1c..79a3a7d3702 100644 --- a/sim/bpf/bpf-helpers.c +++ b/sim/bpf/bpf-helpers.c @@ -72,6 +72,7 @@ bpf_trace_printk (SIM_CPU *current_cpu) supported, which are read from %r3, %r4 and %r5 respectively. */ for (i = 0, tags_processed = 0; i < size;) { + UDI value; QI c = GETMEMUQI (current_cpu, CPU_PC_GET (current_cpu), fmt_address + i); @@ -88,7 +89,7 @@ bpf_trace_printk (SIM_CPU *current_cpu) if (i++ >= size) return -1; /* XXX look for kernel error code. */ - UDI value = GET_H_GPR (3 + tags_processed); + value = GET_H_GPR (3 + tags_processed); switch ((GETMEMUQI (current_cpu, CPU_PC_GET (current_cpu), fmt_address + i))) diff --git a/sim/bpf/mloop.in b/sim/bpf/mloop.in index 91f0c445eed..75a869b3399 100644 --- a/sim/bpf/mloop.in +++ b/sim/bpf/mloop.in @@ -123,14 +123,17 @@ cat <> 16); - USI imm32 = (USI) ((insn & 0xffffffff00000000) >> 32); + off16 = (UHI) ((insn & 0x00000000ffff0000) >> 16); + imm32 = (USI) ((insn & 0xffffffff00000000) >> 32); off16 = SWAP_2 (off16); imm32 = SWAP_4 (imm32); -- 2.30.2