Re: [PATCH V9 2/2] checkpatch: check format of Vec<String> in modules
From: Joe Perches
Date: Mon Mar 10 2025 - 03:54:10 EST
On Sun, 2025-03-09 at 14:57 -0300, Guilherme Giacomo Simoes wrote:
> Implement a check to ensure that the author, firmware, and alias fields
> of the module! macro are properly formatted.
>
> * If the array contains more than one value, enforce vertical
> formatting.
> * If the array contains only one value, it may be formatted on a single
> line
What happens if the patch contains more than one module?
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +# check if the field is about author, firmware or alias from module! macro and find malformed arrays
> + my $inline = 0;
> + my $key = "";
> + my $add_line = $line =~ /^\+/;
> +
> + if ($line =~ /\b(authors|alias|firmware)\s*:\s*\[/) {
?
> + if ($expected_spaces && $spaces) {
> + if (length($spaces) != length($expected_spaces)) {
spaces contains both spaces and tabs.
Why not test the strings rather than the length?
Otherwise tab-space is the same length as space-tab.
> + WARN("ARRAY_MODULE_MACRO",
> + "Prefer aligned parameters\n" . $herevet_space_add);
Alignment to open parenthesis please.
Why is herevet_space_add more useful than herevet?