sim: bpf: add explicit casts when using explicit formats
authorMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 02:05:04 +0000 (22:05 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 27 Jun 2021 14:37:37 +0000 (10:37 -0400)
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.

sim/bpf/ChangeLog
sim/bpf/bpf-helpers.c

index 7c48d289b30f406a340a9abc7c655c8b49a4ff4b..b53b986472d3cb21c7c77d9215dffdc4a1281c09 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 79a3a7d3702ad29cb3b371ee2e3cf65e3acc7db8..d72c22a09beebf309f57748589ae9b771e5af208 100644 (file)
@@ -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);