rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] rust: alloc: split `Vec::set_len` into `Vec::{inc,dec}_len`
@ 2025-03-18 20:13 Tamir Duberstein
  2025-03-18 20:13 ` [PATCH v2 1/4] rust: alloc: add Vec::len() <= Vec::capacity invariant Tamir Duberstein
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Tamir Duberstein @ 2025-03-18 20:13 UTC (permalink / raw)
  To: Danilo Krummrich, Andrew Ballance, Alice Ryhl, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross
  Cc: rust-for-linux, linux-kernel, Tamir Duberstein

This series is the product of a discussion[0] on the safety requirements
of `set_len`.

This series depends on "rust: alloc: add Vec::truncate method" by Andrew
Ballance <andrewjballance@gmail.com> [1] and rewrites `Vec::truncate`
using `Vec::dec_len`.

Link: https://lore.kernel.org/all/20250315154436.65065-1-dakr@kernel.org/ [0]
Link: https://lore.kernel.org/all/20250316111644.154602-2-andrewjballance@gmail.com/ [1]
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v2:
- Avoid overflow in `set_len`. (Benno Lossin)
- Explained `CString::try_from_fmt` usage of `set_len`. (Benno Lossin,
  Miguel Ojeda, Alice Ryhl)
- Added missing SoB. (Alice Ryhl)
- Prepend a patch documenting `Vec::len() <= Vec::capacity()` invariant.
- Add a patch rewriting `Vec::truncate` in terms of `Vec::dec_len`.
- Link to v1: https://lore.kernel.org/r/20250316-vec-set-len-v1-0-60f98a28723f@gmail.com

---
Tamir Duberstein (4):
      rust: alloc: add Vec::len() <= Vec::capacity invariant
      rust: alloc: add `Vec::dec_len`
      rust: alloc: refactor `Vec::truncate` using `dec_len`
      rust: alloc: replace `Vec::set_len` with `inc_len`

 rust/kernel/alloc/kvec.rs | 87 +++++++++++++++++++++++++++--------------------
 rust/kernel/str.rs        |  2 +-
 rust/kernel/uaccess.rs    |  2 +-
 3 files changed, 53 insertions(+), 38 deletions(-)
---
base-commit: cf25bc61f8aecad9b0c45fe32697e35ea4b13378
change-id: 20250316-vec-set-len-99be6cc48374
prerequisite-patch-id: 85a264a3c7e86025e7b36d91234134f5cc914366

Best regards,
-- 
Tamir Duberstein <tamird@gmail.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-19 13:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 20:13 [PATCH v2 0/4] rust: alloc: split `Vec::set_len` into `Vec::{inc,dec}_len` Tamir Duberstein
2025-03-18 20:13 ` [PATCH v2 1/4] rust: alloc: add Vec::len() <= Vec::capacity invariant Tamir Duberstein
2025-03-18 20:13 ` [PATCH v2 2/4] rust: alloc: add `Vec::dec_len` Tamir Duberstein
2025-03-18 20:13 ` [PATCH v2 3/4] rust: alloc: refactor `Vec::truncate` using `dec_len` Tamir Duberstein
2025-03-18 20:16   ` Tamir Duberstein
2025-03-19  9:53   ` Alice Ryhl
2025-03-19 13:40     ` Tamir Duberstein
2025-03-18 20:13 ` [PATCH v2 4/4] rust: alloc: replace `Vec::set_len` with `inc_len` Tamir Duberstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).