public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libsframe: replace an strncat with strcat
@ 2023-01-10 18:27 Indu Bhagat
  0 siblings, 0 replies; only message in thread
From: Indu Bhagat @ 2023-01-10 18:27 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Hello,

I noticed the following warning on s390x builds, which drew my attention to the
code in dump_sframe_func_with_fres:

   ../../binutils-gdb/libsframe/sframe-dump.c:180:7: warning: ‘strncat’ output
   truncated before terminating nul copying 3 bytes from a string of the same
   length [-Wstringop-truncation] 

I think using strcat is just as fine here.

Thanks,
Indu

----------------------------------

Calling strncat with the size of the src string is not so meaningful.
The length argument to strncat should specify the remaining bytes
bytes in the destination; although in this case, it appears to be
unncessary altogether to use strncat in the first place.

libsframe/
        * sframe-dump.c (dump_sframe_func_with_fres): Use of strcat is
	just as fine.
---
 libsframe/sframe-dump.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 320555a0a51..5417a16f48c 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -176,8 +176,7 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
       const char *ra_mangled_p_str
 	= ((sframe_fre_get_ra_mangled_p (sfd_ctx, &fre, &err[2]))
 	   ? "[s]" : "   ");
-      size_t ra_mangled_p_str_size = strlen (ra_mangled_p_str);
-      strncat (temp, ra_mangled_p_str, ra_mangled_p_str_size);
+      strcat (temp, ra_mangled_p_str);
       printf ("%-13s", temp);
     }
 }
-- 
2.37.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-10 18:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 18:27 [PATCH] libsframe: replace an strncat with strcat Indu Bhagat

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