Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13050875pxu; Sat, 2 Jan 2021 23:55:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3ABSzTk1p5H0v+yJcI27rEtiQ/t60R89/dZUkqCscEdALi+1sI6IMg3VM9VO+V7//RfhM X-Received: by 2002:a17:906:65a:: with SMTP id t26mr55431400ejb.394.1609660542678; Sat, 02 Jan 2021 23:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609660542; cv=none; d=google.com; s=arc-20160816; b=YaJ94LWAK9FP04m0QeUM0YBEvFuOwY8fQExXYw12Op/klsuugyVR4cXWnf6YICxXLW 3Aou0GH0e4beSJxSiQvHcXHt4mTIvKtU7sePU2vgAPVMIAx5HcHM7KVNfH21/U9V3sgX bseT2adW2snIDQeMqlnSTlTsQGE4bHQMRC4dWMwNtvBEoCv93DkjHoqfl1vMoDRrbYw+ Ihp/z7OwwmlvQxOIiVDRp2UeE5l7YsUjy36g174dbLaVFcktKbWIkneZpFX4ruGKhQn5 EDxTFAIeuv6dKkJiJG+r/IIXD52XZTsEidZwO+qnESBnhHfuTwfH8tARz8oOAiJ8bHRc iN0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QzvSaay1vpBL4uNH05Tptc9ZyPGke0vS50orSu+D3Q4=; b=x7sK8B+Qwe9fHLaJJeimjE9HLbWZB3lDdNdSgsZuR1G4ecWVoYIraVK6ojAJ4f4zhO Sm1w/VfTHkGaBV1Knp4/uQ15ADD97++X08wXj0roHfqKGsrkuw0EawJMYMJQQsmcmRxs EPN9bQFaALMZArFf9vQ0+N6wiwwLaZZlVSxPvwULPw3EiolsrK1OApydVLzDZyPP5AhE Q8jnlUn+wLMWdHjRaqxXFLotpFQiTfvdY7Z67gGNF7khAhinsVbkoDfjtwifjfs6RJAO jijESjy3sKfQ6HVlJQQHGO3dnhSaGUIKQ6WCM5YKd8f2WO3wOcqgFci8n27cLdfAIXhC NzLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fau.de header.s=fau-2013 header.b=nN86xNYf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si26762942ejf.90.2021.01.02.23.55.19; Sat, 02 Jan 2021 23:55:42 -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; dkim=pass header.i=@fau.de header.s=fau-2013 header.b=nN86xNYf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726680AbhACHvs (ORCPT + 99 others); Sun, 3 Jan 2021 02:51:48 -0500 Received: from mx-rz-2.rrze.uni-erlangen.de ([131.188.11.21]:51769 "EHLO mx-rz-2.rrze.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbhACHvr (ORCPT ); Sun, 3 Jan 2021 02:51:47 -0500 Received: from mx-rz-smart.rrze.uni-erlangen.de (mx-rz-smart.rrze.uni-erlangen.de [IPv6:2001:638:a000:1025::1e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mx-rz-2.rrze.uni-erlangen.de (Postfix) with ESMTPS id 4D7rY52XgJzPjlR; Sun, 3 Jan 2021 08:51:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fau.de; s=fau-2013; t=1609660265; bh=QzvSaay1vpBL4uNH05Tptc9ZyPGke0vS50orSu+D3Q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:To:CC: Subject; b=nN86xNYf26eIZDbbRPKHuX5a0jHZ915tQn1KpZll7aV0xpHU5UvxRWI9ZXLCX0yZD BS51rvHYMQQ/wsEvmu5avr+WYw3NDUFSZojRGfn+t1V3Mq/gdyLzOCFeiiize0PfXY Sr77cMeFhFUQcRFlsFtra/CFI0oybn016E1p0mKBMyMNruXSf6NZ5CrW3zz5qGtGeG G5BqqhT7RkIlENEwiTeKEJg24F2rrg0XJ7oPt1mcp6VacCtS/o6yUV+WGs3qDIKYQN F+KGoSyLKnQPqULcLbYVVqwHqzJkeA86Fmq5fFuo1ozZZ2FRL8OACBDySPA3HitDS+ ghecvoijKiqAg== X-Virus-Scanned: amavisd-new at boeck1.rrze.uni-erlangen.de (RRZE) X-RRZE-Flag: Not-Spam X-RRZE-Submit-IP: 172.17.10.69 Received: from localhost.localdomain (rat69.ratnet.stw.uni-erlangen.de [172.17.10.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: U2FsdGVkX1/QjcoyQGWNye7Tyj5c5+djQEmW9gyJkNM=) by smtp-auth.uni-erlangen.de (Postfix) with ESMTPSA id 4D7rXy1pz1zPjhV; Sun, 3 Jan 2021 08:50:58 +0100 (CET) From: Nicolai Fischer To: linux-kernel@vger.kernel.org Cc: joe@perches.com, apw@canonical.com, akpm@linux-foundation.org, nicolai.fischer@fau.de, johannes.czekay@fau.de, linux-kernel@i4.cs.fau.de Subject: [PATCH v3 5/5] checkpatch: kconfig: enforce block indentation Date: Sun, 3 Jan 2021 08:50:15 +0100 Message-Id: <20210103075015.23946-6-nicolai.fischer@fau.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210103075015.23946-1-nicolai.fischer@fau.de> References: <20201226140511.662368-1-nicolai.fischer@fau.de> <20210103075015.23946-1-nicolai.fischer@fau.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds a new warning to checkpatch in case a new Kconfig block is not indented one sigle tab more than the keyword which starts it. Co-developed-by: Johannes Czekay Signed-off-by: Johannes Czekay Signed-off-by: Nicolai Fischer --- scripts/checkpatch.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 805b5870803f..8a82ea5c2eb3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3306,7 +3306,8 @@ sub process { # 'choice' is usually the last thing on the line (though # Kconfig supports named choices), so use a word boundary # (\b) rather than a whitespace character (\s) - $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) { + $line =~ /^\+(\s*)(?:config|menuconfig|choice)\b/) { + my $base_indent = $1; my $length = 0; my $cnt = $realcnt; my $ln = $linenr + 1; @@ -3315,6 +3316,7 @@ sub process { my $is_end = 0; my $help_indent; my $help_stat_real; + my $block_stat_real; for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) { $f = $lines[$ln - 1]; $cnt-- if ($lines[$ln - 1] !~ /^-/); @@ -3323,7 +3325,10 @@ sub process { next if ($f =~ /^-/); last if (!$file && $f =~ /^\@\@/); - if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|int|hex|string|prompt)\s*(?:["'].*)?$/) { + if ($lines[$ln - 1] =~ /^\+(\s*)(?:bool|tristate|int|hex|string|prompt)\s*(?:["'].*)?$/) { + if ($1 !~ /^$base_indent\t$/) { + $block_stat_real = get_stat_real($linenr, $ln); + } $is_start = 1; } elsif ($lines[$ln - 1] =~ /^\+(\s*)help$/) { $help_indent = $1; @@ -3358,6 +3363,10 @@ sub process { WARN("CONFIG_DESCRIPTION", "please write a paragraph ($length/$min_conf_desc_length lines) that describes the config symbol fully\n" . $herecurr); } + if ($is_start && $is_end && defined $block_stat_real) { + WARN("CONFIG_DESCRIPTION", + "please indent the block a single tab more than the start\n" . "$here\n$block_stat_real\n"); + } if ($is_start && $is_end && defined $help_stat_real) { WARN("CONFIG_DESCRIPTION", "please indent the help text two spaces more than the keyword\n" . "$here\n$help_stat_real\n"); -- 2.29.2