Re: [PATCH 2/6] parse-options: add precision handling for OPTION_SET_INT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 01, 2025 at 05:54:41PM +0200, René Scharfe wrote:
> On 7/1/25 12:55 PM, Patrick Steinhardt wrote:
> > On Sun, Jun 29, 2025 at 01:50:39PM +0200, René Scharfe wrote:
> >> diff --git a/parse-options.c b/parse-options.c
> >> index da07a000a3..bbb68603cc 100644
> >> --- a/parse-options.c
> >> +++ b/parse-options.c
> >> +static int signed_int_fits(intmax_t value, size_t size)
> >> +{
> >> +	size_t bits = size * CHAR_BIT;
> >> +	intmax_t upper_bound = INTMAX_MAX >> (bitsizeof(intmax_t) - bits);
> >> +	intmax_t lower_bound = -upper_bound - 1;
> >> +	return lower_bound <= value && value <= upper_bound;
> >> +}
> >> +
> > 
> > Should we s/size/precision/ so that it's clear what kind of size this
> > exactly is?
> It's the width of an integer variable as in sizeof(), so the name fits.
> We can inline this single-caller function if it's indeed confusing.

The issue to me is rather that it's unclear what the unit is. Is it size
in bytes, bits, nibbles? You wouldn't know that the expectation is that
the caller passes in `sizeof()` without taking a deeper look.

In any case, this is only a minor nit in the first place, not worth much
bikeshedding.

Patrick




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux