Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbbDCVFT (ORCPT ); Fri, 3 Apr 2015 17:05:19 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:22896 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbbDCVFR (ORCPT ); Fri, 3 Apr 2015 17:05:17 -0400 Date: Sat, 4 Apr 2015 00:04:59 +0300 From: Dan Carpenter To: Joe Perches Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, Amitoj Kaur Chawla , linux-kernel@vger.kernel.org Subject: Re: [PATCH] Staging: rtl8188eu: Remove zero testing pointer typed value Message-ID: <20150403210458.GV10964@mwanda> References: <20150403164211.GA6422@amitoj-Inspiron-3542> <20150403165113.GU10964@mwanda> <1428080470.13180.19.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428080470.13180.19.camel@perches.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1103 Lines: 31 On Fri, Apr 03, 2015 at 10:01:10AM -0700, Joe Perches wrote: > On Fri, 2015-04-03 at 19:51 +0300, Dan Carpenter wrote: > > Also strcmp() and similar should always be done as == 0, < 0 or != 0 > > because that is the idiom: > > Less true. > > When testing for equality, !strcmp is very common. > > There are ~2500 uses of !strcmp in the kernel tree vs > ~1500 uses of strcmp() == or != Bugs with reversed strcmp() tests are almost always caught in testing so it's not an issue. But == 0 is more correct. ;) 1) It's more clear when read in English. "if not strcmp then" or "if strcmp NOT EQUAL zero". In the second one I've emphasized the NOT EQUAL because the strings are not eqaul. 2) Also if works for the other compares too. if (strcmp(x, y) < 0) <-- means x is less than y. if (strcmp(x, y) == 0) <-- means x == y. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/