libsframe: Fix calloc argument order in dump_sframe_header

Message ID 20240121231621.576801-1-mark@klomp.org
State Unresolved
Headers
Series libsframe: Fix calloc argument order in dump_sframe_header |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Mark Wielaard Jan. 21, 2024, 11:16 p.m. UTC
  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(-)
  

Comments

Nick Clifton Jan. 22, 2024, 5:15 p.m. UTC | #1
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
  

Patch

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)