On Tue, Jan 18, 2011 at 1:22 PM, Johannes Stezenbach <[email protected]> wrote:
> I just looked at /usr/include/linux/if.h and ifr_data is not actually
> a char array but a void *. It doesn't matter wrt the aliasing, but it
> might be clearer to use &ifreq.ifr_ifru instead of &ifreq.ifr_data.
>
> The following compiles cleanly (but not tested):
>
> diff --git a/networking/ifplugd.c b/networking/ifplugd.c
> index 58f56db..261ee93 100644
> --- a/networking/ifplugd.c
> +++ b/networking/ifplugd.c
> @@ -129,44 +129,49 @@ static int network_ioctl(int request, void* data, const
> char *errmsg)
>
> /* Link detection routines and table */
>
> +union mii_ifreq {
> + struct ifreq ifreq;
> + struct mii_ioctl_data mii;
> +};
The layout of the union is not what we want.
mii doesn't overlay ifreq.ifr_data.
This doesn't hurm, because you aren't using
the union's overlay match for access, but it's
untypical and therefore confusing.
> static smallint detect_link_mii(void)
> {
> - struct ifreq ifreq;
> - struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
> + union mii_ifreq mii_ifreq;
> + union mii_ifreq *mii = (void *)&mii_ifreq.ifreq.ifr_data;
Here you again assign void** to union mii_ifreq* -
types still do not match.
This doesn't emit warnings probably because gcc
takes a brute-force approach to handling unions
by marking every pointer derived from any union member
"potentially aliases anything". Future versions of gcc
may become "more clever" again, and warnings will return.
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox