From patchwork Sun Jan 21 23:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 189860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2284946dyb; Sun, 21 Jan 2024 15:50:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvgxgNKQ0CTjHVhXBwon3go5ONOREcfXt0UOVhwZNVgDV0AcdcJwua9/iHyE980T0NICgR X-Received: by 2002:ad4:5ecc:0:b0:685:810d:d034 with SMTP id jm12-20020ad45ecc000000b00685810dd034mr4212397qvb.2.1705881052299; Sun, 21 Jan 2024 15:50:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705881052; cv=pass; d=google.com; s=arc-20160816; b=A23HZwhKXHuSIxl/7c9bfNzfbVkkiXJworeeTOBeb5TJDLaOT55Hs9UZ6i58dFZZ2N U5KJkO5qlOZa7BblTp85EuPNVv3HEAvwvDlgBrQ4KydvJglgw+iCrQq4V6oj2xX9zeqQ yLCFajvfDdtA6DT520vSVrErnrxTyDWB7i1TAoYsp/gq9jNmAD9B6k+/bWJTBl0Ttin7 eWfabLTvWZWe4uX0otGJMc7sEdoJXlunHmpaBJVWCLKekMzbJKW3bMmjxSyDrpcdfbRr Bw78En8LZ1dTRzwFbdLAdfCCjqrSdzPbFsSg3O5UMOj0BfD3cf13oszXSo8q17FQHUzy Oosg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=FiZdBpIdC61ulQLzh8AgnBRVISxm0c4HPfXQpBnjU/I=; fh=dJd+3NRnVFvBaW/IXi0G9kHIpwH/063mGZ1m5fE8wt8=; b=EqJu0FFdTvKMr9OrgP6q/vU3beRhUr0moi/q7jBdjtYUoE5FdbOfTCCpAxctT7yMaJ DQSENXN+YMZDZELRb41Lch2f3DZ/9TBjio/nPKP44xVgx7auBo2IOy6tceTB6yf5vvw4 cHpcvtktlUUWf6nrk+iPfmFxatEzfBdPO6mpwH0BcTxAXEos4uylJC3/SE6KVUyNv1rH BeSA+u1HvB5xrGBFNnP8G4SSg+zCCAj2DB0OoUfPmhY0YI2fSfL7xONdUh/0zYee9Ued 10cIi++OqAxAVIt/gSHDIPGZrzHFXuE++8U5JkN6YZBLwzPT3JZwCXjKWhkf1v776FIM yMGA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s16-20020a0ce310000000b00681b43d8d41si4503448qvl.34.2024.01.21.15.50.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 15:50:52 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09FFD385841E for ; Sun, 21 Jan 2024 23:50:52 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788745930507148991 X-GMAIL-MSGID: 1788745930507148991 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. */