Introduce strtoll/strtoull
Subsystems (3)
cover Introduce strtoll/strtoull
A recent posting by Daniele Ahmed inspired me to write a patch adding strtoll/strtoull. While doing that I noticed check_mul_overflow wasn't working and found copy+paste errors with it and check_sub_overflow.
Andrew Jones (2):
compiler.h: Fix typos in mul and sub overflow checks
lib: Introduce strtoll/strtoull
lib/linux/compiler.h | 4 ++-- lib/stdlib.h | 2 ++ lib/string.c | 51 ++++++++++++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 16 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 compiler.h: Fix typos in mul and sub overflow checks
--- lib/linux/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/linux/compiler.h +2 -2
@@ -33,8 +33,8 @@#elif GCC_VERSION >=70100 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1#define check_add_overflow (a, b) __builtin_add_overflow_p(a, b, (typeof((a) + (b)))0) -#define check_sub_overflow (a, b) __builtin_add_overflow_p(a, b, (typeof((a) - (b)))0) -#define check_mul_overflow (a, b) __builtin_add_overflow_p(a, b, (typeof((a) * (b)))0) +#define check_sub_overflow (a, b) __builtin_sub_overflow_p(a, b, (typeof((a) - (b)))0) +#define check_mul_overflow (a, b) __builtin_mul_overflow_p(a, b, (typeof((a) * (b)))0)#else #define check_add_overflow (a, b) ({ (void)((int)(a) == (int)(b)); 0; })#define check_sub_overflow (a, b) ({ (void)((int)(a) == (int)(b)); 0; })
Signature · 1 line
2.31.1
Re: [PATCH kvm-unit-tests 1/2] compiler.h: Fix typos in mul and sub overflow checks
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
PATCH 2/2 lib: Introduce strtoll/strtoull
In reply to Andrew Jones--- lib/stdlib.h | 2 ++ lib/string.c | 51 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 14 deletions(-)
lib/stdlib.h +2 -0
@@ -9,5 +9,7 @@long int strtol (const char *nptr,char **endptr,int base);unsigned long int strtoul (const char *nptr,char **endptr,int base); +long long int strtoll (const char *nptr,char **endptr,int base); +unsigned long long int strtoull (const char *nptr,char **endptr,int base);#endif /* _STDLIB_H_ */
lib/string.c +37 -14
82 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH kvm-unit-tests 2/2] lib: Introduce strtoll/strtoull
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Quoted 4 lines · Andrew Jones
A recent posting by Daniele Ahmed inspired me to write a patch adding strtoll/strtoull. While doing that I noticed
check_mul_overflowwasn't working and found copy+paste errors with it andcheck_sub_overflow.
Quoted 9 lines
Andrew Jones (2):
compiler.h: Fix typos in mul and sub overflow checks
lib: Introduce strtoll/strtoulllib/linux/compiler.h | 4 ++-- lib/stdlib.h | 2 ++ lib/string.c | 51 ++++++++++++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 16 deletions(-)
Queued, thanks.
Paolo