Commit cc22b795fb5fee72bd567eec5d33a11e8b989086
1 parent
518075fc6a
Exists in
master
and in
54 other branches
itest: fix result of string compares
The implementation of the string compare function of the "itest" command was weird, as only the length of the shortest argument was included in the compare, with the result that something like "itest.s abd == abddef" would return TRUE. Fix this. Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
Showing 1 changed file with 2 additions and 5 deletions Side-by-side Diff
common/cmd_itest.c
... | ... | @@ -94,16 +94,13 @@ |
94 | 94 | |
95 | 95 | static int stringcomp(char *s, char *t, int op) |
96 | 96 | { |
97 | - int n, p; | |
97 | + int p; | |
98 | 98 | char *l, *r; |
99 | 99 | |
100 | 100 | l = evalstr(s); |
101 | 101 | r = evalstr(t); |
102 | 102 | |
103 | - /* we'll do a compare based on the length of the shortest string */ | |
104 | - n = min(strlen(l), strlen(r)); | |
105 | - | |
106 | - p = strncmp(l, r, n); | |
103 | + p = strcmp(l, r); | |
107 | 104 | switch (op) { |
108 | 105 | case EQ: return (p == 0); |
109 | 106 | case NE: return (p != 0); |