Re: [PATCH 1/3] rust: sync: return `Result<&T, T>` from `SetOnce::populate()`
"Alexandre Courbot" <[email protected]> Wed, 29 Jul 2026 23:09:32 +0900
| Newsgroups | org.kernel.vger.linux-modules,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Wed Jul 22, 2026 at 6:16 PM JST, Alice Ryhl wrote: > When `populate()` succeeds, there's no way infallible way to get the > value that was just inserted. By returning &T in this case, such > infallible access methods become possible. > > Additionally, when `populate()` fails, the provided value is dropped. > This has two disadvantages: > > 1. If the caller holds a lock, the value is dropped under said lock. > 2. If the caller wishes to use the same value for something else, they > can't, because it's lost. > > Changing the return value to Result<&T, T> handles all of these cases. > > Rust Binder is updated to avoid a warning about an unused Result. Does the GEM shmem module also need to be updated for the same reason?