Re: [PATCH V2 2/2] checkpatch: throw error in malformed arrays

From: Joe Perches
Date: Sat Feb 15 2025 - 00:24:25 EST


On Fri, 2025-02-14 at 15:45 -0300, Guilherme Giacomo Simoes wrote:
> In module! macro, some fields have a string array type, and we need a
> check for guarantee a good formatation.
> Check if the current line contains one of these keys that must be a
> string array and if so, make a regex for check if contains more than one
> value in array, if yes, the array should be in vertical. If array have
> only one value, so the array can be in the same line.
>
> Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@xxxxxxxxx>
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3567,6 +3570,46 @@ sub process {
[]
> +
> + if ($add_line && $key) {
> + my $herevet = "\n$here\n" . cat_vet($rawline) . "\n";

Please look at the other checkpatch uses of $herevet
$herevet does not begin with '\n'

> +
> + my $counter = () = $line =~ /"/g;
> + my $more_than_one = $counter > 2;
> + if ($more_than_one) {
> + WARN("ARRAY_MODULE_MACRO",
> + "Prefere one value per line$herevet");

Prefer not Prefere
Align to open parenthesis
So this should be
WARN("ARRAY_MODULE_MACRO"
"Prefer one value per line\n" . $herevet);

etc...