Re: [PATCH GSoC v18 10/13] transport: add client support for object-info
- From
Pablo Sabater <pabloosabaterr@gmail.com>
- Date
- Jul 15, 2026, 18:08 UTC
- Message-ID
- <DJZCGKYT43SW.BJZSQ8TO1GF@gmail.com>
- In-Reply-To
- <xmqqpl0onp5d.fsf@gitster.g>
On Wed Jul 15, 2026 at 7:22 PM CEST, Junio C Hamano wrote:
Show 24 quoted lines
> Pablo Sabater <pabloosabaterr@gmail.com> writes:
>
>> +static size_t parse_object_size(const char *s, size_t *res)
>> +{
>> + uintmax_t uim;
>> +
>> + if (!s[0] || s[strspn(s, "0123456789")])
>> + return -1;
>> + errno = 0;
>> + uim = strtoumax(s, NULL, 10);
>> + if (errno || uim > SIZE_MAX)
>> + return -1;
>> + *res = uim;
>> + return 0;
>> +}
>
> Since size_t is unsigned, returning -1 is a bit problematic,
> isn't it? Perhaps this should return a plain 'int' instead.
>
> The sole caller only cares about a boolean "did we succeed or
> fail?" result, and more importantly, the actual size parsed
> is already returned via the out-parameter.
>
> Thanks.Completly true, when I changed this from beign strtoumax_szt() I must have been thinking too much about size_t.
I will change it to return int. Thanks.
Regards, Pablo