[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] Rewrite mdio_read() in linkdetect.c for strict aliasing rules.
- From: David Cantrell <dcantrell redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH] Rewrite mdio_read() in linkdetect.c for strict aliasing rules.
- Date: Mon, 9 Feb 2009 12:59:53 -1000
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.
---
isys/linkdetect.c | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/isys/linkdetect.c b/isys/linkdetect.c
index fd89db3..cffdd89 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 */
--
1.6.1.2
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]