Re: [PATCH/RFC 2/6] remote-curl.c: fix variable shadowing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 18, 2016, 18:35 UTC
- Message-ID
- <xmqqega26a01.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1460747949-3514-3-git-send-email-dturner@twopensource.com>
David Turner <dturner@twopensource.com> writes:
> The local variable 'options' was shadowing a global of the same name. > > Signed-off-by: David Turner <dturner@twopensource.com> > ---
OK. In general, giving a longer and more descriptive name to the global would be a direction to lead to more readable code, though.
Show 40 quoted lines
> remote-curl.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index 15e48e2..b9b6a90 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -254,7 +254,7 @@ static struct discovery *discover_refs(const char *service, int for_push)
> struct strbuf effective_url = STRBUF_INIT;
> struct discovery *last = last_discovery;
> int http_ret, maybe_smart = 0;
> - struct http_get_options options;
> + struct http_get_options get_options;
>
> if (last && !strcmp(service, last->service))
> return last;
> @@ -271,15 +271,15 @@ static struct discovery *discover_refs(const char *service, int for_push)
> strbuf_addf(&refs_url, "service=%s", service);
> }
>
> - memset(&options, 0, sizeof(options));
> - options.content_type = &type;
> - options.charset = &charset;
> - options.effective_url = &effective_url;
> - options.base_url = &url;
> - options.no_cache = 1;
> - options.keep_error = 1;
> + memset(&get_options, 0, sizeof(get_options));
> + get_options.content_type = &type;
> + get_options.charset = &charset;
> + get_options.effective_url = &effective_url;
> + get_options.base_url = &url;
> + get_options.no_cache = 1;
> + get_options.keep_error = 1;
>
> - http_ret = http_get_strbuf(refs_url.buf, &buffer, &options);
> + http_ret = http_get_strbuf(refs_url.buf, &buffer, &get_options);
> switch (http_ret) {
> case HTTP_OK:
> break;