author: Rasmus Villemoes <linux@rasmusvillemoes.dk> 2015-02-13 14:36:44 -0800
committer: Linus Torvalds <torvalds@linux-foundation.org> 2015-02-13 21:21:36 -0800
commit: 8da53d4595a53fb9a3380dd4d1c9bc24c7c9aab8
parent: fcc139ae227b97bd81352e9102d8e79498d1e930
Commit Summary:
Diffstat:
1 file changed, 6 insertions, 6 deletions
diff --git a/lib/string.c b/lib/string.c
index 3206d0178296..cdd97f431ae2 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -313,12 +313,12 @@ EXPORT_SYMBOL(strchrnul);
*/
char *strrchr(const char *s, int c)
{
- const char *p = s + strlen(s);
- do {
- if (*p == (char)c)
- return (char *)p;
- } while (--p >= s);
- return NULL;
+ const char *last = NULL;
+ do {
+ if (*s == (char)c)
+ last = s;
+ } while (*s++);
+ return (char *)last;
}
EXPORT_SYMBOL(strrchr);
#endif