From: Hsiu Che Yu Date: Sat, 25 Apr 2026 10:16:19 +0000 (+0800) Subject: rust: alloc: fix `Vec::extend_with` SAFETY comment X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f497aae6ded43f91b1dbf29a35d7062823635640;p=thirdparty%2Fkernel%2Flinux.git rust: alloc: fix `Vec::extend_with` SAFETY comment Fix an incorrect operator in the SAFETY comment, changing `<` to `<=`, since `Vec::reserve` guarantees capacity for exactly n additional elements, so the equal case should be included. Signed-off-by: Hsiu Che Yu Reviewed-by: Alexandre Courbot Fixes: 2aac4cd7dae3d ("rust: alloc: implement kernel `Vec` type") Link: https://patch.msgid.link/18fc8eee2f057a6bfbcadae156d1d0b7c40d0077.1777111268.git.yu.whisper.personal@gmail.com Signed-off-by: Danilo Krummrich --- diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs index 76cbcfb73be2b..ee6361a299424 100644 --- a/rust/kernel/alloc/kvec.rs +++ b/rust/kernel/alloc/kvec.rs @@ -884,7 +884,7 @@ impl Vec { spare[n - 1].write(value); // SAFETY: - // - `self.len() + n < self.capacity()` due to the call to reserve above, + // - `self.len() + n <= self.capacity()` due to the call to reserve above, // - the loop and the line above initialized the next `n` elements. unsafe { self.inc_len(n) };