kstrtox: delete end-of-string test
PATCH 1/2 kstrtox: delete end-of-string test
Standard "while (*s)" test is unnecessary because NUL won't pass valid-digit test anyway. Save one branch per parsed character.
Signed-off-by Alexey Dobriyan <[email protected]>
---
lib/kstrtox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kstrtox.c +1 -1
@@ -51,7 +51,7 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long res =0 ; rv =0 ; -while (*s) { +while (1 ) {unsigned int val;if ('0' <= *s && *s <='9' )
lib/kstrtox.c unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long · line 54
Quoted 5 lines · Alexey Dobriyan
Standard "while (*s)" test is unnecessary because NUL won't pass valid-digit test anyway. Save one branch per parsed character.
lib/kstrtox.c +1
-1-while (*s) { +while (1 ) {
In such cases I prefer
do {} while ();
Since it makes easier to reader to catch that the loop is going at least once (and less error prone (1) vs. (l) depending on font in use).
...however, I see that patch is already applied.
Signature · 2 lines
With Best Regards, Andy Shevchenko