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.
This commit is contained in:
Alan Modra
2023-08-03 12:32:40 +09:30
parent 75747be51e
commit ad923ded82
7 changed files with 67 additions and 69 deletions

View File

@@ -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