]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
checkpatch: Don't warn about PREFER_IF in headers/DT files
authorSimon Glass <sjg@chromium.org>
Sun, 14 Jun 2020 16:54:08 +0000 (10:54 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 10 Jul 2020 00:57:22 +0000 (18:57 -0600)
This warning should only be displayed for C files. Fix it and update the
test.

Signed-off-by: Simon Glass <sjg@chromium.org>
scripts/checkpatch.pl
tools/patman/test_checkpatch.py

index 9544e57352b325b381a4cc599df09df377e0bf88..238f12cb469db068b2d3df3c471cde57e1f972d6 100755 (executable)
@@ -2343,7 +2343,7 @@ sub u_boot_line {
        }
 
        # use if instead of #if
-       if ($line =~ /^\+#if.*CONFIG.*/) {
+       if ($realfile =~ /\.c$/ && $line =~ /^\+#if.*CONFIG.*/) {
                WARN("PREFER_IF",
                     "Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible\n" . $herecurr);
        }
index 710b4a7d88b79b6b1bd83c78fff834c87f4d0066..c9580adb54485b29ad0e724925ca176ad488c2e1 100644 (file)
@@ -388,6 +388,8 @@ index 0000000..2234c87
         """Test for Use the livetree API"""
         pm = PatchMaker()
         pm.add_line('common/main.c', '#ifdef CONFIG_YELLOW')
+        pm.add_line('common/init.h', '#ifdef CONFIG_YELLOW')
+        pm.add_line('fred.dtsi', '#ifdef CONFIG_YELLOW')
         self.checkSingleMessage(pm, "PREFER_IF")
 
     def testCommandUseDefconfig(self):