Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754395Ab1EGCBQ (ORCPT ); Fri, 6 May 2011 22:01:16 -0400 Received: from 64.mail-out.ovh.net ([91.121.185.65]:50527 "HELO 64.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753369Ab1EGCBP (ORCPT ); Fri, 6 May 2011 22:01:15 -0400 Date: Sat, 7 May 2011 03:50:41 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: Arnaud Lacombe Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH v2] kconfig: autogenerated config_is_xxx macro Message-ID: <20110507015041.GA21017@game.jcrosoft.org> References: <1304658229-30820-1-git-send-email-plagnioj@jcrosoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-PGP-Key: http://uboot.jcrosoft.org/plagnioj.asc X-PGP-key-fingerprint: 6309 2BBA 16C8 3A07 1772 CC24 DEFC FFA3 279C CE7C User-Agent: Mutt/1.5.20 (2009-06-14) X-Ovh-Tracer-Id: 12096668601148091385 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1947 Lines: 51 On 12:19 Fri 06 May , Arnaud Lacombe wrote: > Hi, > > On Fri, May 6, 2011 at 1:03 AM, Jean-Christophe PLAGNIOL-VILLARD > wrote: > > this will allow to use to use > > > > ? ? ? ?if(config_is_xxx()) > > ? ? ? ?if(config_is_xxx_module()) > > > > in the code instead of > > > > ? ? ? ?#ifdef CONFIG_xxx > > ? ? ? ?#ifdef CONFIG_xxx_MODULE > > > > and now let the compiler remove the non usefull code and not the > > pre-processor > > > Why would it be a good thing ? > > Most configuration-dependent code inside functions tends to be moved > to a static inline already, which get conditionally defined based on > the CONFIG_. If it is not, then the code is badly architectured > (-> bad). Using that if(xxx) notation would also lead to yet more > heavily indented function (-> bad). Moreover, this introduces > yet-another way to check for an information (-> bad), and you will end > up with mixing the config_is_ notation inside a function > declaration, and CONFIG_ when not inside a function (-> bad) > > Actually, this is even worse than that as you'll not be able to hide > structure (or structure members) inside CONFIG_ and use that > structure (or structure members) in config_is_ protected block > without causing compile-time failure. sorry but conditionnal structure members is bad practice you save nearly no space nut for the test of the code in multiple configuration. Use union for this. the compile-time failure is good here. it's means your code is not generic. specially when you want to keep code running on multiple soc/arch keep compiling no matter the configuration #ifdef in the code is a really bad habit Best Regards, J. -- 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/