Patchwork [U-Boot] itest: fix result of string compares

login
register
mail settings
Submitter Wolfgang Denk
Date Feb. 8, 2011, 3:56 p.m.
Message ID <1297180565-23763-1-git-send-email-wd@denx.de>
Download mbox | patch
Permalink /patch/82354/
State Accepted
Commit cc22b795fb5fee72bd567eec5d33a11e8b989086
Headers show

Comments

Wolfgang Denk - Feb. 8, 2011, 3:56 p.m.
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>
---
 common/cmd_itest.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
Detlev Zundel - Feb. 15, 2011, 1:55 p.m.
Hi Wolfgang,

> 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> 

Cheers
  Detlev
Wolfgang Denk - Feb. 15, 2011, 8:46 p.m.
Dear Wolfgang Denk,

In message <1297180565-23763-1-git-send-email-wd@denx.de> 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 <wd@denx.de>
> ---
>  common/cmd_itest.c |    7 ++-----
>  1 files changed, 2 insertions(+), 5 deletions(-)

Applied.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index fa6a0c3..2a238a4 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -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);