Re: [PATCH 1/4] Reduce url_len variable scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vasyl' Vavrychuk <vvavrychuk@xxxxxxxxx> writes:

> Subject: Re: [PATCH 1/4] Reduce url_len variable scope

Please mark the patch in such a way that the readers can tell what
file/function this patch is about by reading "git shortlog" output
without anything else, i.e.

	Subject: builtin/fetch.c: shorten lifetime of the url_len variable

Hmph.  While this does not bring in any new bug to the code, what benefit
do we gain from it?

The scope is not reduced (even though the variable's lifespan is shortened
in the scope).  Are we so short of registers that this change matters?

>  builtin/fetch.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 357f3cd..2b0b11e 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -385,6 +385,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>  		url_len = i + 1;
>  		if (4 < i && !strncmp(".git", url + i - 3, 4))
>  			url_len = i - 3;
> +		url[url_len] = '\0';
>  
>  		note_len = 0;
>  		if (*what) {
> @@ -399,7 +400,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>  				    rm->old_sha1),
>  			rm->merge ? "" : "not-for-merge",
>  			note);
> -		for (i = 0; i < url_len; ++i)
> +		for (i = 0; url[i]; ++i)
>  			if ('\n' == url[i])
>  				fputs("\\n", fp);
>  			else
> @@ -415,8 +416,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>  				 REFCOL_WIDTH, *what ? what : "HEAD");
>  		if (*note) {
>  			if (verbosity >= 0 && !shown_url) {
> -				fprintf(stderr, "From %.*s\n",
> -						url_len, url);
> +				fprintf(stderr, "From %s\n", url);
>  				shown_url = 1;
>  			}
>  			if (verbosity >= 0)
> -- 
> 1.7.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]