Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/sys If we are going to use offsetof() we'd need t...
details: https://anonhg.NetBSD.org/src/rev/9a884133a70d
branches: trunk
changeset: 323428:9a884133a70d
user: kre <kre%NetBSD.org@localhost>
date: Fri Jun 15 07:46:59 2018 +0000
description:
If we are going to use offsetof() we'd need to include <stddef.h> to
get it defined. Rather than deal with potential namespace issues
with that, just clear the entire struct, rather than attempting to
stop after the potential padding field. If the compiler is good enough
it should make no difference (there are just 3 fields, 2 named ones
are assigned to, immediately after the memset() - the compiler can
detect that, and not bother assigning (via memset()) to the unmamed
3rd padding field). If the compiler is not smart enough to deal
with this, then I doubt writing 8 more zero bytes will make enough
difference to matter.
diffstat:
sys/compat/sys/time_types.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (18 lines):
diff -r 0c09aa786fea -r 9a884133a70d sys/compat/sys/time_types.h
--- a/sys/compat/sys/time_types.h Fri Jun 15 07:33:27 2018 +0000
+++ b/sys/compat/sys/time_types.h Fri Jun 15 07:46:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: time_types.h,v 1.3 2018/06/15 07:33:27 mrg Exp $ */
+/* $NetBSD: time_types.h,v 1.4 2018/06/15 07:46:59 kre Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -97,7 +97,7 @@
struct timespec50 *ts50)
{
#if INT32_MAX < LONG_MAX /* scrub padding */
- memset(ts50, 0, offsetof(struct timespec50, tv_nsec));
+ memset(ts50, 0, sizeof(struct timespec50));
#endif
ts50->tv_sec = (int32_t)ts->tv_sec;
ts50->tv_nsec = ts->tv_nsec;
Home |
Main Index |
Thread Index |
Old Index