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 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel