something to warry about...

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 21 00:20:59 UTC 2011


On Wednesday 19 January 2011 14:50, Johannes Stezenbach wrote:
> (somehow mail delivery from the list to me seems to be delayed?)
> 
> On Wed, Jan 19, 2011 at 01:20:20PM +0100, Johannes Stezenbach wrote:
> > On Wed, Jan 19, 2011 at 12:43:23PM +0100, Denys Vlasenko wrote:
> > > On Tue, Jan 18, 2011 at 1:22 PM, Johannes Stezenbach <js at sig21.net> wrote:
> > > > +union mii_ifreq {
> > > > +       struct ifreq ifreq;
> > > > +       struct mii_ioctl_data mii;
> > > > +};
> 
> Another variation of the theme: C99 aliasing rules
> also say that any pointer can alias with a char pointer.
> Maybe you like this approach better.
> 
> (compiles, but otherwise untested)
> 
> diff --git a/networking/ifplugd.c b/networking/ifplugd.c
> index 58f56db..4730e01 100644
> --- a/networking/ifplugd.c
> +++ b/networking/ifplugd.c
> @@ -131,18 +131,19 @@ static int network_ioctl(int request, void* data, const char *errmsg)
>  
>  static smallint detect_link_mii(void)
>  {
> -	struct ifreq ifreq;
> -	struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;
> +	char buf[sizeof(struct ifreq)];
> +	struct ifreq *ifreq = (struct ifreq *)buf;
> +	struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data;

This works and look ok.

Thanks!
-- 
vda


More information about the busybox mailing list