diff --git a/include/common/standard.h b/include/common/standard.h index 8efda8a4b..a502951ea 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -152,14 +152,14 @@ static inline unsigned int __strl2ui(const char *s, int len) static inline unsigned int __strl2uic(const char *s, int len) { unsigned int i = 0; - unsigned int j; + unsigned int j, k; while (len-- > 0) { j = (*s++) - '0'; - i = i * 10; + k = i * 10; if (j > 9) break; - i += j; + i = k + j; } return i; } diff --git a/src/standard.c b/src/standard.c index 69c8f4f5d..80e0d1b4a 100644 --- a/src/standard.c +++ b/src/standard.c @@ -248,27 +248,27 @@ unsigned int strl2uic(const char *s, int len) int strl2ic(const char *s, int len) { int i = 0; - int j; + int j, k; if (len > 0) { if (*s != '-') { /* positive number */ while (len-- > 0) { j = (*s++) - '0'; - i = i * 10; + k = i * 10; if (j > 9) break; - i += j; + i = k + j; } } else { /* negative number */ s++; while (--len > 0) { j = (*s++) - '0'; - i = i * 10; + k = i * 10; if (j > 9) break; - i -= j; + i = k - j; } } }