]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: bpf: fix mixed decls & code warnings (and style)
authorMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 02:03:14 +0000 (22:03 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 14:36:55 +0000 (10:36 -0400)
sim/bpf/ChangeLog
sim/bpf/bpf-helpers.c
sim/bpf/mloop.in

index 7ac04664a9116e5f7fab2ee2ce2845df8b9f3791..7c48d289b30f406a340a9abc7c655c8b49a4ff4b 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-27  Mike Frysinger  <vapier@gentoo.org>
+
+       * 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  <vapier@gentoo.org>
 
        * configure: Regenerate.
index c308812ab1cc543d98da5d8214799f603f2d2036..79a3a7d3702ad29cb3b371ee2e3cf65e3acc7db8 100644 (file)
@@ -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)))
index 91f0c445eed059b5cc6ed9b40eb570cbf1e940bc..75a869b3399795468a956aa087d1b96d77b9056e 100644 (file)
@@ -123,14 +123,17 @@ cat <<EOF
 
   if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     {
+      UHI off16;
+      USI imm32;
+
       /* eBPF instructions are little-endian, but GETIMEMUDI reads according
          to target byte order. Swap to little-endian. */
       insn = SWAP_8 (insn);
 
       /* But, the imm32 and offset16 fields within instructions follow target
          byte order. Swap those fields back. */
-      UHI off16 = (UHI) ((insn & 0x00000000ffff0000) >> 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);