From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 1/3] http: offer to cast `size_t` to `curl_off_t` safely
Date: Sun, 21 Sep 2025 07:52:54 -0700 [thread overview]
Message-ID: <xmqqfrcfx3g9.fsf@gitster.g> (raw)
In-Reply-To: <7caaec91020687f09764bbd50477c3fe889fcfed.1758457356.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Sun, 21 Sep 2025 12:22:34 +0000")
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> This commit moves the `xcurl_off_t()` function, which validates that a
> given value fits within the `curl_off_t` data type and then casts it, to
> a more central place so that it can be used outside of `remote-curl.c`,
> too.
>
> At the same time, this function is renamed to conform better with the
> naming convention of the helper functions that safely cast from one data
> type to another which has been well established in `git-compat-util.h`.
OK. The code inside the renamed function is the same with an
updated message to show the value.
> With this move, the error message can unfortunately no longer be renamed
> because the `_(...)` function is not available at the time of
> definition.
It is not clear to me what change (or lack thereof?) in this patch
this paragraph refers to. Who wants to rename what error message
and why?
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> http.h | 10 ++++++++++
> remote-curl.c | 14 +++-----------
> 2 files changed, 13 insertions(+), 11 deletions(-)
Thanks; will queue.
> +static inline curl_off_t cast_size_t_to_curl_off_t(size_t a)
> +{
> + uintmax_t size = a;
> + if (size > maximum_signed_value_of_type(curl_off_t))
> + die(_("number too large to represent as curl_off_t "
> + "on this platform: %"PRIuMAX), (uintmax_t)a);
> + return (curl_off_t)a;
> +}
> +
> -static curl_off_t xcurl_off_t(size_t len)
> -{
> - uintmax_t size = len;
> - if (size > maximum_signed_value_of_type(curl_off_t))
> - die(_("cannot handle pushes this big"));
> - return (curl_off_t)size;
> -}
next prev parent reply other threads:[~2025-09-21 14:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-21 12:22 [PATCH 0/3] Fix curl_easy_setopt() parameter type problem, again Johannes Schindelin via GitGitGadget
2025-09-21 12:22 ` [PATCH 1/3] http: offer to cast `size_t` to `curl_off_t` safely Johannes Schindelin via GitGitGadget
2025-09-21 14:52 ` Junio C Hamano [this message]
2025-09-21 12:22 ` [PATCH 2/3] imap-send: be more careful when casting to `curl_off_t` Johannes Schindelin via GitGitGadget
2025-09-21 15:06 ` Junio C Hamano
2025-09-21 12:22 ` [PATCH 3/3] http-push: avoid new compile error Johannes Schindelin via GitGitGadget
2025-09-21 15:09 ` Junio C Hamano
2025-09-26 10:32 ` [PATCH v2 0/3] Fix curl_easy_setopt() parameter type problem, again Johannes Schindelin via GitGitGadget
2025-09-26 10:32 ` [PATCH v2 1/3] http: offer to cast `size_t` to `curl_off_t` safely Johannes Schindelin via GitGitGadget
2025-09-26 10:32 ` [PATCH v2 2/3] imap-send: be more careful when casting to `curl_off_t` Johannes Schindelin via GitGitGadget
2025-09-26 10:32 ` [PATCH v2 3/3] http-push: avoid new compile error Johannes Schindelin via GitGitGadget
2025-09-26 17:40 ` [PATCH v2 0/3] Fix curl_easy_setopt() parameter type problem, again Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqfrcfx3g9.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).