summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2010-08-10 04:20:54 +0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-10 07:45:09 +0400
commit559b140a36613bb5b63f258b2ad833dad8cd11d9 (patch)
tree5059f8a551b1cfb11f3a72f00b5f3ee584dd0a61 /lib/vsprintf.c
parente3f76e3386ee38e3654e81c2f3933ccca1f2d639 (diff)
downloadlinux-559b140a36613bb5b63f258b2ad833dad8cd11d9.tar.xz
lib: vsprintf: useless strlen() removed
The strict_strtoul() and strict_strtoull() functions used strlen() to check argument's length in a situation where it wasn't strictly necessary Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Cc: "Yi Yang" <yi.y.yang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 4ee19d0d3910..7af9d841c43b 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -146,19 +146,16 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
char *tail;
unsigned long val;
- size_t len;
*res = 0;
- len = strlen(cp);
- if (len == 0)
+ if (!*cp)
return -EINVAL;
val = simple_strtoul(cp, &tail, base);
if (tail == cp)
return -EINVAL;
- if ((*tail == '\0') ||
- ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
+ if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
*res = val;
return 0;
}
@@ -220,18 +217,15 @@ int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res)
{
char *tail;
unsigned long long val;
- size_t len;
*res = 0;
- len = strlen(cp);
- if (len == 0)
+ if (!*cp)
return -EINVAL;
val = simple_strtoull(cp, &tail, base);
if (tail == cp)
return -EINVAL;
- if ((*tail == '\0') ||
- ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
+ if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
*res = val;
return 0;
}