Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1449642ybi; Thu, 30 May 2019 18:14:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJ2ijJoYZFouskvvDmMXMsogDwl7mPfsDtQoxDNEIjHNr8Ep/Ci7h7WPzo9zFeAd9l2AJf X-Received: by 2002:a63:1f11:: with SMTP id f17mr600729pgf.311.1559265245637; Thu, 30 May 2019 18:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265245; cv=none; d=google.com; s=arc-20160816; b=VqT+Tn11L+9pGXaZWTRROgV7d7meI3TT77ZMsHo9W4EUw26l4n+u2fvtsBtMhyleCP wGcjjzg1XNcVgnP9ikulRREXd57WTis/WYUJ+6mCPQyJvZQqR6fCwLRdHEUJERXY9hjL pvsqrfT7HPY9KfAuZdt9u0ykhxmrZxzJDSHtnlIlCLfGgXn6NYQVSyk4bdoGdfOv0mEu VgPDiKTID9zrJxcnXCqo0RxWQlePHWgT9mI42n/a0hRo+h92YK7Pa/mGdq8RL9+h4nLn 6PY7TCivtoo789JUXmKd6zQRKEoh4YD5cN2o4szJ5PiuDAT0DiFSXlG/iK7XUx2n3PPw 1wIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=/GSo3L74CrMpk122PH7s5v0Pukl/A/+yXOFEsEd3WHE=; b=oB2lBLDeIsvLGTwkMRc10ggE6gTwYMkPIdQt7lKLLVAjuxOmM8GAq14UgImsQJlI5h xl8PdZpdc2anPaEQR7pqWjn/hJQRWkK+PMeh/QQdD6B+0G6fY8f5nhwVLUIT9beoKB0V vu1meUtwtZW06qq01cKFlSq3BEhfNcHbFrfeJ+PK6IyiKmtbKYyljVHeP9C5j4UlJ7HR rYBSZRzg+re8NkhEmDssN/oGtq+KW8wrSm9vmc/opIcS8zfoB9mTl31NUJEFDrjpUSTT QUsa1ZjZOTOmWlcHM5hAxjVCkZMzelg4lTCIOsnhVMiYPhGjenF5zOhhY6LOLdtU+15c QnuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t188si4311661pgc.228.2019.05.30.18.13.44; Thu, 30 May 2019 18:14:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbfEaBMb (ORCPT + 99 others); Thu, 30 May 2019 21:12:31 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46913 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbfEaBMa (ORCPT ); Thu, 30 May 2019 21:12:30 -0400 Received: by mail-wr1-f65.google.com with SMTP id n4so112376wrw.13 for ; Thu, 30 May 2019 18:12:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/GSo3L74CrMpk122PH7s5v0Pukl/A/+yXOFEsEd3WHE=; b=te0MxJEPuSMhpBf69/2zxKm2J5xaCbNn9/ppxI9Pf88ZmEzX2QjanU/f4XE8GpjWto wD4w5A/wAnIwBD5jv2BZDQoBtPpBEUxQ8iv79aNPSEbKGYWtYKI0dBri0njQkgkZSso6 KJQ8E/zMnUXL1hPtXR++jb+LbY5XIGF9BXPOCF0TecQVk11HFYu6hn3BZF/BjiqQXNcq FstuqMuN58xtLQKUXao65xanWHa84ZeZy7lPBaSAZEo6jXTjQVz4RXKXrCR3xuMbcje6 s2h5DbHf4M5551SKayVQDGwz1vV2fbJSB+AV2PuDEcLOe72LG6AUTNqmxsIqFqYQV/+S IYng== X-Gm-Message-State: APjAAAU0oU/QnW5oKTlg/JpdsOuVmYPB4tvYdIKomqKF1iW1M4FEKmeF pIZF/0CSslDpJiKgkVKhoW0ZCQoU0ic= X-Received: by 2002:a5d:5542:: with SMTP id g2mr4277947wrw.232.1559265148873; Thu, 30 May 2019 18:12:28 -0700 (PDT) Received: from raver.teknoraver.net (net-93-144-152-91.cust.vodafonedsl.it. [93.144.152.91]) by smtp.gmail.com with ESMTPSA id p2sm2936448wmp.40.2019.05.30.18.12.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 30 May 2019 18:12:27 -0700 (PDT) From: Matteo Croce To: linux-kernel@vger.kernel.org, Andy Whitcroft , Joe Perches Cc: Kees Cook , Aaron Tomlin , Matthew Wilcox , Andrew Morton Subject: [PATCH v2] checkpatch.pl: Warn on duplicate sysctl local variable Date: Fri, 31 May 2019 03:12:27 +0200 Message-Id: <20190531011227.21181-1-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 6a33853c5773 ("proc/sysctl: add shared variables for range check") adds some shared const variables to be used instead of a local copy in each source file. Warn when a chunk duplicates one of these values in a ctl_table struct: $ scripts/checkpatch.pl 0001-test-commit.patch WARNING: duplicated sysctl range checking value 'zero', consider using the shared one in include/linux/sysctl.h #27: FILE: arch/arm/kernel/isa.c:48: + .extra1 = &zero, WARNING: duplicated sysctl range checking value 'int_max', consider using the shared one in include/linux/sysctl.h #28: FILE: arch/arm/kernel/isa.c:49: + .extra2 = &int_max, total: 0 errors, 2 warnings, 14 lines checked Signed-off-by: Matteo Croce --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 342c7c781ba5..629c31435487 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6639,6 +6639,12 @@ sub process { "unknown module license " . $extracted_string . "\n" . $herecurr); } } + +# check for sysctl duplicate constants + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max|max_int)\b/) { + WARN("DUPLICATED_SYSCTL_CONST", + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr); + } } # If we have no input at all, then there is nothing to report on -- 2.21.0