From 2e3a636b7eb1a866fb136fe359d8097481000709 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= <rene.kijewski@fu-berlin.de>
Date: Tue, 25 Aug 2015 00:03:46 +0200
Subject: [PATCH] embUnit: simplify `strcmp()` implementation

The logic of `stdimpl_strcmp()` was needlessly complicated and not
understood by scan-build. This change fixes the warning and makes the
code more readable.

Found via scan-build.
---
 sys/embunit/stdImpl.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sys/embunit/stdImpl.c b/sys/embunit/stdImpl.c
index 5068be8a36..8a45259be1 100644
--- a/sys/embunit/stdImpl.c
+++ b/sys/embunit/stdImpl.c
@@ -103,17 +103,18 @@ int stdimpl_strcmp(const char *s1, const char *s2)
     if (s1 == s2) {
         return 0;
     }
-    else if (s1 && !s2) {
+    else if (s1 == NULL) {
+        return -1;
+    }
+    else if (s2 == NULL) {
         return +1;
     }
-    else if (!s1 && s2) {
-        return -1;
-    } else {
-        char c1,c2;
+    else {
+        char c1, c2;
         do {
             c1 = *s1++;
             c2 = *s2++;
-        } while (c1 && c2 && (c1==c2));
+        } while ((c1 == c2) && (c1 != '\0'));
         return c1 - c2;
     }
 }
-- 
GitLab