From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DDAA3859FD for ; Tue, 7 Jul 2026 18:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783447771; cv=none; b=NAOqT5+5cVnOG/ZqDli267tdxb5DFd+Pds/nPE+CMJmDhjpQxbxsUTy0TomAmfsrr+UNXHxb1wbqTnjbbBI+e16p3VCJAcdtdU+CVkUqkVdG6lpsSaVs0XPt3EtE3sdbSs8GPgl70zvjDq2ZrbP5SXvW8yZLL4QNnBfVofjvFGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783447771; c=relaxed/simple; bh=1KUikAPYiwSj8V14cfpwAS3XiButSOEaifgL3HDqA3U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=LA0ECmTM4/W+vrP9+BC5EQH+MH5qvKt8/3t0bPZvWqaPtAC75jjH9w4pK4rtetMdHKTSCAG6MkuBWNN0u2aG6FBm1t1DnR8hJegkfKIv0zvTXLkuR8mAdJclyyK9BSVspP0mFNjuwMVWfHjtDt9AaNPerXN1wNhNOm9QENVNuGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=wetjLAoq; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KCMcdJ3N; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="wetjLAoq"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KCMcdJ3N" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 505591400026; Tue, 7 Jul 2026 14:09:29 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-10.internal (MEProxy); Tue, 07 Jul 2026 14:09:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1783447769; x=1783534169; bh=k04lYsWA1V 3qiSfDmoKBl1NCLrUo8yOXqB8TATBLDfw=; b=wetjLAoqrTtNlIOei3Eli6ys5O RuDxbI77/8RszD8SQHi9A9Qx/UNpg5fhgesCJpg4dGKa8EJDukAYoTc7wvS23B1s sieN3X+PpAgqnHKkDvlL7kq6I/xHp9nCKUekl+eNoLnifOzb2nJ8WPJklRD8cPVa NYwIF8OVUah4xxS/bYjSsz0HmRb07Qo/MnzUoarOkmRMOm3pbkLO/34erVmDjBNa YR71ZiLdsiWYyv0dJApdChElgJYE2n0qpaZanFZdGz2LHWxw0XC3ZqikZeW3NX0u SKivf7PZFJZaNmaBk/2Utaalo/5jXcib8NMvsP3UkKf8BOtcmBQKT0tPI82w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1783447769; x=1783534169; bh=k04lYsWA1V3qiSfDmoKBl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n5MP06g X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 7 Jul 2026 14:09:27 -0400 (EDT) From: Junio C Hamano To: Pablo Sabater Cc: git@vger.kernel.org, chandrapratap3519@gmail.com, chriscool@tuxfamily.org, eric.peijian@gmail.com, jltobler@gmail.com, karthik.188@gmail.com, peff@peff.net, toon@iotcl.com Subject: Re: [PATCH GSoC v15 02/13] git-compat-util: add `strtoumax_szt()` with error handling In-Reply-To: (Pablo Sabater's message of "Tue, 7 Jul 2026 10:50:41 +0200") References: <20260625-ps-eric-work-rebase-v14-0-09f7ffe21a53@gmail.com> <20260701-ps-eric-work-rebase-v15-0-c88a43b63917@gmail.com> <20260701-ps-eric-work-rebase-v15-2-c88a43b63917@gmail.com> Date: Tue, 07 Jul 2026 11:09:26 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Pablo Sabater writes: >> If you are trying to more explicitly insist that s[] has only >> digits, which may not be a bad idea, as that is what we generally >> expect, then >> >> if (!s[0] || s[strspn(s, "0123456789")]) >> return -1; >> >> perhaps. > > I like the idea of only digits but, even though in this series I only > use this function in base 10, I want the function to work in other > bases, that's why I left the base in the function signature instead of > hardcoding it. strspn(s, "0123456789") rejects bases >10 ("ff" for > base 16) while strtoumax does support higher ones. > I think that it would be better to explicitly reject what we don't > want similarly to "-": Let's step back a bit and think. Where do we plan to use this function? Remember that being a superset is not always necessarily good for a helper function that serves as a format checker. In the output of "git diff master...ps/cat-file-remote-object-info", there is only one caller, which is fetch_object_info(). It reads into object_info_data[].sizep. Do we expect to express the object size in anything but an unsigned decimal integer? Remember that it is better to be unambiguous when designing a protocol. We do not want a third-party reimplementation of whatever is talking to fetch_object_info() to send object size in hex ;-). It may also be usable to parse the size of the object payload in object-file.c::parse_loose_header() but notice that it is already even stricter not to use strto system function and instead handcrafts the trivial number parsing. This would avoid system dependent funnyness, which is a good thing. > if (!*s || isspace((unsigned char)*s) || *s == '-' || *s == '+') > return -1; > > About that, strtoumax works fine with "+" and ignores starting > whitespaces, but for consistency (we reject "-" and whitespaces > between or at the end) rejecting whitespaces and +/- will be better > and make the caller format it correctly. > > I'll do that for the next version.