lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 30 Dec 2020 04:38:56 -0800
From:   Joe Perches <joe@...ches.com>
To:     Peng Wang <rocking@...ux.alibaba.com>, apw@...onical.com,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] checkpatch: ignore warning designated initializers
 using NR_CPUS

On Wed, 2020-12-30 at 20:29 +0800, Peng Wang wrote:
> 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,
>         },
> 	...
> }
> 
> Signed-off-by: Peng Wang <rocking@...ux.alibaba.com>
> ---
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -7028,12 +7028,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);

Thanks.

Acked-by: Joe Perches <joe@...ches.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ