itest: fix result of string compares
PATCH 1/1 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.
--- common/cmd_itest.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
common/cmd_itest.c +2 -5
@@ -94,16 +94,13 @@ static char * evalstr(char *s)static int stringcomp (char *s,char *t,int op) { -int n, p; +int p;char *l, *r; l =evalstr (s); r =evalstr (t); -/* we'll do a compare based on the length of the shortest string */ - n =min (strlen (l),strlen (r)); - - p =strncmp (l, r, n); + p =strcmp (l, r);switch (op) {case EQ :return (p ==0 );case NE :return (p !=0 );
Signature · 1 line
1.7.4
PATCH 1/1 itest: fix result of string compares
Hi Wolfgang,
Quoted 6 lines
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 <[email protected]>
Cheers
Detlev
Signature · 8 lines
The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital computer or the gears of a cycle transmission as he does at the top of a mountain or in the petals of a flower. To think otherwise is to demean the Buddha - which is to demean oneself. -- Robert M. Pirsig -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
Wolfgang Denk
AppliedPATCH 1/1 itest: fix result of string compares
In reply to Wolfgang DenkDear Wolfgang Denk,
Quoted 9 lines · In message <[email protected]> you wrote:
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 <[email protected]>--- common/cmd_itest.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
Applied.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Experience is what causes a person to make new mistakes instead of old ones.