Module Name:    src
Committed By:   kre
Date:           Fri Jun 15 07:46:59 UTC 2018

Modified Files:
        src/sys/compat/sys: time_types.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/sys/time_types.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/sys/time_types.h
diff -u src/sys/compat/sys/time_types.h:1.3 src/sys/compat/sys/time_types.h:1.4
--- src/sys/compat/sys/time_types.h:1.3	Fri Jun 15 07:33:27 2018
+++ src/sys/compat/sys/time_types.h	Fri Jun 15 07:46:59 2018
@@ -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 @@ static __inline void timespec_to_timespe
     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;

Reply via email to