Re: [PATCH 1/5] config: relax requirements on multi-value return

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

 



"Derrick Stolee via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: Derrick Stolee <derrickstolee@xxxxxxxxxx>
>
> The git_configset_get_value() method has an assert() statement
> guaranteeing that the result from git_configset_get_value_multi() is
> either NULL or has at least one element. We want to change that return
> to provide an empty list instead of a NULL list, so change the earlier
> 'return 1' condition to care about a NULL or empty list.

If we are allowing to return an empty string_list from the function
in later steps, the assert() that insists the list has at least 1
item on it will get in the way.  OK.

> Signed-off-by: Derrick Stolee <derrickstolee@xxxxxxxxxx>
> ---
>  config.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/config.c b/config.c
> index cbb5a3bab74..bf89afbdab0 100644
> --- a/config.c
> +++ b/config.c
> @@ -2407,9 +2407,8 @@ int git_configset_get_value(struct config_set *cs, const char *key, const char *
>  	 */
>  	values = git_configset_get_value_multi(cs, key);
>  
> -	if (!values)
> +	if (!values || !values->nr)
>  		return 1;
> -	assert(values->nr > 0);
>  	*value = values->items[values->nr - 1].string;

But we need to guard against an empty list, obviously.  OK.

>  	return 0;
>  }



[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