string: on strstrip(), first remove leading spaces before running over str
authorAndré Goddard Rosa <andre.goddard@gmail.com>
Tue, 15 Dec 2009 02:01:04 +0000 (18:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Dec 2009 16:53:32 +0000 (08:53 -0800)
... so that strlen() iterates over a smaller string comprising of the
remaining characters only.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/string.c

index 3a912a4e9a632a3cf63d1da2f4da6dd502e82ff5..765566a6a0887b3054670b6b59090d4edb3430c3 100644 (file)
@@ -364,8 +364,8 @@ char *strstrip(char *s)
        size_t size;
        char *end;
 
+       s = skip_spaces(s);
        size = strlen(s);
-
        if (!size)
                return s;
 
@@ -374,7 +374,7 @@ char *strstrip(char *s)
                end--;
        *(end + 1) = '\0';
 
-       return skip_spaces(s);
+       return s;
 }
 EXPORT_SYMBOL(strstrip);