Module Name: src Committed By: pooka Date: Thu Sep 5 17:35:11 UTC 2013
Modified Files: src/lib/libc/gen: utmpx.c Log Message: Avoid strict-alias problem flagged by certain compilers (e.g. Centos one): libc/gen/utmpx.c:89: error: dereferencing pointer 'otv' does break strict-aliasing rules reviewed by Christos (thanks!) To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/lib/libc/gen/utmpx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/utmpx.c diff -u src/lib/libc/gen/utmpx.c:1.30 src/lib/libc/gen/utmpx.c:1.31 --- src/lib/libc/gen/utmpx.c:1.30 Sun Jun 24 15:26:03 2012 +++ src/lib/libc/gen/utmpx.c Thu Sep 5 17:35:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: utmpx.c,v 1.30 2012/06/24 15:26:03 christos Exp $ */ +/* $NetBSD: utmpx.c,v 1.31 2013/09/05 17:35:11 pooka Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: utmpx.c,v 1.30 2012/06/24 15:26:03 christos Exp $"); +__RCSID("$NetBSD: utmpx.c,v 1.31 2013/09/05 17:35:11 pooka Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -82,11 +82,12 @@ old2new(struct utmpx *utx) static void new2old(struct utmpx *utx) { - struct timeval tv; - struct otimeval *otv = (void *)&utx->ut_tv; - (void)memcpy(&tv, otv, sizeof(tv)); - otv->tv_sec = (long)tv.tv_sec; - otv->tv_usec = (long)tv.tv_usec; + struct timeval otv; + struct timeval *tv = &utx->ut_tv; + + otv.tv_sec = (long)tv->tv_sec; + otv.tv_usec = (long)tv->tv_usec; + (void)memcpy(tv, &otv, sizeof(otv)); } void