lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b150157b266b0aa78e26b1feb5a6b3d7735a2293.camel@perches.com>
Date: Sat, 22 Feb 2025 01:22:25 -0800
From: Joe Perches <joe@...ches.com>
To: Guilherme Giacomo Simoes <trintaeoitogc@...il.com>,
 a.hindborg@...nel.org, 	alex.gaynor@...il.com, aliceryhl@...gle.com,
 apw@...onical.com, arnd@...db.de, 	aswinunni01@...il.com, axboe@...nel.dk,
 benno.lossin@...ton.me, 	bhelgaas@...gle.com, bjorn3_gh@...tonmail.com,
 boqun.feng@...il.com, 	dakr@...nel.org, dwaipayanray1@...il.com,
 ethan.twardy@...il.com, 	fujita.tomonori@...il.com, gary@...yguo.net,
 gregkh@...uxfoundation.org, 	lukas.bulwahn@...il.com, ojeda@...nel.org,
 pbonzini@...hat.com, tmgross@...ch.edu, 	walmeida@...rosoft.com
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 2/2] checkpatch: throw error for malformed arrays

On Fri, 2025-02-21 at 15:21 -0300, Guilherme Giacomo Simoes wrote:
> Implement a check to ensure these fields are correctly formatted. If a
> line contains one of these keys that should be of type Vec<String>, use
> a regex to verify whether the array holds multiple values.
> * If the array contains more than one value, enforce vertical formatting
> * If the array has only one value, it can remain on the same line

Malformed arrays of what type?

[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2775,6 +2775,9 @@ sub process {
>  	$realcnt = 0;
>  	$linenr = 0;
>  	$fixlinenr = -1;
> +
> +	my %array_parse_module;
> +
>  	foreach my $line (@lines) {
>  		$linenr++;
>  		$fixlinenr++;
> @@ -3567,6 +3570,46 @@ sub process {
>  # ignore non-hunk lines and lines being removed
>  		next if (!$hunk_line || $line =~ /^-/);
>  
> +# check if arrays has more than one value in the same line

check if what kind of array otherwise this comment is very poor.
Arrays commonly have more than one value assigned on a single line like

	int foo[] = { 1, 2, 3 };

> +		my $inline = 0;
> +		my $key = "";
> +		my $add_line = $line =~ /^\+/;
> +
> +		if ($line =~ /\s*.*\b(authors|alias|firmware)\s*:\s*\[/) {

The initial "\s*.*" portion of this regex isn't necessary
and can be removed
=
> +			$inline = 1;
> +			$array_parse_module{$1} = 1;
> +		}
> +
> +		my @keys = keys %array_parse_module;
> +		if (@keys) {
> +			$key = $keys[0];
> +		}
> +
> +		if ($add_line && $key) {
> +			my $herevet = "$here\n" . cat_vet($rawline) . "\n";
> +
> +			my $counter = () = $line =~ /"/g;
> +			my $more_than_one = $counter > 2;
> +			if ($more_than_one) {
> +				WARN("ARRAY_MODULE_MACRO",
> +				"Prefer each array element on a separate line\n$herevet");

As I wrote in an earlier submission, please align to open parenthesis
and use the common form for the message with $herevet

				WARN("ARRAY_MODULE_MACRO",
				     "Prefer each array element on a separate line\n" . $herevet);

> +			} elsif ($inline && $line !~ /\]/ && $line !~ /,/ && $line =~ /"/) {
> +				WARN("ARRAY_MODULE_MACRO",
> +				"Prefer declare ] on the same line\n$herevet");

etc...


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ