checkpatch: add PREFER_IS_ENABLED test
Using #if defined CONFIG_<FOO> || defined CONFIG_<FOO>_MODULE is more verbose than necessary and IS_ENABLED(CONFIG_<FOO>) is preferred. So add a test and a message for it. --fix it to if desired. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
fff7fb0b2d
commit
2d6327459e
|
@ -5637,6 +5637,16 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for #if defined CONFIG_<FOO> || defined CONFIG_<FOO>_MODULE
|
||||
if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(CONFIG_[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/) {
|
||||
my $config = $1;
|
||||
if (WARN("PREFER_IS_ENABLED",
|
||||
"Prefer IS_ENABLED(<FOO>) to CONFIG_<FOO> || CONFIG_<FOO>_MODULE\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] = "\+#if IS_ENABLED($config)";
|
||||
}
|
||||
}
|
||||
|
||||
# check for case / default statements not preceded by break/fallthrough/switch
|
||||
if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
|
||||
my $has_break = 0;
|
||||
|
|
Loading…
Reference in New Issue