From mboxrd@z Thu Jan 1 00:00:00 1970 From: AKASHI Takahiro Date: Mon, 15 Jun 2020 11:58:57 +0900 Subject: [PATCH 6/6] checkpatch.pl: Request if() instead #ifdef In-Reply-To: <20200604233935.GO32287@bill-the-cat> References: <20200522223240.187032-1-sjg@chromium.org> <20200522163226.6.I1e88f035ad8ba4d943ea914eaa536d4cbdc06495@changeid> <20200604233935.GO32287@bill-the-cat> Message-ID: <20200615025857.GA20498@laputa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, Jun 04, 2020 at 07:39:35PM -0400, Tom Rini wrote: > On Fri, May 22, 2020 at 04:32:40PM -0600, Simon Glass wrote: > > > There is a lot of use of #ifdefs in U-Boot. In an effort reduce this, > > suggest using the compile-time construct. > > > > Signed-off-by: Simon Glass > > Applied to u-boot/master, thanks! This check is simple, but IMHO, too simple. It will generate false-positive, or pointless, warnings for some common use cases. Say, In an include header, #ifdef CONFIG_xxx extern int foo_data; int foo(void); #endif Or in a C file (foo_common.c), #ifdef CONFIG_xxx_a int foo_a(void) ... #endif #ifdef CONFIG_xxx_b int foo_b(void) ... #endif Or, struct baa baa_list[] = { #ifdef CONFIG_xxx data_xxx, #endif ... They are harmless and can be ignored, but also annoying. Can you sophisticate this check? In addition, if I want to stick to this rule, there can co-exist an "old" style and "new" style of code in a single file. (particularly tons of examples in UEFI subsystem) How should we deal with this? Thanks, -Takahiro Akashi > -- > Tom