[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131030164535.GA3511@obsidianresearch.com>
Date: Wed, 30 Oct 2013 10:45:35 -0600
From: Jason Gunthorpe <jgunthorpe@...idianresearch.com>
To: Peter Huewe <peterhuewe@....de>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Rajiv Andrade <mail@...jiv.net>,
tpmdd-devel@...ts.sourceforge.net,
Xiaoyan Zhang <xiaoyan.zhang@...el.com>,
Gang Wei <gang.wei@...el.com>
Subject: Re: [tpmdd-devel] [PATCH 1/2] tpm/tpm_ppi: Do not compare strcmp(a,
b) == -1
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:
cmp(a,b) == 0
cmp(a,b) < 0
cmp(a,b) > 0
As the operator matches what is actually happening in all cases.
'>= -1' doesn't mean a >= b.
Regards,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists