diff options
Diffstat (limited to 'lib/kstrtox.c')
-rw-r--r-- | lib/kstrtox.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index d8a5cf66c316..b8e2080c1a47 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -48,11 +48,9 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long | |||
48 | { | 48 | { |
49 | unsigned long long res; | 49 | unsigned long long res; |
50 | unsigned int rv; | 50 | unsigned int rv; |
51 | int overflow; | ||
52 | 51 | ||
53 | res = 0; | 52 | res = 0; |
54 | rv = 0; | 53 | rv = 0; |
55 | overflow = 0; | ||
56 | while (*s) { | 54 | while (*s) { |
57 | unsigned int val; | 55 | unsigned int val; |
58 | 56 | ||
@@ -71,15 +69,13 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long | |||
71 | */ | 69 | */ |
72 | if (unlikely(res & (~0ull << 60))) { | 70 | if (unlikely(res & (~0ull << 60))) { |
73 | if (res > div_u64(ULLONG_MAX - val, base)) | 71 | if (res > div_u64(ULLONG_MAX - val, base)) |
74 | overflow = 1; | 72 | rv |= KSTRTOX_OVERFLOW; |
75 | } | 73 | } |
76 | res = res * base + val; | 74 | res = res * base + val; |
77 | rv++; | 75 | rv++; |
78 | s++; | 76 | s++; |
79 | } | 77 | } |
80 | *p = res; | 78 | *p = res; |
81 | if (overflow) | ||
82 | rv |= KSTRTOX_OVERFLOW; | ||
83 | return rv; | 79 | return rv; |
84 | } | 80 | } |
85 | 81 | ||