summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPeng Wang <rocking@linux.alibaba.com>2021-02-26 02:21:44 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2021-02-26 18:41:04 +0100
commit35cdcbfc5cfc30012b790d9b077bd949ad46f1dd (patch)
tree9967484ff24c47b6b95197805797aab0ab61574f /scripts
parentcheckpatch: improve blank line after declaration test (diff)
downloadlinux-35cdcbfc5cfc30012b790d9b077bd949ad46f1dd.tar.xz
linux-35cdcbfc5cfc30012b790d9b077bd949ad46f1dd.zip
checkpatch: ignore warning designated initializers using NR_CPUS
Some max_length wants to hold as large room as possible to ensure enough size to tackle with the biggest NR_CPUS. An example below: kernel/cgroup/cpuset.c: static struct cftype legacy_files[] = { { .name = "cpus", .seq_show = cpuset_common_seq_show, .write = cpuset_write_resmask, .max_write_len = (100U + 6 * NR_CPUS), .private = FILE_CPULIST, }, ... } Link: https://lkml.kernel.org/r/5d4998aa8a8ac7efada2c7daffa9e73559f8b186.1609331255.git.rocking@linux.alibaba.com Signed-off-by: Peng Wang <rocking@linux.alibaba.com> Acked-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bc8069503819..7ba8fbbf9f1b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7025,12 +7025,14 @@ sub process {
# use of NR_CPUS is usually wrong
# ignore definitions of NR_CPUS and usage to define arrays as likely right
+# ignore designated initializers using NR_CPUS
if ($line =~ /\bNR_CPUS\b/ &&
$line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
$line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
$line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
$line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
- $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/)
+ $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/ &&
+ $line !~ /^.\s*\.\w+\s*=\s*.*\bNR_CPUS\b/)
{
WARN("NR_CPUS",
"usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);