rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/2] author field in module! macro should be a array
@ 2025-02-21 18:21 Guilherme Giacomo Simoes
  2025-02-21 18:21 ` [PATCH V4 1/2] rust: module: change author to an array Guilherme Giacomo Simoes
  2025-02-21 18:21 ` [PATCH V4 2/2] checkpatch: throw error for malformed arrays Guilherme Giacomo Simoes
  0 siblings, 2 replies; 6+ messages in thread
From: Guilherme Giacomo Simoes @ 2025-02-21 18:21 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, aliceryhl, apw, arnd, aswinunni01, axboe,
	benno.lossin, bhelgaas, bjorn3_gh, boqun.feng, dakr,
	dwaipayanray1, ethan.twardy, fujita.tomonori, gary, gregkh, joe,
	lukas.bulwahn, ojeda, pbonzini, tmgross, walmeida
  Cc: trintaeoitogc, rust-for-linux, linux-kernel

In the module! macro, the author field is currently of type String.
Since modules can have multiple authors, this limitation prevents
specifying more than one.

- Change the author field to Option<Vec<String>> to allow creating
  modules with multiple authors.

- rename the field from author to authors to make it explicit that it
  can refer to multiple authors.

- In modules that use the author field, update its value to an array of
  strings, and also rename it from author to authors.

- Change the checkpatch.pl to find poorly formatted arrays in the macro
  module!

---
V4 changes 

- Improved checkpatch warning messages
- Improved shiftwidth
- Fixed the regex in checkpatch
---

Guilherme Giacomo Simoes (2):
  rust: module: change author to an array
  checkpatch: throw error for malformed arrays

 drivers/block/rnull.rs               |  2 +-
 rust/kernel/net/phy.rs               |  4 +--
 rust/kernel/pci.rs                   |  2 +-
 rust/macros/lib.rs                   |  6 ++--
 rust/macros/module.rs                | 12 ++++----
 samples/rust/rust_driver_faux.rs     |  2 +-
 samples/rust/rust_driver_pci.rs      |  2 +-
 samples/rust/rust_driver_platform.rs |  2 +-
 samples/rust/rust_minimal.rs         |  2 +-
 samples/rust/rust_misc_device.rs     |  2 +-
 samples/rust/rust_print_main.rs      |  2 +-
 scripts/checkpatch.pl                | 43 ++++++++++++++++++++++++++++
 12 files changed, 63 insertions(+), 18 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH V5 2/2] checkpatch: throw error for malformed arrays
@ 2025-02-23 14:34 Joe Perches
  2025-02-23 15:39 ` [PATCH V4 " Guilherme Giacomo Simoes
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2025-02-23 14:34 UTC (permalink / raw)
  To: Guilherme Giacomo Simoes, a.hindborg, alex.gaynor, aliceryhl, apw,
	arnd, aswinunni01, axboe, benno.lossin, bhelgaas, bjorn3_gh,
	boqun.feng, dakr, dwaipayanray1, ethan.twardy, fujita.tomonori,
	gary, gregkh, lukas.bulwahn, ojeda, pbonzini, tmgross, walmeida
  Cc: rust-for-linux, linux-kernel

On Sat, 2025-02-22 at 21:21 -0300, Guilherme Giacomo Simoes wrote:
> Implement a check to ensure that the author, firmware, and alias fields
> of the module! macro are properly formatted.

Poor email subject.

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3567,6 +3570,46 @@ sub process {
>  # ignore non-hunk lines and lines being removed
>  		next if (!$hunk_line || $line =~ /^-/);
>  
> +# 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*\[/) {
> +			$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);
> +			} elsif ($inline && $line !~ /\]/ && $line !~ /,/ && $line =~ /"/) {
> +				WARN("ARRAY_MODULE_MACRO",
> +				     "Prefer declare ] on the same line\n$herevet");

Convert all the messages.  Use consistent style.

> +			} elsif (!$inline && $line =~ /\]/ && $line =~ /\"/) {
> +				WARN("ARRAY_MODULE_MACRO",
> +				     "Prefer a new line after the last value and before ]\n" . $herevet);
> +			} elsif ($inline && $line =~ /,/ && $line !~ /\]/) {
> +				WARN("ARRAY_MODULE_MACRO",
> +				     "Prefer a new line after [\n$herevet");

twice.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-02-23 15:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 18:21 [PATCH V4 0/2] author field in module! macro should be a array Guilherme Giacomo Simoes
2025-02-21 18:21 ` [PATCH V4 1/2] rust: module: change author to an array Guilherme Giacomo Simoes
2025-02-21 18:21 ` [PATCH V4 2/2] checkpatch: throw error for malformed arrays Guilherme Giacomo Simoes
2025-02-22  9:22   ` Joe Perches
2025-02-22 13:30     ` Guilherme Giacomo Simoes
  -- strict thread matches above, loose matches on Subject: below --
2025-02-23 14:34 [PATCH V5 " Joe Perches
2025-02-23 15:39 ` [PATCH V4 " Guilherme Giacomo Simoes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).