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

2013-10-31 Thread Bernd Petrovitsch
Hi all! On Mit, 2013-10-30 at 12:41 -0700, Joe Perches wrote: [...] > The arch/... assembly versions don't always > return -1, 0, 1 so I don't think it's worth > it to change all of those. FWIW user-space strcmp() - e.g. as in http://pubs.opengroup.org/onlinepubs/009695399/functions/strcmp.html

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

2013-10-31 Thread Bernd Petrovitsch
Hi all! On Mit, 2013-10-30 at 12:41 -0700, Joe Perches wrote: [...] The arch/... assembly versions don't always return -1, 0, 1 so I don't think it's worth it to change all of those. FWIW user-space strcmp() - e.g. as in http://pubs.opengroup.org/onlinepubs/009695399/functions/strcmp.html but

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

2013-10-30 Thread Joe Perches
On Wed, 2013-10-30 at 20:35 +0100, Peter Hüwe wrote: > Hi Joe, Jason Hi Peter. > > lib/string.c:strcmp returns only -1,0,1 > > so that's what the arch versions should do too. > > However, arch implementations do vary... [] > I did not pay attention to where cscope did send me > - it was

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

2013-10-30 Thread Peter Hüwe
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. >

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

2013-10-30 Thread Jason Gunthorpe
On Wed, Oct 30, 2013 at 01:40:27AM +0100, Peter Huewe wrote: > strcmp does return the difference between two strings not only -1,0,1 > consequently > if (strcmp (a,b) == -1) > might lead to taking the wrong branch > > -> compare with <= instead. I've always thought this was the preferred idiom:

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

2013-10-30 Thread Jason Gunthorpe
On Wed, Oct 30, 2013 at 01:40:27AM +0100, Peter Huewe wrote: strcmp does return the difference between two strings not only -1,0,1 consequently if (strcmp (a,b) == -1) might lead to taking the wrong branch - compare with = instead. I've always thought this was the preferred idiom:

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

2013-10-30 Thread Peter Hüwe
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,

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

2013-10-30 Thread Joe Perches
On Wed, 2013-10-30 at 20:35 +0100, Peter Hüwe wrote: Hi Joe, Jason Hi Peter. lib/string.c:strcmp returns only -1,0,1 so that's what the arch versions should do too. However, arch implementations do vary... [] I did not pay attention to where cscope did send me - it was

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

2013-10-29 Thread Joe Perches
On Wed, 2013-10-30 at 01:40 +0100, Peter Huewe wrote: > strcmp does return the difference between two strings not only -1,0,1 > consequently > if (strcmp (a,b) == -1) > might lead to taking the wrong branch > > -> compare with <= instead. lib/string.c:strcmp returns only -1,0,1 so that's what

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

2013-10-29 Thread Peter Huewe
strcmp does return the difference between two strings not only -1,0,1 consequently if (strcmp (a,b) == -1) might lead to taking the wrong branch -> compare with <= instead. This also makes the code/behavior compliant with its comments. (e.g. if PPI Version is 1.0) Fixes Coverity complaints:

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

2013-10-29 Thread Peter Huewe
strcmp does return the difference between two strings not only -1,0,1 consequently if (strcmp (a,b) == -1) might lead to taking the wrong branch - compare with = instead. This also makes the code/behavior compliant with its comments. (e.g. if PPI Version is 1.0) Fixes Coverity complaints: CID:

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

2013-10-29 Thread Joe Perches
On Wed, 2013-10-30 at 01:40 +0100, Peter Huewe wrote: strcmp does return the difference between two strings not only -1,0,1 consequently if (strcmp (a,b) == -1) might lead to taking the wrong branch - compare with = instead. lib/string.c:strcmp returns only -1,0,1 so that's what the arch