rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tamir Duberstein <tamird@gmail.com>
To: "Danilo Krummrich" <dakr@kernel.org>,
	"Andrew Ballance" <andrewjballance@gmail.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Tamir Duberstein <tamird@gmail.com>
Subject: [PATCH v4 0/4] rust: alloc: split `Vec::set_len` into `Vec::{inc,dec}_len`
Date: Wed, 16 Apr 2025 13:15:39 -0400	[thread overview]
Message-ID: <20250416-vec-set-len-v4-0-112b222604cd@gmail.com> (raw)

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

Link: https://lore.kernel.org/all/20250315154436.65065-1-dakr@kernel.org/ [0]
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v4:
- Rebase on rust/alloc-next to resolve conflict with "rust: alloc: use
  `spare_capacity_mut` to reduce unsafe".
- Link: https://lore.kernel.org/all/20250318-vec-push-use-spare-v3-1-68741671d1af@gmail.com/
- Link to v3: https://lore.kernel.org/r/20250407-vec-set-len-v3-0-c5da0d03216e@gmail.com

Changes in v3:
- Fix compilation (s/ptr/tail/) in "refactor `Vec::truncate` using
  `dec_len`".
- Fix grammar and s/alloc/realloc/ in a safety comment touched by "rust:
  alloc: add Vec::len() <= Vec::capacity invariant".
- Use `if let`. (Alice Ryhl).
- Avoid mutable reference after `drop_in_place`. (Alice Ryhl).
- Rebase on rust/alloc-next.
- Remove dependency on the `Vec::truncate` series which has been merged.
- Link to v2: https://lore.kernel.org/r/20250318-vec-set-len-v2-0-293d55f82d18@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 | 81 +++++++++++++++++++++++++++--------------------
 rust/kernel/str.rs        |  2 +-
 rust/kernel/uaccess.rs    |  2 +-
 3 files changed, 49 insertions(+), 36 deletions(-)
---
base-commit: c3152988c047a7b6abb10d4dc5e24fafbabe8b7e
change-id: 20250316-vec-set-len-99be6cc48374

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


             reply	other threads:[~2025-04-16 17:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 17:15 Tamir Duberstein [this message]
2025-04-16 17:15 ` [PATCH v4 1/4] rust: alloc: add Vec::len() <= Vec::capacity invariant Tamir Duberstein
2025-04-23 10:00   ` Alice Ryhl
2025-04-16 17:15 ` [PATCH v4 2/4] rust: alloc: add `Vec::dec_len` Tamir Duberstein
2025-04-16 17:15 ` [PATCH v4 3/4] rust: alloc: refactor `Vec::truncate` using `dec_len` Tamir Duberstein
2025-04-16 17:15 ` [PATCH v4 4/4] rust: alloc: replace `Vec::set_len` with `inc_len` Tamir Duberstein
2025-04-23 10:10 ` [PATCH v4 0/4] rust: alloc: split `Vec::set_len` into `Vec::{inc,dec}_len` Danilo Krummrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416-vec-set-len-v4-0-112b222604cd@gmail.com \
    --to=tamird@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=andrewjballance@gmail.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).