mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
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.
This commit is contained in:
parent
80fe12e483
commit
2e3a636b7e
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user