[PATCHv2 06/21] 802.1X: Make VLAN-keys a list instead of an array.

Jouni Malinen j
Tue Jun 25 01:04:49 PDT 2013


On Fri, May 17, 2013 at 10:42:33AM +0200, Michael Braun wrote:
> Currently, 802.1X code relies on vlan_id to be a small integer
> so it can use an array to keep them. When increasing the number
> of VLANs supported, this no longer is feasable.

> diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c

> @@ -238,13 +241,21 @@ ieee802_1x_get_group(struct hostapd_data *hapd, struct hostapd_ssid *ssid,
>  		     size_t vlan_id)
>  {
>  	const char *ifname;
> +	int i;
> +	int free = -1;

This results in a compiler warnings with free shadowing a global
declaration (free()). Please use different variable name here.

> +	if (free < 0) {
> +		/* resize array */
> +		int free = ssid->count_dyn_vlan_keys; /* aka oldsize */
> +		int newsize = (free == 0) ? 1 : 2 * free;

And this is even more confusing since the inner free variable would
shadow the other one within this block in the function.

> +	ssid->dyn_vlan_keys[free] = ieee802_1x_group_alloc(hapd, ifname,
> +	                                                   vlan_id);

This going back to using the top level 'free' within the function..

Was this supposed to be two different variables? If so, please use
different names for them (neither of which should be 'free' to avoid
shadowing free()).

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list