Re: [PATCH v3 05/16] KVM: selftests: Add helper to generate random u64 in range [min,max]
From: Josh Hilke
Date: Thu May 28 2026 - 19:02:21 EST
On Tue, May 26, 2026 at 6:58 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Tue, Apr 21, 2026, Josh Hilke wrote:
> > +/* Returns a random u64 in the inclusive range [min, max] */
>
> Put the comment above the definition (But thank you for writing it! I had typed
> up a response asking for exactly this, before I realized it was there, just on
> the declaration).
Will do
> > +uint64_t kvm_random_u64_in_range(struct kvm_random_state *state, uint64_t min, uint64_t max)
>
> Wrap.
Will do.
> > + TEST_ASSERT(min <= max, "min (0x%lx) cannot be greater than max (0x%lx)", min, max);
>
> LOL, that's a rather hilarious error message. Partly because it's so pointless
> (gotta love TEST_ASSERT()), partly because @min obviously _can_ be greater than
> @max :-)
>
> The "min <= max" that gets printed is pretty darn self-explanatory, maybe take
> the opportunity to throw shade at the user/developer?
>
> TEST_ASSERT(min <= max, "PEBKAC, min = 0x%lx, max = 0x%lx", min, max);
I love a good roast ;)