Re: [PATCH v6 2/9] rust: sync: Add basic atomic operation mapping framework
"Benno Lossin" <[email protected]> Fri, 11 Jul 2025 10:15:17 +0200
| Newsgroups | dev.linux.lists.lkmm,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Thu Jul 10, 2025 at 10:29 PM CEST, Boqun Feng wrote: > On Thu, Jul 10, 2025 at 09:21:17PM +0200, Benno Lossin wrote: >> On Thu Jul 10, 2025 at 6:16 PM CEST, Boqun Feng wrote: >> > At least the rustdoc has safety section for each function. ;-) >> >> I don't usually use rustdoc to read function safety sections. Instead I >> jump to their definition and read the code. >> > > Understood. It's probalby the first time we use macros to generate a few > unsafe functions, so this is something new. > > But let me ask you a question, as a programmer yourself, when you run > into a code base, and see something repeat in a similar pattern for 10+ > times, what's your instinct? You would try to combine the them together, > right? That's why duplication seems not compelling to me. But surely, we > don't need to draw conclusion right now, however that's my opinion. It all depends, if the definition never changes for a long time, I don't mind the duplication. It's probably more effort to write macros to then have less overall code. It also makes it harder to read especially wrt safety docs. So if you think you will have to make constant tweaks & additions to these, then we should go a macro-heavy route. But if not, then I think making it more readable is the way to go. --- Cheers, Benno