From patchwork Fri May 22 22:32:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246332 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Fri, 22 May 2020 16:32:40 -0600 Subject: [PATCH 6/6] checkpatch.pl: Request if() instead #ifdef In-Reply-To: <20200522223240.187032-1-sjg@chromium.org> References: <20200522223240.187032-1-sjg@chromium.org> Message-ID: <20200522163226.6.I1e88f035ad8ba4d943ea914eaa536d4cbdc06495@changeid> 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 --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 22869992e90..33ec4e2bfd4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2259,6 +2259,12 @@ sub u_boot_line { WARN("CMD_TEST", "Possible new command - make sure you add a test\n" . $herecurr); } + + # use if instead of #if + if ($line =~ /^\+#if.*CONFIG.*/) { + WARN("PREFER_IF", + "Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible\n" . $herecurr); + } } sub process {