Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/fwctl use memcpy to avoid type punned warnings



details:   https://anonhg.NetBSD.org/src/rev/6ba1c2297e70
branches:  trunk
changeset: 768333:6ba1c2297e70
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Aug 14 17:42:23 2011 +0000

description:
use memcpy to avoid type punned warnings

diffstat:

 usr.sbin/fwctl/Makefile    |   7 +------
 usr.sbin/fwctl/fwcontrol.c |  18 ++++++++++++------
 2 files changed, 13 insertions(+), 12 deletions(-)

diffs (64 lines):

diff -r 5b546e51352e -r 6ba1c2297e70 usr.sbin/fwctl/Makefile
--- a/usr.sbin/fwctl/Makefile   Sun Aug 14 16:50:49 2011 +0000
+++ b/usr.sbin/fwctl/Makefile   Sun Aug 14 17:42:23 2011 +0000
@@ -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
diff -r 5b546e51352e -r 6ba1c2297e70 usr.sbin/fwctl/fwcontrol.c
--- a/usr.sbin/fwctl/fwcontrol.c        Sun Aug 14 16:50:49 2011 +0000
+++ b/usr.sbin/fwctl/fwcontrol.c        Sun Aug 14 17:42:23 2011 +0000
@@ -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);
        }



Home | Main Index | Thread Index | Old Index