Thread (331 messages) 331 messages, 12 authors, 18h ago

Re: [PATCH GSoC v18 10/13] transport: add client support for object-info

From: Pablo Sabater <hidden>
Date: 2026-07-15 18:08:36

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help