Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: refcount: always inline functions using build_assert with arguments

`build_assert` relies on the compiler to optimize out its error path.
Functions using it with its arguments must thus always be inlined,
otherwise the error path of `build_assert` might not be optimized out,
triggering a build error.

Cc: stable@vger.kernel.org
Fixes: bb38f35b35f9 ("rust: implement `kernel::sync::Refcount`")
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251208-io-build-assert-v3-5-98aded02c1ea@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Alexandre Courbot and committed by
Miguel Ojeda
d6ff6e87 09c3c911

+2 -1
+2 -1
rust/kernel/sync/refcount.rs
··· 23 23 /// Construct a new [`Refcount`] from an initial value. 24 24 /// 25 25 /// The initial value should be non-saturated. 26 - #[inline] 26 + // Always inline to optimize out error path of `build_assert`. 27 + #[inline(always)] 27 28 pub fn new(value: i32) -> Self { 28 29 build_assert!(value >= 0, "initial value saturated"); 29 30 // SAFETY: There are no safety requirements for this FFI call.