Re: [PATCH v6 11/27] refs.c: introduce get_main_ref_store()

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

 



On 03/18/2017 03:03 AM, Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
>  refs.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/refs.c b/refs.c
> index e7606716dd..2637353b72 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1456,15 +1456,23 @@ static struct ref_store *ref_store_init(const char *submodule)
>  	return refs;
>  }
>  
> +static struct ref_store *get_main_ref_store(void)
> +{
> +	struct ref_store *refs;
> +
> +	if (main_ref_store)
> +		return main_ref_store;
> +
> +	refs = ref_store_init(NULL);
> +	return refs;
> +}
> +

I still [1] think that `refs` here is an unnecessary temporary variable.
And even after your "kill register_ref_store" patch I think it is
superfluous and the function could look like

static struct ref_store *get_main_ref_store(void)
{
	if (!main_ref_store)
		main_ref_store = ref_store_init(NULL);

	return main_ref_store;
}

> [...]

Michael

[1]
http://public-inbox.org/git/0bef1e49-e96b-1666-9b88-f4262c2aeeba@xxxxxxxxxxxx/



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