Fix strstr() indent and rewrite to not call strlen() on each char

Coverity #75583 flagged an indentation error in strstr().
While looking at that, I noticed that strstr() is calling strlen() for
each character it compares. That led me to look closer.
And I found that the function was badly broken.

Examples of bad results:
   strstr("foobar", "foo") => 1
   strstr("foobar", "ob") => -1

So I rewrote strlen() using memcmp().
I also made the parameters "const" and cleaned up strlen().

Change-Id: Id1188f114d505cd10e72fa02d3f920646a499603
Signed-off-by: Ben Gardner <>
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <>
2 files changed