]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
binutils: Fix calloc argument order in srconv.c
authorMark Wielaard <mark@klomp.org>
Sun, 21 Jan 2024 23:47:46 +0000 (00:47 +0100)
committerMark Wielaard <mark@klomp.org>
Mon, 22 Jan 2024 17:20:21 +0000 (18:20 +0100)
GCC 14 will warn about calling calloc with swapped size and count
arguments.

binutils/srconv.c: In function ‘nints’:
binutils/srconv.c:598:36: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  598 |   return (int *) (xcalloc (sizeof (int), x));
      |                                    ^~~
binutils/srconv.c:598:36: note: earlier argument should specify number of elements, later size of each element

binutils/

* srconv.c (nints): Swap xcalloc arguments.
(wr_du): Likewise.
(wr_dus): Likewise.

binutils/srconv.c

index 1ff68fa08b07ae475390abca058aadcfa8fd9d04..7e22f7a0d4fdce42ea33d3d5b83a5c5f0d184b43 100644 (file)
@@ -595,7 +595,7 @@ wr_dps_end (struct coff_section *section ATTRIBUTE_UNUSED,
 static int *
 nints (int x)
 {
-  return (int *) (xcalloc (sizeof (int), x));
+  return (int *) (xcalloc (x, sizeof (int)));
 }
 
 static void
@@ -1183,7 +1183,7 @@ wr_du (struct coff_ofile *p, struct coff_sfile *sfile, int n)
   du.spare = 0;
   du.unit = n;
   du.sections = p->nsections - 1;
-  du.san = (int *) xcalloc (sizeof (int), du.sections);
+  du.san = (int *) xcalloc (du.sections, sizeof (int));
   du.address = nints (du.sections);
   du.length = nints (du.sections);
 
@@ -1242,7 +1242,7 @@ wr_dus (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile)
   dus.efn = 0x1001;
   dus.ns = 1;                  /* p->nsources; sac 14 jul 94 */
   dus.drb = nints (dus.ns);
-  dus.fname = (char **) xcalloc (sizeof (char *), dus.ns);
+  dus.fname = (char **) xcalloc (dus.ns, sizeof (char *));
   dus.spare = nints (dus.ns);
   dus.ndir = 0;
   /* Find the filenames.  */