lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 4 Apr 2015 00:04:59 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Joe Perches <joe@...ches.com>
Cc:	devel@...verdev.osuosl.org, gregkh@...uxfoundation.org,
	Amitoj Kaur Chawla <amitoj1606@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Staging: rtl8188eu: Remove zero testing pointer typed
 value

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@...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

Powered by Openwall GNU/*/Linux Powered by OpenVZ