ifplugd: eliminate aliasing warnings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-01-20 01:20:36 +01:00
parent 9ad97d5041
commit 53f30b41ec

View File

@ -131,18 +131,20 @@ static int network_ioctl(int request, void* data, const char *errmsg)
static smallint detect_link_mii(void) static smallint detect_link_mii(void)
{ {
struct ifreq ifreq; /* char buffer instead of bona-fide struct avoids aliasing warning */
struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; char buf[sizeof(struct ifreq)];
struct ifreq *ifreq = (void *)buf;
struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data;
set_ifreq_to_ifname(&ifreq); set_ifreq_to_ifname(ifreq);
if (network_ioctl(SIOCGMIIPHY, &ifreq, "SIOCGMIIPHY") < 0) { if (network_ioctl(SIOCGMIIPHY, ifreq, "SIOCGMIIPHY") < 0) {
return IFSTATUS_ERR; return IFSTATUS_ERR;
} }
mii->reg_num = 1; mii->reg_num = 1;
if (network_ioctl(SIOCGMIIREG, &ifreq, "SIOCGMIIREG") < 0) { if (network_ioctl(SIOCGMIIREG, ifreq, "SIOCGMIIREG") < 0) {
return IFSTATUS_ERR; return IFSTATUS_ERR;
} }
@ -151,18 +153,20 @@ static smallint detect_link_mii(void)
static smallint detect_link_priv(void) static smallint detect_link_priv(void)
{ {
struct ifreq ifreq; /* char buffer instead of bona-fide struct avoids aliasing warning */
struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; char buf[sizeof(struct ifreq)];
struct ifreq *ifreq = (void *)buf;
struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data;
set_ifreq_to_ifname(&ifreq); set_ifreq_to_ifname(ifreq);
if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0) { if (network_ioctl(SIOCDEVPRIVATE, ifreq, "SIOCDEVPRIVATE") < 0) {
return IFSTATUS_ERR; return IFSTATUS_ERR;
} }
mii->reg_num = 1; mii->reg_num = 1;
if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1") < 0) { if (network_ioctl(SIOCDEVPRIVATE+1, ifreq, "SIOCDEVPRIVATE+1") < 0) {
return IFSTATUS_ERR; return IFSTATUS_ERR;
} }