Re: [PATCH] rust: macros: add authors

From: Daniel Sedlak
Date: Mon Dec 09 2024 - 07:21:39 EST




On 12/7/24 5:07 PM, guilherme giacomo simoes wrote:
Daniel Sedlak <daniel@xxxxxxxxxx> wrote:
Since module is a macro, if we would allow syntax in the macro like:

authors: ["author1", "author2", ...]

I think we could fight with the code formatting, because when it comes
to the rust macros, rustfmt is often very confused and we could end up
with variations like:

authors: ["author1", "author2",
"author3"]

or

authors: [
"author1",
"author2",
]

and rustfmt would be totally ok with both of them.
It seems to me that the rustfmt.toml in the kernel, don't have a max width for
line. Are you sure that the rustfmt would broke the line for big enough lines?

That is not what I meant. See [1] or [2] as an example (there are plenty of those cases).

Link: https://github.com/rust-lang/rustfmt/discussions/5437 [1]
Link: https://users.rust-lang.org/t/rustfmt-skips-macro-arguments/74807 [2]

I think accepting several "author" fields is the best one because it
mirrors the C API, where in C when you want to specify more authors you
just repeat the MODULE_AUTHOR("author<N>") macro.
If you (daniel and miguel) are ok with repeat the `author` field and think that
this is the better option I is happy to make this change.

I am Ok with repeating the field, so I would vote for that. However if Miguel thinks that it is a bad idea, I will not contest that.

I was run the follow command:
grep -rwo 'MODULE_AUTHOR' . | awk -F: '{count[$1]++} END {for (file in count) if (count[file] > 1) print file, count[file]}' | sort -k2 -n > res
for found the modules with more than one MODULE_AUTHOR.
I see that the maximum of MODULE_AUTHOR that is contains in a module is 11.

Thank you for posting your results and working on that.

Daniel