public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: rust: sync: Add SetOnce::reset()
Date: Thu, 04 Jun 2026 12:29:53 +1000	[thread overview]
Message-ID: <review-patch3-20260602172807.1051806-4-lyude@redhat.com> (raw)
In-Reply-To: <20260602172807.1051806-4-lyude@redhat.com>

Patch Review

Adds `reset()` which takes `&mut self` (proving exclusive access), drops the value, and resets `init` to 0.

**Invariant update**: The change from "init may only increase in value" to "init may only increase in value, unless modified through a mutable reference" is correct — `&mut self` guarantees no concurrent observers.

**`drop_val` safety contract**: The `unsafe fn drop_val` has a critical safety requirement:
```rust
/// If this function returns `true`, `self` must be freed or `init` must be reset to `0`.
```
Between `drop_val()` returning `true` and the caller resetting `init`, there's a window where `init == 2` but the value is dropped. This is safe because `&mut self` ensures exclusive access, but the contract is correctly documented. Both callers (`reset` and `Drop`) satisfy it.

**Doctest**: The example is good and demonstrates the full reset/repopulate cycle:
```rust
assert_eq!(value.populate(67), true);
assert_eq!(value.reset(), true);
assert!(value.as_ref().is_none());
assert_eq!(value.reset(), false);
assert_eq!(value.populate(69), true);
```

No issues.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-06-04  2:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 17:24 [PATCH v16 0/6] Rust bindings for gem shmem Lyude Paul
2026-06-02 17:25 ` [PATCH v16 1/6] rust: drm: gem/shmem: Add DmaResvGuard helper Lyude Paul
2026-06-04  2:29   ` Claude review: " Claude Code Review Bot
2026-06-02 17:25 ` [PATCH v16 2/6] rust: drm: gem: Add vmap functions to shmem bindings Lyude Paul
2026-06-04  2:29   ` Claude review: " Claude Code Review Bot
2026-06-02 17:25 ` [PATCH v16 3/6] rust: sync: Add SetOnce::reset() Lyude Paul
2026-06-04  2:29   ` Claude Code Review Bot [this message]
2026-06-02 17:25 ` [PATCH v16 4/6] rust: gem: shmem: Fix Default implementation for ObjectConfig Lyude Paul
2026-06-04  2:29   ` Claude review: " Claude Code Review Bot
2026-06-02 17:25 ` [PATCH v16 5/6] rust: faux: Allow retrieving a bound Device Lyude Paul
2026-06-04  2:29   ` Claude review: " Claude Code Review Bot
2026-06-02 17:25 ` [PATCH v16 6/6] rust: drm: gem: Introduce shmem::Object::sg_table() Lyude Paul
2026-06-04  2:29   ` Claude review: " Claude Code Review Bot
2026-06-04  2:29 ` Claude review: Rust bindings for gem shmem Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-03 19:42 [PATCH v17 0/6] " Lyude Paul
2026-06-03 19:42 ` [PATCH v17 5/6] rust: sync: Add SetOnce::reset() Lyude Paul
2026-06-04  1:29   ` Claude review: " Claude Code Review Bot

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=review-patch3-20260602172807.1051806-4-lyude@redhat.com \
    --to=claude-review@example.com \
    --cc=dri-devel-reviews@example.com \
    /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