Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Peng Wang and committed by
Linus Torvalds
35cdcbfc b5e8736a

+3 -1
+3 -1
scripts/checkpatch.pl
··· 7025 7025 7026 7026 # use of NR_CPUS is usually wrong 7027 7027 # ignore definitions of NR_CPUS and usage to define arrays as likely right 7028 + # ignore designated initializers using NR_CPUS 7028 7029 if ($line =~ /\bNR_CPUS\b/ && 7029 7030 $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ && 7030 7031 $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ && 7031 7032 $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ && 7032 7033 $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ && 7033 - $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/) 7034 + $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/ && 7035 + $line !~ /^.\s*\.\w+\s*=\s*.*\bNR_CPUS\b/) 7034 7036 { 7035 7037 WARN("NR_CPUS", 7036 7038 "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);