Module Name: src Committed By: dholland Date: Mon Jan 11 00:46:21 UTC 2016
Modified Files: src/sys/sys: buf.h Log Message: Add a CTASSERT for the condition required to make a conditionally-existing union member sort-of safe. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/sys/buf.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/sys/buf.h diff -u src/sys/sys/buf.h:1.121 src/sys/sys/buf.h:1.122 --- src/sys/sys/buf.h:1.121 Sat Mar 28 19:24:04 2015 +++ src/sys/sys/buf.h Mon Jan 11 00:46:21 2016 @@ -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 @@ extern kmutex_t buffer_lock; * 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