Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10265316pxu; Tue, 29 Dec 2020 20:16:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxL3sYzJh92mKo9o7qbFX2Q3vlGnlTES0oZ0OBbd7t3IFCD+4CGAnBxbFNMGCgIgrCro4Na X-Received: by 2002:a50:d60f:: with SMTP id x15mr47969901edi.224.1609301792473; Tue, 29 Dec 2020 20:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609301792; cv=none; d=google.com; s=arc-20160816; b=vS9RKvIY23fKpQWwshNEzJl2S0u1TgHTeGzVSkSft26j05EGv92TufYDsDHiU6f4i+ C/nDVU3Jtbutg6Lmu/alVlsaPXAuqtdknjk1uNJkXa2ij5xoOe5OB6MMr4FWvzS98m/O YpOt7xEZcK/9ffQSg9V9ngXG7G4TauRnzwE3MApk5QmuZE57WiON0AzGxU+CYajIHJwd UMZOB7jNL7VWk3rq05/VPWpuYcsSe6JLFwcy/oBlQauLlYb5gh/qHBoMQgja/yEigA9g 1WlYPfhghrbDU7AOx4EYvN87o3xfL+IG6GBxVSfg2AsrazEF2ZG5kQQWeI4ilRGgfIPT +NYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=1owuFjYxHsnGXe1pkjs3nFxj/fZfzh5eJLQ+c/eMWKw=; b=UgTMdpJLSBkLj3+lATz3eK3k0A9PV9UBNt2iF7Y5DmqkvUI9BEJthoNqWXsy1Sa9bn MSI0clMZxJ+X80yGwyj/s9RKFOEneqURDq2c2fnJp3lfmLjhesiYLENspuYFN9HEgssY WF4SybVcQ19pXQ9AuJ47ydZZA/hTLB/r9T76H8mSdgiWUqv4Y8WpTWTCmnTSWIgRSzoo LwWc++NHsUOV5rWCoiyizZ10R/jb7Phz47xwb07mUROOURC5/zTM1tOXukl3eCgksaWM iZRmMj5hMrh7yp0JM+fDKZP5PcmBFLNfDH0x2xPtsfY0JaKSpvxYacQdBBVWfpy3CB2C 0trg== 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 t10si18477567edt.208.2020.12.29.20.16.08; Tue, 29 Dec 2020 20:16:32 -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 S1726203AbgL3EOq (ORCPT + 99 others); Tue, 29 Dec 2020 23:14:46 -0500 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:41994 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbgL3EOq (ORCPT ); Tue, 29 Dec 2020 23:14:46 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R741e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=rocking@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UKCUbX8_1609301637; Received: from localhost(mailfrom:rocking@linux.alibaba.com fp:SMTPD_---0UKCUbX8_1609301637) by smtp.aliyun-inc.com(127.0.0.1); Wed, 30 Dec 2020 12:14:04 +0800 From: Peng Wang To: apw@canonical.com, joe@perches.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: ignore warning designated initializers using NR_CPUS Date: Wed, 30 Dec 2020 12:13:55 +0800 Message-Id: <2eba2ec8531f440410ee8164aaf2ab754bd5a0d1.1609301434.git.rocking@linux.alibaba.com> X-Mailer: git-send-email 2.9.5 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. As 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..da8fc48 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*\..*=.*\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