Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Mon,  4 Nov 2013 21:48:08 -0800
From: Michael Forney <mforney@...rney.org>
To: musl@...ts.openwall.com
Subject: [PATCH] strcmp: Remove unnecessary check for *r

If *l == *r && *l, then by transitivity, *r.
---
I noticed while looking at getopt_long that strcmp has a redundant check for
*r. I know the compiler will almost certainly optimize this out anyway, but I
still think it would be a good change to make.

 src/string/strcmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/string/strcmp.c b/src/string/strcmp.c
index 91eb740..808bd83 100644
--- a/src/string/strcmp.c
+++ b/src/string/strcmp.c
@@ -2,6 +2,6 @@
 
 int strcmp(const char *l, const char *r)
 {
-	for (; *l==*r && *l && *r; l++, r++);
+	for (; *l==*r && *l; l++, r++);
 	return *(unsigned char *)l - *(unsigned char *)r;
 }
-- 
1.8.4.2

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.