From: Simon Glass Date: Sun, 14 Jun 2020 16:54:08 +0000 (-0600) Subject: checkpatch: Don't warn about PREFER_IF in headers/DT files X-Git-Tag: v2020.10~120^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8af45b1f20f7f56a872297873f793655fe37f8e3;p=platform%2Fkernel%2Fu-boot.git checkpatch: Don't warn about PREFER_IF in headers/DT files This warning should only be displayed for C files. Fix it and update the test. Signed-off-by: Simon Glass --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9544e57..238f12c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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); } diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py index 710b4a7..c9580ad 100644 --- a/tools/patman/test_checkpatch.py +++ b/tools/patman/test_checkpatch.py @@ -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):