diff options
author | David Cantrell <dcantrell@redhat.com> | 2009-02-09 12:54:57 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2009-02-09 14:43:51 -1000 |
commit | 8a52ee8fc93e0c9a476a56c7e9ed4f8a7d422105 (patch) | |
tree | aea1d54528252fd6d1fc56bb4a784aceb472b48e /isys | |
parent | d0d1a378eff44aa7470ac9767885d029e44f9bac (diff) | |
download | anaconda-8a52ee8fc93e0c9a476a56c7e9ed4f8a7d422105.tar.gz anaconda-8a52ee8fc93e0c9a476a56c7e9ed4f8a7d422105.tar.xz anaconda-8a52ee8fc93e0c9a476a56c7e9ed4f8a7d422105.zip |
Rewrite mdio_read() in linkdetect.c for strict aliasing rules.
Can't cast from a void pointer to struct mii_ioctl_data. Create
a local variable and copy in to struct ifreq and back out again
to do the same thing.
Diffstat (limited to 'isys')
-rw-r--r-- | isys/linkdetect.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/isys/linkdetect.c b/isys/linkdetect.c index fd89db351..cffdd89d4 100644 --- a/isys/linkdetect.c +++ b/isys/linkdetect.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <sys/ioctl.h> #include <string.h> #include <unistd.h> @@ -41,19 +42,26 @@ static struct ifreq ifr; -static int mdio_read(int skfd, int location) +static int mdio_read(int skfd, uint16_t location) { - void *data = &ifr.ifr_data; - struct mii_ioctl_data *mii = data; - mii->reg_num = location; + struct mii_ioctl_data mii; + + memset(&mii, 0, sizeof(mii)); + memcpy(&mii, &ifr.ifr_data, sizeof(mii)); + mii.reg_num = location; + memcpy(&ifr.ifr_data, &mii, sizeof(mii)); + if (ioctl(skfd, SIOCGMIIREG, &ifr) < 0) { #ifdef STANDALONE - fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); + fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name, + strerror(errno)); #endif - return -1; + return -1; + } else { + memcpy(&mii, &ifr.ifr_data, sizeof(mii)); } - return mii->val_out; + + return mii.val_out; } /* we don't need writing right now */ |