forked from Imagelibrary/binutils-gdb
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user