|
From: | Pedro A ARANDA |
Subject: | RE: Grub-devel Digest, Vol 69, Issue 19 |
Date: | Tue, 10 Nov 2009 10:06:30 +0000 |
Hi all, just my .00002 euto-cents: With this function, you always assume that strlen(s1) <= strlen(s2), right? > int > grub_auth_strcmp (const char *s1, const char *s2) > { > int n; > volatile int ret = 0; > > for (n = grub_strlen (s1); n >= 0; n--) > { > if (*s1 != *s2) > ret |= 1; > else > ret |= 0; > > s1++; s2++; > } > > return ret; > } because if not, you'd have to if (*s1 == 0 || *s2 == 0) break; in the loop and the return would be something like return *s1 == 0 && *s2 == 0 && ret == 1; And then you can continue simplifying to while (1) { if (*s1 != *s2) break; if (*s1 == 0) break; if (*s2 == 0) break; s1++; s2++; } return *s1 == 0 && *s2 == 0; Again, just my .00002 euro-cents or less Cheers,/PA Windows Live: Keep your friends up to date with what you do online. |
[Prev in Thread] | Current Thread | [Next in Thread] |