Re: [PATCH v6 09/12] fixup: sha1_file: convert gotos to break/continue

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

 



On 12/05, Jeff Hostetler wrote:
> From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx>
> 

I'm a fan of eliminating looping goto statements.  I understand their
need for doing cleanup, but I think they should be reserved for that
specific case.  Thanks for cleaning this up!

> Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx>
> ---
>  sha1_file.c | 40 ++++++++++++++++++++--------------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/sha1_file.c b/sha1_file.c
> index fc7718a..ce67f27 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -1180,30 +1180,30 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
>  		}
>  	}
>  
> -retry:
> -	if (find_pack_entry(real, &e))
> -		goto found_packed;
> +	while (1) {
> +		if (find_pack_entry(real, &e))
> +			break;
>  
> -	/* Most likely it's a loose object. */
> -	if (!sha1_loose_object_info(real, oi, flags))
> -		return 0;
> +		/* Most likely it's a loose object. */
> +		if (!sha1_loose_object_info(real, oi, flags))
> +			return 0;
>  
> -	/* Not a loose object; someone else may have just packed it. */
> -	reprepare_packed_git();
> -	if (find_pack_entry(real, &e))
> -		goto found_packed;
> -
> -	/* Check if it is a missing object */
> -	if (fetch_if_missing && repository_format_partial_clone &&
> -	    !already_retried) {
> -		fetch_object(repository_format_partial_clone, real);
> -		already_retried = 1;
> -		goto retry;
> -	}
> +		/* Not a loose object; someone else may have just packed it. */
> +		reprepare_packed_git();
> +		if (find_pack_entry(real, &e))
> +			break;
>  
> -	return -1;
> +		/* Check if it is a missing object */
> +		if (fetch_if_missing && repository_format_partial_clone &&
> +		    !already_retried) {
> +			fetch_object(repository_format_partial_clone, real);
> +			already_retried = 1;
> +			continue;
> +		}
> +
> +		return -1;
> +	}
>  
> -found_packed:
>  	if (oi == &blank_oi)
>  		/*
>  		 * We know that the caller doesn't actually need the
> -- 
> 2.9.3
> 

-- 
Brandon Williams



[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]

  Powered by Linux