public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libsframe: Fix calloc argument order in dump_sframe_header
@ 2024-01-21 23:16 Mark Wielaard
  2024-01-22 17:15 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2024-01-21 23:16 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat, Mark Wielaard

GCC14 warns about the order of the arguments to calloc

libsframe/sframe-dump.c: In function ‘dump_sframe_header’:
libsframe/sframe-dump.c:70:39: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
   70 |   flags_str = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
      |                                       ^~~~
libsframe/sframe-dump.c:70:39: note: earlier argument should specify number of elements, later size of each element

Fix this by swapping the size and count arguments.

libsframe/

	* sframe-dump.c (dump_sframe_header): Swap arguments to calloc
---
 libsframe/sframe-dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 0d596918f72..42a086a5691 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -67,7 +67,7 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx)
 
   /* Prepare SFrame section flags string.  */
   flags = header->sfh_preamble.sfp_flags;
-  flags_str = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
+  flags_str = (char*) calloc (SFRAME_HEADER_FLAGS_STR_MAX_LEN, sizeof (char));
   if (flags)
     {
       if (flags & SFRAME_F_FDE_SORTED)
-- 
2.39.3


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

* Re: [PATCH] libsframe: Fix calloc argument order in dump_sframe_header
  2024-01-21 23:16 [PATCH] libsframe: Fix calloc argument order in dump_sframe_header Mark Wielaard
@ 2024-01-22 17:15 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2024-01-22 17:15 UTC (permalink / raw)
  To: Mark Wielaard, binutils; +Cc: Indu Bhagat

Hi Mark,

> GCC14 warns about the order of the arguments to calloc

> libsframe/
> 
> 	* sframe-dump.c (dump_sframe_header): Swap arguments to calloc

Approved - please apply.

Cheers
   Nick



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

end of thread, other threads:[~2024-01-22 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 23:16 [PATCH] libsframe: Fix calloc argument order in dump_sframe_header Mark Wielaard
2024-01-22 17:15 ` Nick Clifton

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).