Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbaLONoQ (ORCPT ); Mon, 15 Dec 2014 08:44:16 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:23327 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbaLONoP (ORCPT ); Mon, 15 Dec 2014 08:44:15 -0500 Date: Mon, 15 Dec 2014 16:43:34 +0300 From: Dan Carpenter To: Jeremiah Mahler , One Thousand Gnomes , Loic Pefferkorn , gregkh@linuxfoundation.org, alan@linux.intel.com, jun.j.tian@intel.com, octavian.purdila@intel.com, nnk@google.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, apw@canonical.com, joe@perches.com Subject: Re: [PATCH] checkpatch giving bogus advice (was staging: goldfish: Fix minor coding style) Message-ID: <20141215134334.GE4856@mwanda> References: <20141213175518.GA28616@hudson.localdomain> <20141213182238.GA6979@iron> <20141213194647.GA30065@hudson.localdomain> <20141215114421.7389d32a@lxorguk.ukuu.org.uk> <20141215130346.GB18251@hudson.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141215130346.GB18251@hudson.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 15, 2014 at 05:03:46AM -0800, Jeremiah Mahler wrote: > > Or another way mentioned in K&R that produces a compile error > > if (NULL = x) > Yes. People used to write Yoda code back in the day. Don't ever do this in the kernel. 1) It looks stupid. 2) GCC will catch most == vs = bugs as Alan pointed out. 3) There are still some that sneak through because people put double parenthesis around everything like "if ((foo = NULL) || (...)) {", but checkpatch.pl and Smatch will catch those. 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/