Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kstrto*: accept "-0" for signed conversion

strtol(3) et al accept "-0", so should we.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
2d2e4715 3cdea4d7

+2 -6
+1 -1
lib/kstrtox.c
··· 152 152 rv = _kstrtoull(s + 1, base, &tmp); 153 153 if (rv < 0) 154 154 return rv; 155 - if ((long long)(-tmp) >= 0) 155 + if ((long long)-tmp > 0) 156 156 return -ERANGE; 157 157 *res = -tmp; 158 158 } else {
+1 -5
lib/test-kstrtox.c
··· 260 260 {"4294967297", 10, 4294967297LL}, 261 261 {"9223372036854775807", 10, 9223372036854775807LL}, 262 262 263 + {"-0", 10, 0LL}, 263 264 {"-1", 10, -1LL}, 264 265 {"-2", 10, -2LL}, 265 266 {"-9223372036854775808", 10, LLONG_MIN}, ··· 278 277 {"-9223372036854775809", 10}, 279 278 {"-18446744073709551614", 10}, 280 279 {"-18446744073709551615", 10}, 281 - /* negative zero isn't an integer in Linux */ 282 - {"-0", 0}, 283 - {"-0", 8}, 284 - {"-0", 10}, 285 - {"-0", 16}, 286 280 /* sign is first character if any */ 287 281 {"-+1", 0}, 288 282 {"-+1", 8},