Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/route avoid pointer gymnastics
details: https://anonhg.NetBSD.org/src/rev/50e4f9ae47eb
branches: trunk
changeset: 790644:50e4f9ae47eb
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 18 21:01:00 2013 +0000
description:
avoid pointer gymnastics
diffstat:
sbin/route/route.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diffs (57 lines):
diff -r 7f7521a146d8 -r 50e4f9ae47eb sbin/route/route.c
--- a/sbin/route/route.c Fri Oct 18 20:47:06 2013 +0000
+++ b/sbin/route/route.c Fri Oct 18 21:01:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $ */
+/* $NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $ */
/*
* Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $");
+__RCSID("$NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $");
#endif
#endif /* not lint */
@@ -543,8 +543,10 @@
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
sin6.sin6_scope_id == 0) {
- sin6.sin6_scope_id =
- ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);
+ uint16_t scope;
+ memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
+ sizeof(scope));
+ sin6.sin6_scope_id = ntohs(scope);
sin6.sin6_addr.s6_addr[2] = 0;
sin6.sin6_addr.s6_addr[3] = 0;
}
@@ -710,8 +712,10 @@
(IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
sin6.sin6_scope_id == 0) {
- sin6.sin6_scope_id =
- ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);
+ uint16_t scope;
+ memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
+ sizeof(scope));
+ sin6.sin6_scope_id = ntohs(scope);
sin6.sin6_addr.s6_addr[2] = 0;
sin6.sin6_addr.s6_addr[3] = 0;
}
@@ -1259,8 +1263,10 @@
if ((IN6_IS_ADDR_LINKLOCAL(&su->sin6.sin6_addr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&su->sin6.sin6_addr)) &&
su->sin6.sin6_scope_id) {
- *(u_int16_t *)&su->sin6.sin6_addr.s6_addr[2] =
- htons(su->sin6.sin6_scope_id);
+ uint16_t scope;
+ scope = htons(su->sin6.sin6_scope_id);
+ memcpy(&su->sin6.sin6_addr.s6_addr[2], &scope,
+ sizeof(scope));
su->sin6.sin6_scope_id = 0;
}
#endif
Home |
Main Index |
Thread Index |
Old Index