Subject: Re: [PATCH v6 10/15] bugreport: add config values from safelist

From: SZEDER Gábor <[email-masked]>
Date: Fri, 7 Feb 2020 15:47:25 +0100

On Wed, Feb 05, 2020 at 04:41:03PM -0800, Emily Shaffer wrote:
> +static void get_safelisted_config(struct strbuf *config_info)
> +{
> +	size_t idx;
> +	struct string_list_item *it = NULL;
> +	struct key_value_info *kv_info = NULL;
> +
> +	for (idx = 0; idx < ARRAY_SIZE(bugreport_config_safelist); idx++) {

GCC 9 complains about this loop condition:

      CC bugreport.o
  
  bugreport.c: In function 'get_safelisted_config':
  
  bugreport.c:66:20: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
  
     66 |  for (idx = 0; idx < ARRAY_SIZE(bugreport_config_safelist); idx++) {
  
        |                    ^

I don't understand this error, that autogenerated
'bugreport_config_safelist' array clearly has a a non-zero size.
What am I missing?

> +		const struct string_list *list =
> +			git_config_get_value_multi(bugreport_config_safelist[idx]);
> +
> +		if (!list)
> +			continue;
> +
> +		strbuf_addf(config_info, "%s:\n", bugreport_config_safelist[idx]);
> +		for_each_string_list_item(it, list) {
> +			kv_info = it->util;
> +			strbuf_addf(config_info, "  %s (%s)\n", it->string,
> +				    kv_info ? config_scope_name(kv_info->scope)
> +					    : "source unknown");
> +		}
> +	}
> +}
> +