[PATCH 2/8] string: fix strncmp function

Piotr Wilczek p.wilczek at samsung.com
Wed Dec 11 08:07:33 EST 2013


Fix function to return the number of characters that differ in
the compared strings.

Signed-off-by: Piotr Wilczek <p.wilczek at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
---
 string.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/string.c b/string.c
index d13e22b..ced25c8 100644
--- a/string.c
+++ b/string.c
@@ -24,7 +24,7 @@ int strncmp(const char *stra, const char *strb, int len)
 	const char *b = strb;
 
 	while ((a - stra) < len)
-		diff += *(a++) - *(b++);
+		diff += !!(*(a++) - *(b++));
 
 	return diff;
 }
-- 
1.7.9.5




More information about the linux-arm-kernel mailing list