All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 2/2] checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an error
Date: Mon,  5 Oct 2020 09:57:30 +0300	[thread overview]
Message-ID: <20201005065730.9768-2-alpernebiyasak@gmail.com> (raw)
In-Reply-To: <20201005065730.9768-1-alpernebiyasak@gmail.com>

CONFIG_IS_ENABLED() takes the kconfig name without the CONFIG_ prefix,
e.g. CONFIG_IS_ENABLED(CLK) for CONFIG_CLK. Make including the prefix
an error in checkpatch.pl so calls in the wrong format aren't
accidentally reintroduced.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
---

Changes in v2:
- Add patman test

v1: https://patchwork.ozlabs.org/project/uboot/patch/20200930114612.22319-2-alpernebiyasak at gmail.com/

 scripts/checkpatch.pl           | 6 ++++++
 tools/patman/test_checkpatch.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4bed2b0cdc..4ed7e124c9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2365,6 +2365,12 @@ sub u_boot_line {
 		ERROR("DISABLE_FDT_OR_INITRD_RELOC",
 		     "fdt or initrd relocation disabled at boot time\n" . $herecurr);
 	}
+
+	# Do not use CONFIG_ prefix in CONFIG_IS_ENABLED() calls
+	if ($line =~ /^\+.*CONFIG_IS_ENABLED\(CONFIG_\w*\).*/) {
+		ERROR("CONFIG_IS_ENABLED_CONFIG",
+		      "CONFIG_IS_ENABLED() takes values without the CONFIG_ prefix\n" . $herecurr);
+	}
 }
 
 sub process {
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index 792196e689..f71c70fb13 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -405,6 +405,12 @@ index 0000000..2234c87
         pm.add_line('include/myfile.h', '#include <dm.h>')
         self.checkSingleMessage(pm, 'BARRED_INCLUDE_IN_HDR', 'error')
 
+    def testConfigIsEnabledConfig(self):
+        """Test for accidental CONFIG_IS_ENABLED(CONFIG_*) calls"""
+        pm = PatchMaker()
+        pm.add_line('common/main.c', 'if (CONFIG_IS_ENABLED(CONFIG_CLK))')
+        self.checkSingleMessage(pm, 'CONFIG_IS_ENABLED_CONFIG', 'error')
+
 
 if __name__ == "__main__":
     unittest.main()
-- 
2.28.0

  reply	other threads:[~2020-10-05  6:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  6:57 [PATCH v2 1/2] treewide: Fix wrong CONFIG_IS_ENABLED() handling Alper Nebi Yasak
2020-10-05  6:57 ` Alper Nebi Yasak [this message]
2020-10-05 10:56   ` [PATCH v2 2/2] checkpatch.pl: Make CONFIG_IS_ENABLED(CONFIG_*) an error Simon Glass
2020-10-14 17:43   ` Tom Rini
2020-10-14 17:43 ` [PATCH v2 1/2] treewide: Fix wrong CONFIG_IS_ENABLED() handling Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201005065730.9768-2-alpernebiyasak@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.