On Wed Jul 15, 2026 at 7:22 PM CEST, Junio C Hamano wrote:
Pablo Sabater [off-list ref] writes:
quoted
+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