From: Patrick Steinhardt <ps@pks.im>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 2/4] http.c: introduce `set_long_from_env()` for convenience
Date: Thu, 20 Mar 2025 06:24:47 +0100 [thread overview]
Message-ID: <Z9umnwmhZTZ82SnU@pks.im> (raw)
In-Reply-To: <2e39a78e87edaf8f9842e510d05047dce647f4af.1742423021.git.me@ttaylorr.com>
On Wed, Mar 19, 2025 at 06:23:50PM -0400, Taylor Blau wrote:
> diff --git a/http.c b/http.c
> index 0cbcb079b2..17b676a1d5 100644
> --- a/http.c
> +++ b/http.c
> @@ -1256,10 +1256,30 @@ static void set_from_env(char **var, const char *envname)
> }
> }
>
> +static void set_long_from_env(long *var, const char *envname)
> +{
> + const char *val = getenv(envname);
> + if (val) {
> + long tmp;
> + char *endp;
> + int saved_errno = errno;
> +
> + errno = 0;
> + tmp = strtol(val, &endp, 10);
> +
> + if (errno)
> + warning_errno(_("failed to parse %s"), envname);
> + else if (*endp || endp == val)
> + warning(_("failed to parse %s"), envname);
> + else
> + *var = tmp;
> +
> + errno = saved_errno;
> + }
> +}
The `saved_errno` dance feels a bit unnecessary, but other than that I'm
okay with this approach of only printing a warning instead of dying
right away.
The other patches look good to me, too, thanks!
Patrick
next prev parent reply other threads:[~2025-03-20 5:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 22:21 [PATCH 0/3] http: support fine-tuning curl's keepalive behavior Taylor Blau
2025-03-18 22:21 ` [PATCH 1/3] http.c: introduce `set_long_from_env()` for convenience Taylor Blau
2025-03-19 16:00 ` Elijah Newren
2025-03-19 16:00 ` Patrick Steinhardt
2025-03-19 18:02 ` Taylor Blau
2025-03-18 22:21 ` [PATCH 2/3] http.c: inline `set_curl_keepalive()` Taylor Blau
2025-03-19 16:01 ` Elijah Newren
2025-03-18 22:21 ` [PATCH 3/3] http.c: allow custom TCP keepalive behavior via config Taylor Blau
2025-03-19 16:00 ` Patrick Steinhardt
2025-03-19 16:15 ` Elijah Newren
2025-03-19 18:05 ` Taylor Blau
2025-03-19 22:23 ` [PATCH v2 0/4] http: support fine-tuning curl's keepalive behavior Taylor Blau
2025-03-19 22:23 ` [PATCH v2 1/4] http.c: remove unnecessary casts to long Taylor Blau
2025-03-19 22:23 ` [PATCH v2 2/4] http.c: introduce `set_long_from_env()` for convenience Taylor Blau
2025-03-20 5:24 ` Patrick Steinhardt [this message]
2025-04-01 9:10 ` Jeff King
2025-03-19 22:23 ` [PATCH v2 3/4] http.c: inline `set_curl_keepalive()` Taylor Blau
2025-04-01 9:12 ` Jeff King
2025-03-19 22:23 ` [PATCH v2 4/4] http.c: allow custom TCP keepalive behavior via config Taylor Blau
2025-04-01 9:16 ` Jeff King
2025-03-19 22:49 ` [PATCH v2 0/4] http: support fine-tuning curl's keepalive behavior Elijah Newren
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=Z9umnwmhZTZ82SnU@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
/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).