summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-03-27 14:47:09 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-04-10 10:44:31 +0000
commit0de2fa0a622d72d63d64a3d73b4b7ead24380314 (patch)
treeb8d820e3021c60baf65afdd45eb126518cfee476 /payloads/libpayload/include
parent18c1b6b240b675c877b8bd731dfd58f5723d0c57 (diff)
libpayload: Deduplicate strtol and strtoull
Our strtol() and strtoull() function contain almost exactly the same code. This is a) bad in general and b) may cause the code to get out of sync, such as it recently happened with CB:32029. This patch changes strtol() to be based on strtoull() so that the main parsing code exists only once, and also adds a strtoll() to round off the library. Also fix the bounds imposed by strtoul() to be based on the actual length of a 'long', not hardcoded to 32-bits (which is not equivalent on all architectures). Change-Id: I919c65a773cecdb11739c3f22dd0d182ed50c07f Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32086 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/stdlib.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h
index 3f94d2119a..06fb735b75 100644
--- a/payloads/libpayload/include/stdlib.h
+++ b/payloads/libpayload/include/stdlib.h
@@ -186,6 +186,7 @@ static inline void *xmemalign_work(size_t align, size_t size, const char *file,
* @{
*/
long int strtol(const char *s, char **nptr, int base);
+long long int strtoll(const char *s, char **nptr, int base);
unsigned long int strtoul(const char *s, char **nptr, int base);
unsigned long long int strtoull(const char *s, char **nptr, int base);
long atol(const char *nptr);