something to warry about...

Cathey, Jim jcathey at ciena.com
Mon Jan 17 17:35:45 UTC 2011


networking/ifplugd.c: In function 'detect_link_priv':
networking/ifplugd.c:163: warning: dereferencing pointer 'mii' does
break strict-aliasing rules
networking/ifplugd.c:155: note: initialized from here

Here's the code:

static smallint detect_link_priv(void)
{
        struct ifreq ifreq;
        struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data;  <======
LINE 155

        set_ifreq_to_ifname(&ifreq);

        if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0)
{
                return IFSTATUS_ERR;
        }

        mii->reg_num = 1; <================= LINE 163

        if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1")
< 0) {
                return IFSTATUS_ERR;
        }

        return (mii->val_out & 0x0004) ? IFSTATUS_UP : IFSTATUS_DOWN;
}

As given, "mii" isn't actually used for much.  Why not
eliminate it and use "ifreq." instead of "mii->" everywhere?

-- Jim



More information about the busybox mailing list