From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 04DAA3858C56 for ; Sun, 21 Jan 2024 23:50:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04DAA3858C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 04DAA3858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705881042; cv=none; b=Q675I0eh3e2ApYOBwO0BIH77jHS6fiMQL9prt3F4l1GPUK62oC26Xr0jIKDZA9koLrflCZtFhwQv2Fd8bm3Bx3P/xL5qOyKfI8lJuA31V05i2jgqbwY0Wbrx4lV9xaGhgGrRa/nLJ4zq3Fh8OGQMwLQDs+ggYsnENUgSMN5eeOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705881042; c=relaxed/simple; bh=a6PN4uUPr+OXJccTP+C+bl5wimdv2LirnIzIwl8gHlc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=BjUZUFr7Ml1SToCda4dR9YgCx+1SfMbukK6Nwcws9nadlh4PhWNQVLY2Q7usnpOsdsz7JfGSdljjMEmNn5tHMnXm7lCOop138pGj5ktQhLimls/SUW0SEep4BOJF8rQMxdMxRNBZXaoBTpSHCEZkjGWZwLYUk+G3FOpbFjAEWiw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from csb.redhat.com (deer0x03.wildebeest.org [172.31.17.133]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id D299F302BBEA; Mon, 22 Jan 2024 00:50:39 +0100 (CET) Received: by csb.redhat.com (Postfix, from userid 10916) id 76545CEF2C; Mon, 22 Jan 2024 00:50:39 +0100 (CET) From: Mark Wielaard To: binutils@sourceware.org Cc: Mark Wielaard Subject: [PATCH] binutils: Fix calloc argument order in srconv.c Date: Mon, 22 Jan 2024 00:50:38 +0100 Message-Id: <20240121235038.580321-1-mark@klomp.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/binutils/srconv.c b/binutils/srconv.c index 1ff68fa08b0..7e22f7a0d4f 100644 --- a/binutils/srconv.c +++ b/binutils/srconv.c @@ -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. */ -- 2.39.3