Re: [PATCH 1/2] tpm/tpm_ppi: Do not compare strcmp(a,b) == -1

From: Peter Hüwe
Date: Wed Oct 30 2013 - 15:32:12 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/