]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
opcodes: tic4x_disassemble swap xcalloc arguments
authorMark Wielaard <mark@klomp.org>
Sun, 21 Jan 2024 20:51:26 +0000 (21:51 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 22 Jan 2024 17:16:42 +0000 (18:16 +0100)
GCC 14 will detect when the size and count arguments of calloc are
swapped.

binutils-gdb/opcodes/tic4x-dis.c: In function ‘tic4x_disassemble’:
binutils-gdb/opcodes/tic4x-dis.c:710:32: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  710 |       optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE));
      |                                ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:710:32: note: earlier argument should specify number of elements, later size of each element
binutils-gdb/opcodes/tic4x-dis.c:712:40: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  712 |       optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE);
      |                                        ^~~~~~~~~~~~
binutils-gdb/opcodes/tic4x-dis.c:712:40: note: earlier argument should specify number of elements, later size of each element

opcodes/ChangeLog:

* /tic4x-dis.c (tic4x_disassemble): Swap size and count xcalloc
arguments.

opcodes/tic4x-dis.c

index 49de510981b2bfbd9b3b4cef1551ec9d0b637302..0c703ecf08a2c3f933dcc8718543006e2a7be395 100644 (file)
@@ -707,9 +707,9 @@ tic4x_disassemble (unsigned long pc,
 
   if (optab == NULL)
     {
-      optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE));
+      optab = xcalloc ((1 << TIC4X_HASH_SIZE), sizeof (tic4x_inst_t *));
 
-      optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE);
+      optab_special = xcalloc (TIC4X_SPESOP_SIZE, sizeof (tic4x_inst_t *));
 
       /* Install opcodes in reverse order so that preferred
         forms overwrite synonyms.  */