lkml.org 
[lkml]   [2013]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] tpm/tpm_ppi: Do not compare strcmp(a,b) == -1
From
Date
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 versions should do too.
However, arch implementations do vary...

fyi: using
if (strcmp(foo, bar) < 0)
is canonical.

There are no existing <= -1 uses.




\
 
 \ /
  Last update: 2013-10-30 02:21    [W:0.081 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site