Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Add a CTASSERT for the condition required to make a



details:   https://anonhg.NetBSD.org/src/rev/240f7eac374a
branches:  trunk
changeset: 342848:240f7eac374a
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Jan 11 00:46:21 2016 +0000

description:
Add a CTASSERT for the condition required to make a
conditionally-existing union member sort-of safe.

diffstat:

 sys/sys/buf.h |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 379e31505b9c -r 240f7eac374a sys/sys/buf.h
--- a/sys/sys/buf.h     Sun Jan 10 23:01:29 2016 +0000
+++ b/sys/sys/buf.h     Mon Jan 11 00:46:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.h,v 1.121 2015/03/28 19:24:04 maxv Exp $ */
+/*     $NetBSD: buf.h,v 1.122 2016/01/11 00:46:21 dholland Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
@@ -101,13 +101,18 @@
  * For buffers associated with a vnode, b_objlock points to vp->v_interlock.
  * If not associated with a vnode, it points to the generic buffer_lock.
  */
+
+/* required for the conditional union member below to be ~safe */
+__CTASSERT(sizeof(struct work) <= sizeof(TAILQ_ENTRY(buf)));
+
 struct buf {
        union {
                TAILQ_ENTRY(buf) u_actq;
                rb_node_t u_rbnode;
-#if defined(_KERNEL) /* u_work is smaller than u_actq. XXX */
+#if defined(_KERNEL)
+               /* u_work is smaller than u_actq */
                struct work u_work;
-#endif /* defined(_KERNEL) */
+#endif
        } b_u;                                  /* b: device driver queue */
 #define        b_actq  b_u.u_actq
 #define        b_work  b_u.u_work



Home | Main Index | Thread Index | Old Index