diff options
| author | Tamir Duberstein <tamird@gmail.com> | 2025-04-16 13:15:43 -0400 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2025-04-23 12:05:23 +0200 |
| commit | 88d5d6a38d5161228fbfe017eb94d777d5e8a0e4 (patch) | |
| tree | 05345b5dedcfeb459934004e67c226c3121fde15 /rust/kernel/str.rs | |
| parent | 1b04b466c873f62413bf65a05a558f036660aedc (diff) | |
rust: alloc: replace `Vec::set_len` with `inc_len`
Rename `set_len` to `inc_len` and simplify its safety contract.
Note that the usage in `CString::try_from_fmt` remains correct as the
receiver is known to have `len == 0`.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/20250416-vec-set-len-v4-4-112b222604cd@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/str.rs')
| -rw-r--r-- | rust/kernel/str.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 878111cb77bc..d3b0b00e05fa 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -886,7 +886,7 @@ impl CString { // SAFETY: The number of bytes that can be written to `f` is bounded by `size`, which is // `buf`'s capacity. The contents of the buffer have been initialised by writes to `f`. - unsafe { buf.set_len(f.bytes_written()) }; + unsafe { buf.inc_len(f.bytes_written()) }; // Check that there are no `NUL` bytes before the end. // SAFETY: The buffer is valid for read because `f.bytes_written()` is bounded by `size` |