summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/strto.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/strto.c b/lib/strto.c
index b7fc31d6e5d..55ff9f7437d 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -94,12 +94,11 @@ unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
/* fall through */
case 'k':
result *= 1024;
- if ((*endp)[1] == 'i') {
- if ((*endp)[2] == 'B')
- (*endp) += 3;
- else
- (*endp) += 2;
- }
+ (*endp)++;
+ if (**endp == 'i')
+ (*endp)++;
+ if (**endp == 'B')
+ (*endp)++;
}
return result;
}
@@ -116,12 +115,11 @@ unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
/* fall through */
case 'k':
result *= 1024;
- if ((*endp)[1] == 'i') {
- if ((*endp)[2] == 'B')
- (*endp) += 3;
- else
- (*endp) += 2;
- }
+ (*endp)++;
+ if (**endp == 'i')
+ (*endp)++;
+ if (**endp == 'B')
+ (*endp)++;
}
return result;
}