diff options
| author | Alice Ryhl <[email protected]> | 2025-06-24 15:27:55 +0000 |
|---|---|---|
| committer | Miguel Ojeda <[email protected]> | 2025-07-15 19:01:48 +0000 |
| commit | 8802e168437840ea0b1d5ca571cd3e95681e9e2b (patch) | |
| tree | 15a8ff5d18ce4eb58e07ac034ee0577634d578d4 /rust/helpers | |
| parent | rust: types: require `ForeignOwnable::into_foreign` return non-null (diff) | |
| download | kernel-8802e168437840ea0b1d5ca571cd3e95681e9e2b.tar.gz kernel-8802e168437840ea0b1d5ca571cd3e95681e9e2b.zip | |
rust: types: add Opaque::cast_from
Since commit b20fbbc08a36 ("rust: check type of `$ptr` in
`container_of!`") we have enforced that the field pointer passed to
container_of! must match the declared field. This caused mismatches when
using a pointer to bindings::x for fields of type Opaque<bindings::x>.
This situation encourages the user to simply pass field.cast() to the
container_of! macro, but this is not great because you might
accidentally pass a *mut bindings::y when the field type is
Opaque<bindings::x>, which would be wrong.
To help catch this kind of mistake, add a new Opaque::cast_from that
wraps a raw pointer in Opaque without changing the inner type. Also
update the docs to reflect this as well as some existing users.
Signed-off-by: Alice Ryhl <[email protected]>
Acked-by: Andreas Hindborg <[email protected]>
Acked-by: Boqun Feng <[email protected]>
Reviewed-by: Danilo Krummrich <[email protected]>
Acked-by: Danilo Krummrich <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Diffstat (limited to 'rust/helpers')
0 files changed, 0 insertions, 0 deletions
