Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10342249pxu; Tue, 29 Dec 2020 23:16:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyryDU/3wEfPy/RbBfjMgZxF19UOShgKO5tgWRwmPzqQIQFxpXuePTZk0TMhOaeSLyBWhIk X-Received: by 2002:aa7:de0f:: with SMTP id h15mr49793013edv.110.1609312594529; Tue, 29 Dec 2020 23:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609312594; cv=none; d=google.com; s=arc-20160816; b=wlvu5W2Sw8o+nsbNwIWqdvdG9ttSVesR2iy31r995fpWnTkI8AC3siFbpRmI6mSPqH IRigSX1ywlssvoLVKTqn3/N3c3jT9fKHD7rkKrPtSlI0p2NorSwnO6AsoH05f9rTVRXH OSIbQUQlvf6fCUaBn2wKUrGP9jVW3vCW8eJIoVPiYSZ/6lbj5o/mEmbMPPBDLlXbniA3 R2ZZezy6R5u8/8o2tHhsBnhZCrnYSmP6Xzg5Vb4Bnumoi7C92Tv06sa7moydaOn7KkkN +V44g2aXL281nfs27aE0mXZlxL8mjsyb+nJ7EPnwOv3m9U99JCMdzkcGqPtnO8bI5F9m X7ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=cnsvhPEiArq3kPd6vgyqS+Em5/CpV8h6x1/WZz18+w8=; b=INn9VRIBvJFaenlLn16ZcjG4VXM+yNq8lLfKsGhIjntn3JCkN7N6/kNNWcvuHt6gq8 IL2u0EK2ZqfkvDIq8iAmhjvWP8mWtRqRBwWseZPWKuu94MaIFiO0rjhhP/8soQMXvVdM 4eA1l86skHSmpj9fo9UF2Rr9WkMKpk0KscQGHFlGUbgHRZ3qY8DAmUI3hVGK6+9+Oy4T 4EUBavKPmj2sPTYeIZLzLr++LPv7JK52an3fSmIBJGlmfmc1a9lmvq7mkuqBFT4NEwu/ rcZPhdqom3LsnL41Va9x72bssVU7ruJcmhX7l/tuqMTMTmwuXz9K3sRIGofeXmwrcbPJ fn7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si22980663edy.255.2020.12.29.23.16.11; Tue, 29 Dec 2020 23:16:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbgL3HPR (ORCPT + 99 others); Wed, 30 Dec 2020 02:15:17 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:60968 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgL3HPR (ORCPT ); Wed, 30 Dec 2020 02:15:17 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R431e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=rocking@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UKD93jr_1609312464; Received: from localhost(mailfrom:rocking@linux.alibaba.com fp:SMTPD_---0UKD93jr_1609312464) by smtp.aliyun-inc.com(127.0.0.1); Wed, 30 Dec 2020 15:14:33 +0800 From: Peng Wang To: apw@canonical.com, joe@perches.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] checkpatch: ignore warning designated initializers using NR_CPUS Date: Wed, 30 Dec 2020 15:14:08 +0800 Message-Id: <334ce7b5136e25bd4b10309abc36c18d75bb0d33.1609311092.git.rocking@linux.alibaba.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <5ca6c2d28f6cf091a676f8e7d8f14a933da0b267.camel@perches.com> References: <5ca6c2d28f6cf091a676f8e7d8f14a933da0b267.camel@perches.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- scripts/checkpatch.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0008530..fdbbab3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7022,12 +7022,15 @@ 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); -- 2.9.5