[Lguest] [PATCH] lguest.c: get rid of compiler warnings

Andrew Jones drjones at redhat.com
Wed Dec 8 04:30:18 EST 2010


This is a small cleanup to get rid of compiler warnings when compiling
with strict aliasing turned on.

Signed-off-by: Andrew Jones <drjones at redhat.com>
---
 Documentation/lguest/lguest.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 098de5b..09da807 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -1448,14 +1448,15 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name)
 static void configure_device(int fd, const char *tapif, u32 ipaddr)
 {
 	struct ifreq ifr;
-	struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
+	struct sockaddr_in sin;
+	sin.sin_family = AF_INET;
+	sin.sin_addr.s_addr = htonl(ipaddr);
 
 	memset(&ifr, 0, sizeof(ifr));
 	strcpy(ifr.ifr_name, tapif);
+	memcpy(&ifr.ifr_addr, &sin, sizeof(ifr.ifr_addr));
 
 	/* Don't read these incantations.  Just cut & paste them like I did! */
-	sin->sin_family = AF_INET;
-	sin->sin_addr.s_addr = htonl(ipaddr);
 	if (ioctl(fd, SIOCSIFADDR, &ifr) != 0)
 		err(1, "Setting %s interface address", tapif);
 	ifr.ifr_flags = IFF_UP;
-- 
1.7.1



More information about the Lguest mailing list