checkpatch.pl: Request if() instead #ifdef
authorSimon Glass <sjg@chromium.org>
Fri, 22 May 2020 22:32:40 +0000 (16:32 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 4 Jun 2020 22:10:02 +0000 (18:10 -0400)
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 <sjg@chromium.org>
scripts/checkpatch.pl

index cf620c8614ab85170f25ba7a543699b38a6a8290..17d41825c5e186222a8f2be7c134beda10a4b4c5 100755 (executable)
@@ -2261,6 +2261,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 {