public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] PPC + ARC: Fix calloc() call
@ 2023-11-21 13:40 Jan-Benedict Glaw
  2023-11-21 13:49 ` Claudiu Zissulescu
  2023-11-21 15:19 ` Peter Bergner
  0 siblings, 2 replies; 3+ messages in thread
From: Jan-Benedict Glaw @ 2023-11-21 13:40 UTC (permalink / raw)
  To: binutils; +Cc: Claudiu Zissulescu, Geoff Keating, Alan Modra, Peter Bergner

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

H!


Recently, -Walloc-size warnings started to kick in. Fix these two
calloc() calls to match the intended usage pattern.

opcodes/ChangeLog:

	* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
	* ppc-dis.c (powerpc_init_dialect): Ditto.

diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index 59b668ff64e..7498e75cee2 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -147,7 +147,7 @@ static bool
 init_arc_disasm_info (struct disassemble_info *info)
 {
   struct arc_disassemble_info *arc_infop
-    = calloc (sizeof (*arc_infop), 1);
+    = calloc (1, sizeof (*arc_infop));
 
   if (arc_infop == NULL)
     return false;
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index d97137d8b71..4d5652ebfeb 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -348,7 +348,7 @@ powerpc_init_dialect (struct disassemble_info *info)
 {
   ppc_cpu_t dialect = 0;
   ppc_cpu_t sticky = 0;
-  struct dis_private *priv = calloc (sizeof (*priv), 1);
+  struct dis_private *priv = calloc (1, sizeof (*priv));
 
   if (priv == NULL)
     return;



Ok to commit?

MfG, JBG

-- 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] PPC + ARC: Fix calloc() call
  2023-11-21 13:40 [PATCH] PPC + ARC: Fix calloc() call Jan-Benedict Glaw
@ 2023-11-21 13:49 ` Claudiu Zissulescu
  2023-11-21 15:19 ` Peter Bergner
  1 sibling, 0 replies; 3+ messages in thread
From: Claudiu Zissulescu @ 2023-11-21 13:49 UTC (permalink / raw)
  To: Jan-Benedict Glaw, binutils; +Cc: Geoff Keating, Alan Modra, Peter Bergner

Hi,

Ok. Please commit it.

Thank you,
Claudiu

-----Original Message-----
From: Jan-Benedict Glaw <jbglaw@lug-owl.de> 
Sent: Tuesday, November 21, 2023 3:40 PM
To: binutils@sourceware.org
Cc: Claudiu Zissulescu <claziss@synopsys.com>; Geoff Keating <geoffk@geoffk.org>; Alan Modra <amodra@gmail.com>; Peter Bergner <bergner@vnet.ibm.com>
Subject: [PATCH] PPC + ARC: Fix calloc() call

H!


Recently, -Walloc-size warnings started to kick in. Fix these two
calloc() calls to match the intended usage pattern.

opcodes/ChangeLog:

	* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
	* ppc-dis.c (powerpc_init_dialect): Ditto.

diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c index 59b668ff64e..7498e75cee2 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -147,7 +147,7 @@ static bool
 init_arc_disasm_info (struct disassemble_info *info)  {
   struct arc_disassemble_info *arc_infop
-    = calloc (sizeof (*arc_infop), 1);
+    = calloc (1, sizeof (*arc_infop));
 
   if (arc_infop == NULL)
     return false;
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c index d97137d8b71..4d5652ebfeb 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -348,7 +348,7 @@ powerpc_init_dialect (struct disassemble_info *info)  {
   ppc_cpu_t dialect = 0;
   ppc_cpu_t sticky = 0;
-  struct dis_private *priv = calloc (sizeof (*priv), 1);
+  struct dis_private *priv = calloc (1, sizeof (*priv));
 
   if (priv == NULL)
     return;



Ok to commit?

MfG, JBG

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PPC + ARC: Fix calloc() call
  2023-11-21 13:40 [PATCH] PPC + ARC: Fix calloc() call Jan-Benedict Glaw
  2023-11-21 13:49 ` Claudiu Zissulescu
@ 2023-11-21 15:19 ` Peter Bergner
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Bergner @ 2023-11-21 15:19 UTC (permalink / raw)
  To: Jan-Benedict Glaw, binutils
  Cc: Claudiu Zissulescu, Geoff Keating, Alan Modra, Peter Bergner

On 11/21/23 7:40 AM, Jan-Benedict Glaw wrote:
> Recently, -Walloc-size warnings started to kick in. Fix these two
> calloc() calls to match the intended usage pattern.
> 
> opcodes/ChangeLog:
> 
> 	* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
> 	* ppc-dis.c (powerpc_init_dialect): Ditto.

Looks obvious to me, but to remove any doubt, the ppc change is ok.
Thanks!

Peter




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-21 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21 13:40 [PATCH] PPC + ARC: Fix calloc() call Jan-Benedict Glaw
2023-11-21 13:49 ` Claudiu Zissulescu
2023-11-21 15:19 ` Peter Bergner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).