Re: [PATCH v2 2/7] parse-options: add precision handling for PARSE_OPT_CMDMODE

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

 



On 7/9/25 3:58 PM, Patrick Steinhardt wrote:
> On Wed, Jul 09, 2025 at 11:45:14AM +0200, René Scharfe wrote:
>>
>> Call the function that does the raw casting do_get_int_value() to
>> reserve the name get_int_value() for a more friendly wrapper we're
>> going to introduce in one of the next patches.

>> diff --git a/parse-options.c b/parse-options.c
>> index 68ff494492..ddac008a5e 100644
>> --- a/parse-options.c
>> +++ b/parse-options.c
>> @@ -68,6 +68,26 @@ static char *fix_filename(const char *prefix, const char *file)
>>  		return prefix_filename_except_for_dash(prefix, file);
>>  }
>>  
>> +static int do_get_int_value(const void *value, size_t precision, intmax_t *ret)
> 
> Nit: after the fourth patch we have `do_get_int_value()` and
> `get_int_value()`, where the major difference is that the latter dies if
> we failed to parse the value. It might be easier to discern which is
> which if we called them `get_int_value()` and `get_int_value_or_die()`.

That would be misleading because get_int_value() doesn't die() like a
function from write-or-die.c, it BUGs instead.  I don't think it makes
sense to advertise the presence of assertions in a function's name.
But we do have a tradition of using a prefix of "do_" with wrapped
functions that have a more raw interface and do the actual work.

Nit: They don't parse, but cast a void pointer to the appropriate type
and dereference it.

René






[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