diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-06-26 22:05:04 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-06-27 10:37:37 -0400 |
commit | 44e88cd631202e0878ea39f34a8de252d7dd528b (patch) | |
tree | 6e9071cebe98b43aea7b94b6c531a1613a2c51fd /sim | |
parent | cc9c19b0302a83be6520c38a0a9944314ccc6962 (diff) | |
download | gdb-44e88cd631202e0878ea39f34a8de252d7dd528b.zip gdb-44e88cd631202e0878ea39f34a8de252d7dd528b.tar.gz gdb-44e88cd631202e0878ea39f34a8de252d7dd528b.tar.bz2 |
sim: bpf: add explicit casts when using explicit formats
Since the value variable usually has an incompatible type for the wide
variety of types it is printed as, add explicit casts to them all.
Diffstat (limited to 'sim')
-rw-r--r-- | sim/bpf/ChangeLog | 4 | ||||
-rw-r--r-- | sim/bpf/bpf-helpers.c | 24 |
2 files changed, 16 insertions, 12 deletions
diff --git a/sim/bpf/ChangeLog b/sim/bpf/ChangeLog index 7c48d28..b53b986 100644 --- a/sim/bpf/ChangeLog +++ b/sim/bpf/ChangeLog @@ -1,5 +1,9 @@ 2021-06-27 Mike Frysinger <vapier@gentoo.org> + * bpf-helpers.c (bpf_trace_printk): Add casts to every value printf. + +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. diff --git a/sim/bpf/bpf-helpers.c b/sim/bpf/bpf-helpers.c index 79a3a7d..d72c22a 100644 --- a/sim/bpf/bpf-helpers.c +++ b/sim/bpf/bpf-helpers.c @@ -95,16 +95,16 @@ bpf_trace_printk (SIM_CPU *current_cpu) fmt_address + i))) { case 'd': - trace_printf (sd, current_cpu, "%d", value); + trace_printf (sd, current_cpu, "%d", (int) value); break; case 'i': - trace_printf (sd, current_cpu, "%i", value); + trace_printf (sd, current_cpu, "%i", (int) value); break; case 'u': - trace_printf (sd, current_cpu, "%u", value); + trace_printf (sd, current_cpu, "%u", (unsigned int) value); break; case 'x': - trace_printf (sd, current_cpu, "%x", value); + trace_printf (sd, current_cpu, "%x", (unsigned int) value); break; case 'l': { @@ -114,16 +114,16 @@ bpf_trace_printk (SIM_CPU *current_cpu) fmt_address + i)) { case 'd': - trace_printf (sd, current_cpu, "%ld", value); + trace_printf (sd, current_cpu, "%ld", (long) value); break; case 'i': - trace_printf (sd, current_cpu, "%li", value); + trace_printf (sd, current_cpu, "%li", (long) value); break; case 'u': - trace_printf (sd, current_cpu, "%lu", value); + trace_printf (sd, current_cpu, "%lu", (unsigned long) value); break; case 'x': - trace_printf (sd, current_cpu, "%lx", value); + trace_printf (sd, current_cpu, "%lx", (unsigned long) value); break; case 'l': { @@ -132,16 +132,16 @@ bpf_trace_printk (SIM_CPU *current_cpu) switch (GETMEMUQI (current_cpu, CPU_PC_GET (current_cpu), fmt_address + i)) { case 'd': - trace_printf (sd, current_cpu, "%lld", value); + trace_printf (sd, current_cpu, "%lld", (long long) value); break; case 'i': - trace_printf (sd, current_cpu, "%lli", value); + trace_printf (sd, current_cpu, "%lli", (long long) value); break; case 'u': - trace_printf (sd, current_cpu, "%llu", value); + trace_printf (sd, current_cpu, "%llu", (unsigned long long) value); break; case 'x': - trace_printf (sd, current_cpu, "%llx", value); + trace_printf (sd, current_cpu, "%llx", (unsigned long long) value); break; default: assert (0); |