diff options
author | Alan Modra <amodra@gmail.com> | 2023-08-03 12:32:40 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-08-03 21:20:33 +0930 |
commit | ad923ded82d0ede5a2506a9fbd0f5a5a6728e1a6 (patch) | |
tree | 60fc72cb334c014f1aed431154cf8f35d224135e /binutils/size.c | |
parent | 75747be51e6d11287e12c4504f2607d36a0edfd2 (diff) | |
download | fsf-binutils-gdb-ad923ded82d0ede5a2506a9fbd0f5a5a6728e1a6.zip fsf-binutils-gdb-ad923ded82d0ede5a2506a9fbd0f5a5a6728e1a6.tar.gz fsf-binutils-gdb-ad923ded82d0ede5a2506a9fbd0f5a5a6728e1a6.tar.bz2 |
binutils sprintf optimisation
Avoid the use of sprintf with a "%s" format string, replacing with
strcpy or stpcpy. Use sprintf return value rather than a later
strlen. Don't use strcat where we can keep track of the end of a
string output buffer.
* dlltool.c (look_for_prog): memcpy prefix and strcpy prog_name.
* dllwrap.c (look_for_prog): Likewise.
* resrc.c (look_for_default): Likewise. Add quotes with memmove
rather than allocating another buffer.
* size.c (size_number): Use sprintf return value.
* stabs.c (parse_stab_argtypes): Likewise.
* windmc.c (write_bin): Likewes, and use stpcpy.
* wrstabs.c: Similarly throughout.
Diffstat (limited to 'binutils/size.c')
-rw-r--r-- | binutils/size.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/binutils/size.c b/binutils/size.c index 9473897..243c740 100644 --- a/binutils/size.c +++ b/binutils/size.c @@ -441,11 +441,9 @@ size_number (bfd_size_type num) { char buffer[40]; - sprintf (buffer, (radix == decimal ? "%" PRIu64 - : radix == octal ? "0%" PRIo64 : "0x%" PRIx64), - (uint64_t) num); - - return strlen (buffer); + return sprintf (buffer, (radix == decimal ? "%" PRIu64 + : radix == octal ? "0%" PRIo64 : "0x%" PRIx64), + (uint64_t) num); } static void |