Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Avoid strict-alias problem flagged by certain c...
details: https://anonhg.NetBSD.org/src/rev/2f24c131ae25
branches: trunk
changeset: 789735:2f24c131ae25
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Sep 05 17:35:11 2013 +0000
description:
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!)
diffstat:
lib/libc/gen/utmpx.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diffs (36 lines):
diff -r 679ab10617eb -r 2f24c131ae25 lib/libc/gen/utmpx.c
--- a/lib/libc/gen/utmpx.c Thu Sep 05 15:28:07 2013 +0000
+++ b/lib/libc/gen/utmpx.c Thu Sep 05 17:35:11 2013 +0000
@@ -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 @@
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
Home |
Main Index |
Thread Index |
Old Index