mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonio Hickey <contact@antoniohickey.com>
To: tamird@gmail.com
Cc: a.hindborg@kernel.org, alex.gaynor@gmail.com,
	aliceryhl@google.com, bjorn3_gh@protonmail.com,
	boqun.feng@gmail.com, contact@antoniohickey.com, dakr@kernel.org,
	danielstonecote@gmail.com, gary@garyguo.net,
	linux-kernel@vger.kernel.org, lossin@kernel.org,
	ojeda@kernel.org, rust-for-linux@vger.kernel.org,
	tmgross@umich.edu
Subject: Re: [PATCH v4 1/2] rust: kernel: create `overflow_assert!` macro
Date: Sun, 20 Jul 2025 16:17:40 +0000	[thread overview]
Message-ID: <20250720161733.364025-1-contact@antoniohickey.com> (raw)
In-Reply-To: <CAJ-ks9m45p9FHCvbuOS0zJvZfHMcXOLvN+rfjQfyNTHzDovspA@mail.gmail.com>

Tamir Duberstein wrote:
> On Sat, Jun 28, 2025 at 10:43 PM Antonio Hickey
> <contact@antoniohickey.com> wrote:
> > +//! Overflow assertion.
> > +
> > +/// Verifies at runtime that an expression is within an expected bound.
> 
> This is a strange comment, imo. The only thing special about this
> macro relative to a plain `assert` is that it disabled when
> CONFIG_RUST_OVERFLOW_CHECKS=n.

Special yes, but it also documents the intent of the `assert`.
I did include a comment about the conditional behaviour with 
CONFIG_RUST_OVERFLOW_CHECKS being enabled/disabled. 

I'm open to rewording this doc comment to be better though. 
I should also add information about the optional panic message 
like the `static_assert` does as well, what about something like:

```
/// Overflow assertion.
///
/// Runtime assertion that an expression is within an expected bounds.
///
/// This macro is only enabled when `CONFIG_RUST_OVERFLOW_CHECKS` is true.
///
/// An optional panic message can be supplied after the expression.
/// Currently only a string literal without formatting is supported
/// due to constness limitations of the [`assert!`] macro.
```

Thanks

> 
> > +///
> > +/// This macro is only active when `CONFIG_RUST_OVERFLOW_CHECKS` is enabled.


  reply	other threads:[~2025-07-20 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250629024310.97937-1-contact@antoniohickey.com>
2025-06-29  2:43 ` Antonio Hickey
2025-06-29 16:04   ` Tamir Duberstein
2025-07-20 16:17     ` Antonio Hickey [this message]
2025-07-20 16:23       ` Tamir Duberstein
2025-07-20 16:58   ` Miguel Ojeda
2025-06-29  2:43 ` [PATCH v4 2/2] rust: uaccess: refactor to use `overflow_assert!` Antonio Hickey
2025-06-29 19:01   ` Tamir Duberstein
2025-07-21 11:28   ` Alice Ryhl

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=20250720161733.364025-1-contact@antoniohickey.com \
    --to=contact@antoniohickey.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=danielstonecote@gmail.com \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --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

all inboxes | Powered by JetHome®