From: Jeff King <peff@peff.net>
To: Nelson Benitez Leon <nelsonjesus.benitez@seap.minhap.es>
Cc: git@vger.kernel.org, sam@vilain.net
Subject: Re: [PATCH v3 3/4] http: handle proxy proactive authentication
Date: Tue, 6 Mar 2012 05:53:39 -0500 [thread overview]
Message-ID: <20120306105339.GA5013@sigill.intra.peff.net> (raw)
In-Reply-To: <20120306100947.GA710@sigill.intra.peff.net>
On Tue, Mar 06, 2012 at 05:09:47AM -0500, Jeff King wrote:
> > Ok, will remove it, I copy/paste it from the http code and I must admit
> > I didn't understand why this was needed.
>
> Ah. I grepped for the spot you copied. The cast is to get rid of the
> "const" on curl_http_proxy. But if it's a pointer to allocated memory,
> it should not be declared const in the first place. Unfortunately,
> fixing this means casting in the call to git_config_string (which for
> some reason takes a pointer-to-const-pointer, even though the value it
> puts in will always be allocated by xstrdup). Or fixing
> git_config_string, but that cascades to require fixing in lots of other
> places. Ugh.
I did a little more looking into this. The situation is annoyingly
complex, because some callers really do have const strings. They do
things like this:
static const char *prune_expire = "2.weeks.ago";
[...]
git_config_string(&prune_expire, var, value);
And that one should be const, because the string literal really is
const. Sometimes it is converted into an allocated value, but we
effectively treat it as const.
And then you have things like curl_http_proxy, which are never actually
const, but always allocated strings (that get freed during cleanup).
Those ones should probably not be const.
So I don't think there's an easy solution, and the least evil thing is
probably to just keep the cast on free, as you did (although I think if
you convert to using CURLOPT_PROXYUSERPWD, you won't be rewriting
curl_http_proxy anymore, and thus your free() call will go away).
-Peff
prev parent reply other threads:[~2012-03-06 10:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 15:19 [PATCH v3 3/4] http: handle proxy proactive authentication Nelson Benitez Leon
2012-03-06 8:30 ` Jeff King
2012-03-06 10:58 ` Nelson Benitez Leon
2012-03-06 10:09 ` Jeff King
2012-03-06 10:53 ` Jeff King [this message]
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=20120306105339.GA5013@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=nelsonjesus.benitez@seap.minhap.es \
--cc=sam@vilain.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).