]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: alloc: fix `Vec::extend_with` SAFETY comment
authorHsiu Che Yu <yu.whisper.personal@gmail.com>
Sat, 25 Apr 2026 10:16:19 +0000 (18:16 +0800)
committerDanilo Krummrich <dakr@kernel.org>
Tue, 12 May 2026 12:00:20 +0000 (14:00 +0200)
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 <yu.whisper.personal@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
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 <dakr@kernel.org>
rust/kernel/alloc/kvec.rs

index 76cbcfb73be2bcda723d65f1da6aee34edd2cf11..ee6361a299424a3b1974eedc9f2d2efd9f82a0e2 100644 (file)
@@ -884,7 +884,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
         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) };