Re: [PATCH] checkpatch: Look for Kconfig indentation errors

From: Jani Nikula
Date: Thu Nov 28 2019 - 04:30:04 EST


On Thu, 28 Nov 2019, Krzysztof Kozlowski <krzk@xxxxxxxxxx> wrote:
> Kconfig should be indented with one tab for first level and tab+2 spaces
> for second level. There are many mixups of this so add a checkpatch
> rule.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@xxxxxxxxxx>

I agree unifying the indentation is nice, and without something like
this it'll start bitrotting before Krzysztof's done fixing them all... I
think there's been quite a few fixes merged lately.

I approve of the idea, but I'm clueless about the implementation.

BR,
Jani.


> ---
> scripts/checkpatch.pl | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e41f4adcc1be..875e862cf076 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3046,6 +3046,13 @@ sub process {
> "Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
> }
>
> +# Kconfig has special indentation
> + if ($realfile =~ /Kconfig/ &&
> + ($rawline =~ /^\+ +\t* *[a-zA-Z-]/) || ($rawline =~ /^\+\t( | )[a-zA-Z-]/)) {
> + WARN("CONFIG_INDENTATION",
> + "Kconfig uses one tab indentation, optionally followed by two spaces.\n" . $herecurr);
> + }
> +
> if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
> ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
> my $flag = $1;

--
Jani Nikula, Intel Open Source Graphics Center