diff mbox

[v3,1/2] checkpatch: add Kconfig 'default n' test

Message ID 1465017040-12777-1-git-send-email-yingjoe.chen@mediatek.com
State Superseded
Headers show

Commit Message

Yingjoe Chen June 4, 2016, 5:10 a.m. UTC
If a Kconfig config option doesn't specify 'default', the default
will be n. Adding 'default n' is unnecessary.

Add a test to warn about this.

Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>

---
For this series, rebase to v4.7-rc1 and dropped 'relax Kconfig help text
line number threshold' patch.

Let me know what you think. Thanks.


Change in v3:
- Rebase to v4.7-rc1

Change in v2:
- Change according to Joe Perches' suggesti

 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
1.9.1

Comments

Yingjoe Chen June 7, 2016, 1:16 p.m. UTC | #1
Hi,

Thanks for the review.


On Mon, 2016-06-06 at 20:10 +0100, Andy Whitcroft wrote:
> On Mon, Jun 06, 2016 at 09:43:15AM -0700, Joe Perches wrote:

> > On Sat, 2016-06-04 at 13:10 +0800, Yingjoe Chen wrote:

> > > If a Kconfig config option doesn't specify 'default', the default

> > > will be n. Adding 'default n' is unnecessary.

> > > Add a test to warn about this.

> > 

> > Is it obvious that a Kconfig has "default n" ?

> > This seems to work, but is this useful?



While sending patch for upstream, I saw maintainers request it to be
removed. So I think it might worth adding check to it.
Some examples from google:

http://lists.infradead.org/pipermail/linux-arm-kernel/2012-September/120733.html
https://lkml.org/lkml/2013/3/16/153
https://lkml.org/lkml/2016/5/23/657


> 

> > > +		if ($realfile =~ /Kconfig/ &&

> > > +		    $line =~ /^\+\s*default\s*n\s*(#.*|$)/i) {

> 

> I wonder particually when the submitter has supplied a comment, presumably

> to tell us why it defaults to 'n'.  I feel more accepting of rejecting

> uncommented ones than those with.



How about change this to /^\+\s*default\s*n$/i ?

Joe.C
diff mbox

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6750595..f5ce804 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2683,6 +2683,13 @@  sub process {
 			     "Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
 		}
 
+# discourage the use of default n
+		if ($realfile =~ /Kconfig/ &&
+		    $line =~ /^\+\s*default\s*n\s*(#.*|$)/i) {
+			WARN("CONFIG_DEFAULT_N",
+			     "Use of default n is unnecessary, default is n when omitted.\n" . $herecurr);
+		}
+
 		if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
 		    ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
 			my $flag = $1;