sim: ppc: clean up various warnings
authorMike Frysinger <vapier@gentoo.org>
Sat, 15 May 2021 14:48:02 +0000 (10:48 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 15 May 2021 15:00:00 +0000 (11:00 -0400)
A random grab bag of minor fixes to enable -Werror for this port.

Cast address vars to long when the format was using %l.
Use %zu with sizeof operations.
Add const to a bunch of strings.
Trim unused variables.
Fix sizeof call to calculate target storage and not the pointer itself.

22 files changed:
sim/ppc/ChangeLog
sim/ppc/Makefile.in
sim/ppc/configure
sim/ppc/configure.ac
sim/ppc/device.c
sim/ppc/emul_chirp.c
sim/ppc/hw_glue.c
sim/ppc/hw_ide.c
sim/ppc/hw_init.c
sim/ppc/hw_phb.c
sim/ppc/hw_shm.c
sim/ppc/igen.c
sim/ppc/interrupts.c
sim/ppc/ld-insn.c
sim/ppc/main.c
sim/ppc/options.c
sim/ppc/ppc-instructions
sim/ppc/psim.c
sim/ppc/psim.h
sim/ppc/tree.c
sim/ppc/vm.c
sim/ppc/vm_n.h

index e1ed6d624afbc8aa250139188b22ec09f1e6d7ba..42db5f26857ee95731ed1593d3887aea1d7ff0f5 100644 (file)
@@ -1,3 +1,39 @@
+2021-05-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * Makefile.in (WERROR_CFLAGS): Define.
+       (STD_CFLAGS): Add $(WERROR_CFLAGS).
+       * configure.ac: Add --enable-werror.
+       * device.c (device_full_name): Delete full_name variable.
+       (device_clean): Delete system variable.
+       * emul_chirp.c (chirp_emul_getprop): Cast vars to unsigned long.
+       (chirp_emul_seek): Likewise.
+       * hw_glue.c (hw_glue_init_address): Use %zu format.
+       * hw_ide.c (hw_ide_io_read_buffer): Cast vars to unsigned long.
+       (hw_ide_io_write_buffer): Likewise.
+       * hw_init.c (update_for_binary_section): Cast vars to unsigned long.
+       * hw_phb.c (hw_phb_dma_read_buffer): Likewise.
+       (hw_phb_dma_write_buffer): Likewise.
+       * hw_shm.c (hw_shm_init_data): Delete d variable.
+       (hw_shm_attach_address_callback): Delete shm variable.
+       * igen.c (gen_semantics_c): Include tree.h.
+       * interrupts.c (alignment_interrupt): Cast vars to unsigned long.
+       * ld-insn.c (dump_insn_field): Cast vars to unsigned long.
+       * main.c (main): Add const to argv.
+       * options.c (print_options): Cast var to int.
+       * ppc-instructions: Add %s to format.  Delete shifted variable.  Add
+       parenthesis to binary operations.
+       * psim.c (find_arg): Add const to return and argv.
+       (is_num): Add const to string.
+       (psim_options): Add const to return and argv, and p & param.
+       (psim_command): Add const to argv, device, and media.
+       (psim_stack): Add const to argv and envp.
+       * psim.h: Add const to psim_options, psim_command, and psim_stack.
+       * tree.c (parse_reg_property): Delete & from sizeof.
+       * vm.c (om_virtual_to_real): Const vars to long.
+       * vm_n.h (vm_data_map_read_N): Change format to %zu.
+       (vm_data_map_write_N): Likewise.
+       * configure: Regenerate.
+
 2021-05-14  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in: Update path.
index 63b957d1b4fc3d1333f71b0031024e8bde41d365..9fc864e677af9ad8aa260f19d20f02632ba7aa18 100644 (file)
@@ -64,6 +64,7 @@ AR = @AR@
 AR_FLAGS = rc
 CC = @CC@
 CFLAGS = @CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
 CC_FOR_BUILD = @CC_FOR_BUILD@
 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
 BISON = bison
@@ -103,7 +104,7 @@ CONFIG_CFLAGS = \
   $(DEVZERO_CFLAGS)
 SIM_FPU_CFLAGS = @sim_fpu_cflags@
 
-STD_CFLAGS     = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(INCLUDES) $(INTL_CFLAGS) $(SIM_FPU_CFLAGS)
+STD_CFLAGS     = $(CFLAGS) $(WERROR_CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(INCLUDES) $(INTL_CFLAGS) $(SIM_FPU_CFLAGS)
 NOWARN_CFLAGS  = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(INCLUDES) $(SIM_FPU_CFLAGS)
 BUILD_CFLAGS   = $(CFLAGS_FOR_BUILD) $(INCLUDES) $(WARNING_CFLAGS)
 
index 3de2ba81a82e25c196e7e6e123bd2d73f15abeef..235595b7b2c464433e79341a5b5f072b82a18503 100755 (executable)
@@ -678,6 +678,7 @@ build
 REPORT_BUGS_TEXI
 REPORT_BUGS_TO
 PKGVERSION
+WERROR_CFLAGS
 EGREP
 GREP
 CPP
@@ -773,6 +774,7 @@ enable_sim_stdio
 enable_sim_switch
 enable_sim_timebase
 enable_sim_trace
+enable_werror
 enable_sim_warnings
 enable_sim_xor_endian
 with_pkgversion
@@ -1435,6 +1437,7 @@ Optional Features:
   --enable-sim-switch                  Use a switch instead of a table for instruction call.
   --enable-sim-timebase                        Specify whether the PPC timebase is supported.
   --enable-sim-trace                   Specify whether tracing is supported.
+  --enable-werror         treat compile warnings as errors
   --enable-sim-warnings=opts           Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o
   --enable-sim-xor-endian=n            Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).
   --enable-plugins        Enable support for plugins
@@ -4758,6 +4761,25 @@ _ACEOF
 $as_echo "$sim_trace" >&6; }
 
 
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+  enableval=$enable_werror; case "${enableval}" in
+     yes | y) ERROR_ON_WARNING="yes" ;;
+     no | n)  ERROR_ON_WARNING="no" ;;
+     *) as_fn_error $? "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;;
+   esac
+fi
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+  ERROR_ON_WARNING=yes
+fi
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+  WERROR_CFLAGS="-Werror"
+fi
+
+
 # Check whether --enable-sim-warnings was given.
 if test "${enable_sim_warnings+set}" = set; then :
   enableval=$enable_sim_warnings; case "${enableval}" in
index 6482fbab1d745cf2cb3a8749c8281519a0c1a281..21913a913294e3594ebbc874d5eab563b7f178e9 100644 (file)
@@ -587,6 +587,23 @@ AC_DEFINE_UNQUOTED([WITH_TRACE], [$sim_trace], [Sim trace settings])
 AC_MSG_RESULT($sim_trace)
 
 
+AC_ARG_ENABLE(werror,
+  AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
+  [case "${enableval}" in
+     yes | y) ERROR_ON_WARNING="yes" ;;
+     no | n)  ERROR_ON_WARNING="no" ;;
+     *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
+   esac])
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+  ERROR_ON_WARNING=yes
+fi
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+  WERROR_CFLAGS="-Werror"
+fi
+AC_SUBST(WERROR_CFLAGS)
+
 AC_ARG_ENABLE(sim-warnings,
 [  --enable-sim-warnings=opts          Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
 [case "${enableval}" in
index 6a0209e5ce693d722dd6bdf56e9c7c835b816dcf..4abef6f9e23403712a9b3135794669b449ddff49 100644 (file)
@@ -180,10 +180,9 @@ device_full_name(device *leaf,
                  unsigned sizeof_buf)
 {
   /* get a buffer */
-  char full_name[1024];
-  if (buf == (char*)0) {
-    buf = full_name;
-    sizeof_buf = sizeof(full_name);
+  if (buf == NULL) {
+    sizeof_buf = 1024;
+    buf = malloc(sizeof_buf);
   }
 
   /* construct a name */
@@ -211,9 +210,6 @@ device_full_name(device *leaf,
     strcat (buf, unit);
   }
   
-  /* return it usefully */
-  if (buf == full_name)
-    buf = (char *) strdup(full_name);
   return buf;
 }
 
@@ -1915,8 +1911,6 @@ INLINE_DEVICE\
 device_clean(device *me,
             void *data)
 {
-  psim *system;
-  system = (psim*)data;
   TRACE(trace_device_init, ("device_clean - initializing %s", me->path));
   clean_device_interrupt_edges(&me->interrupt_destinations);
   clean_device_instances(me);
index d4214f51b9711b8eb781964d583b8a6d9a40afbb..ed49169cc2385ea9cf01f4b46735a744162b937f 100644 (file)
@@ -533,7 +533,7 @@ chirp_emul_getprop(os_emul_data *data,
        break;
       case ihandle_property:
        TRACE(trace_os_emul, ("getprop - ihandle=0x%lx(0x%lx`%s')\n",
-                             BE2H_cell(*(unsigned_cell*)prop->array),
+                             (unsigned long)BE2H_cell(*(unsigned_cell*)prop->array),
                              (unsigned long)device_find_ihandle_property(phandle, name),
                              ihandle_name(device_find_ihandle_property(phandle, name))));
        break;
@@ -1143,7 +1143,8 @@ chirp_emul_seek(os_emul_data *data,
                        (unsigned long)args.ihandle,
                        (unsigned long)ihandle,
                        ihandle_name(ihandle),
-                       args.pos_hi, args.pos_lo));
+                       (unsigned long)args.pos_hi,
+                       (unsigned long)args.pos_lo));
   if (ihandle == NULL) {
     /* OpenFirmware doesn't define this error */
     error("chirp: invalid ihandle passed to seek method");
index c824773393074843ad5c51f1a1124d8f5d50f29f..2af2434b5c3412d13aca664e46f59345324134dc 100644 (file)
@@ -193,13 +193,13 @@ hw_glue_init_address(device *me)
     if (glue->sizeof_output == 0)
       device_error(me, "at least one reg property size must be nonzero");
     if (glue->sizeof_output % sizeof(unsigned_word) != 0)
-      device_error(me, "reg property size must be %d aligned", sizeof(unsigned_word));
+      device_error(me, "reg property size must be %zu aligned", sizeof(unsigned_word));
     /* and the address */
     device_address_to_attach_address(device_parent(me),
                                     &unit.address, &glue->space, &glue->address,
                                     me);
     if (glue->address % (sizeof(unsigned_word) * max_nr_interrupts) != 0)
-      device_error(me, "reg property address must be %d aligned",
+      device_error(me, "reg property address must be %zu aligned",
                   sizeof(unsigned_word) * max_nr_interrupts);
     glue->nr_outputs = glue->sizeof_output / sizeof(unsigned_word);
     glue->output = zalloc(glue->sizeof_output);
index 9d3a7118b71f3f7677f713d72f7debb47d29da9e..6c5e05163ba1bac22d64cf4b9ddb6781b6bab209 100644 (file)
@@ -766,7 +766,7 @@ hw_ide_io_read_buffer(device *me,
     *(unsigned8*)dest = controller->reg[reg];
     break;
   default:
-    device_error(me, "bus-error at address 0x%lx", addr);
+    device_error(me, "bus-error at address 0x%lx", (unsigned long)addr);
     break;
   }
   return nr_bytes;
@@ -820,7 +820,7 @@ hw_ide_io_write_buffer(device *me,
     controller->reg[reg] = *(unsigned8*)source;
     break;
   default:
-    device_error(me, "bus-error at 0x%lx", addr);
+    device_error(me, "bus-error at 0x%lx", (unsigned long)addr);
     break;
   }
   return nr_bytes;
index 779c95c5a24ce3a3112c2b67c348fef718a304c0..e46643c9b49b186880a9154ee314a176f42386e7 100644 (file)
@@ -369,8 +369,8 @@ update_for_binary_section(bfd *abfd,
     mem_in[2] = section_vma;
     if (device_instance_call_method(memory, "claim", 3, mem_in, 1, mem_out) < 0)
       device_error(me, "failed to claim memory for section at 0x%lx (0x%lx",
-                  section_vma,
-                  section_size);
+                  (unsigned long)section_vma,
+                  (unsigned long)section_size);
     if (mem_out[0] != section_vma)
       device_error(me, "section address not as requested");
   }
index 08defc2868ca81275c3bb3cffb169d4ee0e793bb..70d59d3084494cf0d3649ec7d358f486e78eba52 100644 (file)
@@ -967,7 +967,7 @@ hw_phb_dma_read_buffer(device *me,
     device_error(me, "Do not support DMA into own bus");
   /* do it */
   DTRACE(phb, ("dma read - %s:0x%lx (%d bytes)\n",
-              pci_space->name, addr, nr_bytes));
+              pci_space->name, (unsigned long)addr, nr_bytes));
   return device_dma_read_buffer(device_parent(me),
                                dest, pci_space->parent_space,
                                addr, nr_bytes);
@@ -996,7 +996,7 @@ hw_phb_dma_write_buffer(device *me,
     device_error(me, "Do not support DMA into own bus");
   /* do it */
   DTRACE(phb, ("dma write - %s:0x%lx (%d bytes)\n",
-              pci_space->name, addr, nr_bytes));
+              pci_space->name, (unsigned long)addr, nr_bytes));
   return device_dma_write_buffer(device_parent(me),
                                 source, pci_space->parent_space,
                                 addr, nr_bytes,
index f2fa144244acd874a02c21312c6a7d50e80ddbbe..c4d5cae8345342dae12be0bd0744bd270bd013c5 100644 (file)
@@ -89,7 +89,6 @@ static void
 hw_shm_init_data(device *me)
 {
   hw_shm_device *shm = (hw_shm_device*)device_data(me);
-  const device_unit *d;
   reg_property_spec reg;
   int i;
 
@@ -147,8 +146,6 @@ hw_shm_attach_address_callback(device *me,
                                access_type access,
                                device *client) /*callback/default*/
 {
-  hw_shm_device *shm = (hw_shm_device*)device_data(me);
-
   if (space != 0)
     error("shm_attach_address_callback() invalid address space\n");
 
index c036f049aefb3b9052e23f93a5f39f40b184ea0b..0bf3b58ca26d4b3e3dae66656b239c1f88f2926a 100644 (file)
@@ -218,6 +218,7 @@ gen_semantics_c(insn_table *table,
     lf_printf(file, "#include \"cpu.h\"\n");
     lf_printf(file, "#include \"idecode.h\"\n");
     lf_printf(file, "#include \"semantics.h\"\n");
+    lf_printf(file, "#include \"tree.h\"\n");
     lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
     lf_printf(file, "#include \"sim-inline.h\"\n");
     lf_printf(file, "#include \"sim-fpu.h\"\n");
index db100fd26b9aa77793e900d68827d054b1597b57..133638fdcafd7b53c19bb75080119b4d15c657b9 100644 (file)
@@ -262,7 +262,7 @@ alignment_interrupt(cpu *processor,
 
   case USER_ENVIRONMENT:
   case VIRTUAL_ENVIRONMENT:
-    cpu_error(processor, cia, "alignment interrupt - ra=0x%lx", ra);
+    cpu_error(processor, cia, "alignment interrupt - ra=0x%lx", (unsigned long)ra);
     
   case OPERATING_ENVIRONMENT:
     DAR = (spreg)ra;
index 585071a861ff95aaedcce05ad853ca1d50799375..126fc78037b7ecfd01b7a954b9a70975964ee072 100644 (file)
@@ -828,7 +828,7 @@ dump_insn_field(insn_field *field,
                int indent)
 {
 
-  printf("(insn_field*)0x%x\n", (unsigned)field);
+  printf("(insn_field*)0x%lx\n", (unsigned long)field);
 
   dumpf(indent, "(first %d)\n", field->first);
 
index f3f2e9ef338fdadb82023388ff0639b2253c4410..0c1a070fc2c22dd1a402f3c2566d3dca5bd03288 100644 (file)
@@ -251,7 +251,7 @@ cntrl_c(int sig)
 
 
 int
-main(int argc, char **argv)
+main(int argc, char * const *argv)
 {
   const char *name_of_file;
   char *arg_;
index ddb492f54fb7095ef2d1952da56a700e9f76de39..e327187b37565c305bd8896274366cbdefe89be6 100644 (file)
@@ -233,7 +233,7 @@ print_options (void)
                       (((i == ARRAY_SIZE (defines) - 1)
                         || (((i + 1) % cols) == 0))
                        ? 0
-                       : max_len + 4 - strlen (defines[i])),
+                       : max_len + 4 - (int)strlen (defines[i])),
                       "");
     }
     printf_filtered ("\n");
index 9f9773477f772e72577ce3527ee3a6a4c1ee46e1..70aa04e2210ee17fcf80905d1b2767de81f6c13b 100644 (file)
@@ -331,7 +331,7 @@ void::model-static::model_trace_release:model_data *model_ptr, model_busy *busy
          }
        }
        if (busy->vscr_busy)
-         TRACE(trace_model, ("VSCR Register is now available.\n", spr_name(busy->spr_busy)));
+         TRACE(trace_model, ("VSCR Register %s is now available.\n", spr_name(busy->spr_busy)));
 
 # Trace making registers busy
 void::model-static::model_trace_make_busy:model_data *model_ptr, unsigned32 int_mask, unsigned32 fp_mask, unsigned32 cr_mask
@@ -3315,7 +3315,6 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
        unsigned64 mask;
        int n = MASKED(*rB, 59, 63);
        signed32 source = (signed32)*rS; /* signed to keep sign bit */
-       signed32 shifted = source >> n;
        int S = (MASKED(*rS,32,32) != 0);
        signed64 r = ((unsigned64) source);
        r = ((unsigned64) source) << 32 | (unsigned32) source;
@@ -3324,7 +3323,7 @@ void::function::invalid_zero_divide_operation:cpu *processor, unsigned_word cia,
                mask = (unsigned64) MASK64(n+32,63);
        else
                mask = (unsigned64) 0;
-       *rA = (signed_word) (r & mask | ((signed64) -1*S) & ~mask); /* if 64bit will sign extend */
+       *rA = (signed_word) ((r & mask) | (((signed64) -1*S) & ~mask)); /* if 64bit will sign extend */
        if (S && (MASKED(r & ~mask,32,63)!=0))
          XER |= xer_carry;
        else
index ebb9cb42737741d656c58a194dd46575b80d04be..70c02f7141d499a10cac83ea00d300306e5175ce 100644 (file)
@@ -93,10 +93,10 @@ psim_tree(void)
 }
 
 STATIC_INLINE_PSIM\
-(char *)
-find_arg(char *err_msg,
+(const char *)
+find_arg(const char *err_msg,
         int *ptr_to_argp,
-        char **argv)
+        char * const *argv)
 {
   *ptr_to_argp += 1;
   if (argv[*ptr_to_argp] == NULL)
@@ -216,7 +216,7 @@ psim_usage (int verbose, int help, SIM_OPEN_KIND kind)
 /* Test "string" for containing a string of digits that form a number
 between "min" and "max".  The return value is the number or "err". */
 static
-int is_num( char *string, int min, int max, int err)
+int is_num(const char *string, int min, int max, int err)
 {
   int result = 0;
 
@@ -236,9 +236,9 @@ int is_num( char *string, int min, int max, int err)
 }
 
 INLINE_PSIM\
-(char **)
+(char * const *)
 psim_options(device *root,
-            char **argv,
+            char * const *argv,
             SIM_OPEN_KIND kind)
 {
   device *current = root;
@@ -247,8 +247,8 @@ psim_options(device *root,
     return NULL;
   argp = 0;
   while (argv[argp] != NULL && argv[argp][0] == '-') {
-    char *p = argv[argp] + 1;
-    char *param;
+    const char *p = argv[argp] + 1;
+    const char *param;
     while (*p != '\0') {
       switch (*p) {
       default:
@@ -395,7 +395,7 @@ psim_options(device *root,
 INLINE_PSIM\
 (void)
 psim_command(device *root,
-            char **argv)
+            char * const *argv)
 {
   int argp = 0;
   if (argv[argp] == NULL) {
@@ -409,8 +409,8 @@ psim_command(device *root,
       trace_option(opt, 1);
   }
   else if (strcmp(*argv, "change-media") == 0) {
-    char *device = find_arg("Missing device name", &argp, argv);
-    char *media = argv[++argp];
+    const char *device = find_arg("Missing device name", &argp, argv);
+    const char *media = argv[++argp];
     device_ioctl(tree_find_device(root, device), NULL, 0,
                 device_ioctl_change_media, media);
   }
@@ -738,8 +738,8 @@ psim_init(psim *system)
 INLINE_PSIM\
 (void)
 psim_stack(psim *system,
-          char **argv,
-          char **envp)
+          char * const *argv,
+          char * const *envp)
 {
   /* pass the stack device the argv/envp and let it work out what to
      do with it */
index c38b03d899477ad1ab0bea6f1c51627b838f22d3..2070cbf7b903e74a090d1b66c5c32c5da0fa8741 100644 (file)
@@ -47,14 +47,14 @@ typedef struct _psim_status {
 extern device *psim_tree
 (void);
 
-extern char **psim_options
+extern char * const *psim_options
 (device *root,
- char **argv,
+ char * const *argv,
  SIM_OPEN_KIND kind);
 
 extern void psim_command
 (device *root,
- char **argv);
+ char * const *argv);
 
 
 extern void psim_merge_device_file
@@ -79,8 +79,8 @@ extern void psim_init
 
 extern void psim_stack
 (psim *system,
- char **argv,
- char **envp);
+ char * const *argv,
+ char * const *envp);
 
 
 /* Run/stop the system */
index a0e0820b4d9514db203fc8f21c4a59e2ec1d2038..5c35d32f3c5cfa691ea7938847f32fdb0a7b6a71 100644 (file)
@@ -528,7 +528,7 @@ parse_reg_property(device *current,
     if (device_nr_size_cells(bus) > 0)
       chp = parse_size(current, bus, chp, &regs[reg_nr].size);
     else
-      memset(&regs[reg_nr].size, 0, sizeof (&regs[reg_nr].size));
+      memset(&regs[reg_nr].size, 0, sizeof (regs[reg_nr].size));
   }
 
   /* create it */
index 8cf4e8fcf53c30a44a42b773f69ce36fad82410d..9562fb6762c0059ac07ba1573b0cfd7b50c280c8 100644 (file)
@@ -627,9 +627,9 @@ om_virtual_to_real(om_map *map,
       TRACE(trace_vm,
            ("ea=0x%lx - htab search %d - htab=0x%lx hash=0x%lx mask=0x%lx pteg=0x%lx\n",
             (long)ea, current_hash,
-            map->real_address_of_page_table,
-            page_hash,
-            map->page_table_hash_mask,
+            (long)map->real_address_of_page_table,
+            (long)page_hash,
+            (long)map->page_table_hash_mask,
             (long)real_address_of_pte_group));
       for (real_address_of_pte_0 = real_address_of_pte_group;
           real_address_of_pte_0 < (real_address_of_pte_group
index 563cd1ca6a1d4661483648abb532839d6d79c4dc..ce1e05059e1f7dc4342c25be8b4fb399a8f7edf2 100644 (file)
@@ -59,7 +59,7 @@ vm_data_map_read_N(vm_data_map *map,
        unsigned_N val;
        if (vm_data_map_read_buffer(map, &val, ea, sizeof(unsigned_N), processor, cia)
            != sizeof(unsigned_N)) {
-         cpu_error(processor, cia, "misaligned %d byte read to 0x%lx failed",
+         cpu_error(processor, cia, "misaligned %zu byte read to 0x%lx failed",
                    sizeof(unsigned_N), (unsigned long)ea);
        }
        val = T2H_N(val);
@@ -107,7 +107,7 @@ vm_data_map_write_N(vm_data_map *map,
        unsigned_N data = H2T_N(val);
        if (vm_data_map_write_buffer(map, &data, ea, sizeof(unsigned_N), 0, processor, cia)
            != sizeof(unsigned_N)) {
-         cpu_error(processor, cia, "misaligned %d byte write to 0x%lx failed",
+         cpu_error(processor, cia, "misaligned %zu byte write to 0x%lx failed",
                    sizeof(unsigned_N), (unsigned long)ea);
        }
        if (WITH_MON & MONITOR_LOAD_STORE_UNIT) {