Source-Changes-HG archive

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

[src/trunk]: src/external/bsd avoid pointer gymnastics



details:   https://anonhg.NetBSD.org/src/rev/d1531a558ee7
branches:  trunk
changeset: 790752:d1531a558ee7
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 20 03:14:34 2013 +0000

description:
avoid pointer gymnastics

diffstat:

 external/bsd/bind/dist/lib/isc/sha2.c |  9 +++++----
 external/bsd/dhcpcd/dist/if-bsd.c     |  7 ++++---
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r 8e92dab674c5 -r d1531a558ee7 external/bsd/bind/dist/lib/isc/sha2.c
--- a/external/bsd/bind/dist/lib/isc/sha2.c     Sun Oct 20 03:14:21 2013 +0000
+++ b/external/bsd/bind/dist/lib/isc/sha2.c     Sun Oct 20 03:14:34 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sha2.c,v 1.5 2012/06/05 00:42:31 christos Exp $        */
+/*     $NetBSD: sha2.c,v 1.6 2013/10/20 03:14:34 christos Exp $        */
 
 /*
  * Copyright (C) 2005-2007, 2009, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
@@ -887,7 +887,8 @@
                        *context->buffer = 0x80;
                }
                /* Set the bit count: */
-               *(isc_uint64_t*)&context->buffer[ISC_SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+               memcpy(&context->buffer[ISC_SHA256_SHORT_BLOCK_LENGTH],
+                   &context->bitcount, sizeof(isc_uint64_t));
 
                /* Final transform: */
                isc_sha256_transform(context, (isc_uint32_t*)context->buffer);
@@ -1198,8 +1199,8 @@
                *context->buffer = 0x80;
        }
        /* Store the length of input data (in bits): */
-       *(isc_uint64_t*)&context->buffer[ISC_SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
-       *(isc_uint64_t*)&context->buffer[ISC_SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+       memcpy(&context->buffer[ISC_SHA512_SHORT_BLOCK_LENGTH+8],
+           &context->bitcount[0], sizeof(isc_uint64_t));
 
        /* Final transform: */
        isc_sha512_transform(context, (isc_uint64_t*)context->buffer);
diff -r 8e92dab674c5 -r d1531a558ee7 external/bsd/dhcpcd/dist/if-bsd.c
--- a/external/bsd/dhcpcd/dist/if-bsd.c Sun Oct 20 03:14:21 2013 +0000
+++ b/external/bsd/dhcpcd/dist/if-bsd.c Sun Oct 20 03:14:34 2013 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.1.1.21 2013/09/20 10:51:29 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.2 2013/10/20 03:14:34 christos Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -383,8 +383,9 @@
 #ifdef __KAME__
 #define SCOPE {                                                                      \
                if (IN6_IS_ADDR_LINKLOCAL(&su.sin.sin6_addr)) {               \
-                       *(uint16_t *)(void *)&su.sin.sin6_addr.s6_addr[2] =   \
-                           htons(su.sin.sin6_scope_id);                      \
+                       uint16_t scope = htons(su.sin.sin6_scope_id);         \
+                       memcpy(&su.sin.sin6_addr.s6_addr[2], &scope,          \
+                           sizeof(scope));                                   \
                        su.sin.sin6_scope_id = 0;                             \
                }                                                             \
        }



Home | Main Index | Thread Index | Old Index