aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-08-03 07:59:47 +0930
committerAlan Modra <amodra@gmail.com>2023-08-03 21:19:54 +0930
commitb077a53b2b8e4da725f1563e95b55650d61b47e7 (patch)
tree712e7513e05e136873090815e27e017d54c9782d
parent760fb390fd4ce506abd401e8a75fc0a510b82d48 (diff)
downloadbinutils-b077a53b2b8e4da725f1563e95b55650d61b47e7.zip
binutils-b077a53b2b8e4da725f1563e95b55650d61b47e7.tar.gz
binutils-b077a53b2b8e4da725f1563e95b55650d61b47e7.tar.bz2
cris: sprintf sanitizer null destination pointer
Simplify the sprintf calls, and use sprintf return value. Older code in binutils avoided using the sprintf return count of chars printed, because with some older C libraries it wasn't reliable. Nowadays it should be OK to use (and we already use the return value elsewhere). sprintf can't return an error status of -1 here. * cris-dis.c (format_dec): Avoid sanitizer warning. Use sprintf return value rather than calling strlen.
-rw-r--r--opcodes/cris-dis.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/opcodes/cris-dis.c b/opcodes/cris-dis.c
index b8eaa4b..681fccf 100644
--- a/opcodes/cris-dis.c
+++ b/opcodes/cris-dis.c
@@ -580,12 +580,7 @@ static char *
format_dec (long number, char *outbuffer, int signedp)
{
last_immediate = number;
- if (signedp)
- sprintf (outbuffer, "%ld", number);
- else
- sprintf (outbuffer, "%lu", (unsigned long) number);
-
- return outbuffer + strlen (outbuffer);
+ return outbuffer + sprintf (outbuffer, signedp ? "%ld" : "%lu", number);
}
/* Format the name of the general register regno into outbuffer. */