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

From: Guilherme Giacomo Simoes
Date: Thu Feb 13 2025 - 13:22:20 EST


Joe Perches <joe@xxxxxxxxxxx> wrotes:
> Isn't this is a style desire not a parsing limitation?
Yes.

> Probably not useful to add hungarian style naming.
hungarian style naminng ? Do you think that is better `array_parse_module` ?

> \s*.* could be just .*
>
> > + $inline = 1;
> > +
> > + if ($line =~ /author/) {
> > + $parse_module_arr{'author'} = 1;
> > + }
> > +
> > + if ($line =~ /alias/) {
> > + $parse_module_arr{'alias'} = 1;
> > + }
> > +
> > + if ($line =~ /firmware/) {
> > + $parse_module_arr{'firmware'} = 1;
> > + }
>
> $parse_module_arr{$1} = 1;
hmm, ok thanks.

> > + if ($line =~ $more_than_one_vl) {
> > + ERROR("ERR_ARRAY_MODULE_MACRO",
> > + "the key $key have more than one values in same line\n$here\n". cat_vet($rawline));
>
> "Prefer one value per line\n"
>
> ERR_ error prefixes are not useful.
> These seem more like a WARN than an ERROR
> Bad indentation
> And please use a $herevet temporary
>
>
> > + }
> > + elsif ($inline && $line !~ /\]/ && $line =~ /\["/) {
> > + ERROR("ERR_ARRAY_MODULE_MACRO",
> > + qq~the key $key need a new line after declare the key\n$here\n~ . cat_vet($rawline) . qq~\nFor example:
>
> Use } elsif
>
> "Prefer declaring keys on separate lines"
>
> Are quote characters allowed in keys?
> If not, this seems unnecessarily complicated.
>
> $herevet
>
> I think the qq is unnecessary and the for example
> should refer to some style documentation and not
> be explicit in checkpatch.
Okay, I will submit a v2 with your hints

Thanks,
Guilherme