Messages in this thread | | | From | Peter Hüwe <> | Subject | Re: [PATCH 1/2] tpm/tpm_ppi: Do not compare strcmp(a,b) == -1 | Date | Wed, 30 Oct 2013 20:35:36 +0100 |
| |
Hi Joe, Jason > fyi: using > if (strcmp(foo, bar) < 0) > is canonical.
Yeah of course you're both right - if (strcmp(foo, bar) < 0) is the correct version. Sorry about the rubbish patch.
> lib/string.c:strcmp returns only -1,0,1 > so that's what the arch versions should do too. > However, arch implementations do vary...
Joe, You are right on this one as well.
I did not pay attention to where cscope did send me - it was arch/x86/boot/string.c which implements it as
while (*s1 || *s2) { delta = *s2 - *s1; if (delta) return delta; s1++; s2++; }
Although I know that this is not used here, it differs from the version in lib. (Maybe worth changing?)
In anycase if (strcmp(foo, bar) < 0) is better than if (strcmp(foo, bar) == -1) so I'll resend the patch.
Thanks for reviewing!
Peter
| |