Module Name:    src
Committed By:   christos
Date:           Sun Aug 14 17:42:23 UTC 2011

Modified Files:
        src/usr.sbin/fwctl: Makefile fwcontrol.c

Log Message:
use memcpy to avoid type punned warnings


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/fwctl/Makefile
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/fwctl/fwcontrol.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/fwctl/Makefile
diff -u src/usr.sbin/fwctl/Makefile:1.5 src/usr.sbin/fwctl/Makefile:1.6
--- src/usr.sbin/fwctl/Makefile:1.5	Tue Jun 21 22:49:45 2011
+++ src/usr.sbin/fwctl/Makefile	Sun Aug 14 13:42:23 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2011/06/22 02:49:45 mrg Exp $
+# $NetBSD: Makefile,v 1.6 2011/08/14 17:42:23 christos Exp $
 
 WARNS?=5
 PROG=	fwctl
@@ -11,8 +11,3 @@
 CPPFLAGS+=-I${.CURDIR} -I${SDIR}
 
 .include <bsd.prog.mk>
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.fwcontrol.c+=	-fno-strict-aliasing
-.endif

Index: src/usr.sbin/fwctl/fwcontrol.c
diff -u src/usr.sbin/fwctl/fwcontrol.c:1.13 src/usr.sbin/fwctl/fwcontrol.c:1.14
--- src/usr.sbin/fwctl/fwcontrol.c:1.13	Tue Jan  4 15:45:13 2011
+++ src/usr.sbin/fwctl/fwcontrol.c	Sun Aug 14 13:42:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fwcontrol.c,v 1.13 2011/01/04 20:45:13 christos Exp $	*/
+/*	$NetBSD: fwcontrol.c,v 1.14 2011/08/14 17:42:23 christos Exp $	*/
 /*
  * Copyright (C) 2002
  * 	Hidetoshi Shimokawa. All rights reserved.
@@ -34,7 +34,7 @@
  */
 #include <sys/cdefs.h>
 //__FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23 2006/10/26 22:33:38 imp Exp $");
-__RCSID("$NetBSD: fwcontrol.c,v 1.13 2011/01/04 20:45:13 christos Exp $");
+__RCSID("$NetBSD: fwcontrol.c,v 1.14 2011/08/14 17:42:23 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -91,8 +91,11 @@
 static void
 fweui2eui64(const struct fw_eui64 *fweui, struct eui64 *eui)
 {
-	*(uint32_t*)&(eui->octet[0]) = htonl(fweui->hi);
-	*(uint32_t*)&(eui->octet[4]) = htonl(fweui->lo);
+	uint32_t hi, lo;
+	hi = htonl(fweui->hi);
+	lo = htonl(fweui->lo);
+	memcpy(&eui->octet[0], &hi, sizeof(hi));
+	memcpy(&eui->octet[4], &lo, sizeof(lo));
 }
 
 static void
@@ -1027,8 +1030,11 @@
 	 * Set the fwmem target for a node to argument "-m"
 	 */
 	if (set_fwmem_target) {
-		eui.hi = ntohl(*(uint32_t*)&(target.octet[0]));
-		eui.lo = ntohl(*(uint32_t*)&(target.octet[4]));
+		uint32_t hi, lo;
+		memcpy(&hi, &target.octet[0], sizeof(hi));
+		memcpy(&lo, &target.octet[4], sizeof(lo));
+		eui.hi = ntohl(hi);
+		eui.lo = ntohl(lo);
 		sysctl_set_int("hw.fwmem.eui64_hi", eui.hi);
 		sysctl_set_int("hw.fwmem.eui64_lo", eui.lo);
 	}

Reply via email to