diff options
| author | Hsiu Che Yu <yu.whisper.personal@gmail.com> | 2026-04-27 22:15:49 +0800 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-05-12 13:56:12 +0200 |
| commit | 75619f2df7a5da6ffb61eedc2a73fdf70c65471c (patch) | |
| tree | 373dd82fef7acde7df007852ed6eef00cb3e8a93 /rust/kernel/alloc/allocator | |
| parent | 254f49634ee16a731174d2ae34bc50bd5f45e731 (diff) | |
rust: alloc: fix assert in `Vec::reserve` doc test
The assert in the doctest used `>= 10`, which only checks that the
capacity can hold `additional` elements, ignoring the existing length
of `v`. The correct check should ensure there is room for `additional`
*extra* elements on top of what is already in the vector.
Fix the assert to use `>= v.len() + 10` so the example accurately
reflects the actual semantics of the function.
Reported-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72nkXWhjK9iFRrhGtkMZGsvNE_zVsu4JnxaFRfxWL7RRdg@mail.gmail.com/
Fixes: 2aac4cd7dae3d ("rust: alloc: implement kernel `Vec` type")
Signed-off-by: Hsiu Che Yu <yu.whisper.personal@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260427-doctest-kvec-reserve-v1-1-0623abcd9c2e@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/alloc/allocator')
0 files changed, 0 insertions, 0 deletions
