Date: Sat, 2 Aug 2014 08:34:22 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269431 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys Message-ID: <201408020834.s728YMGW034378@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Sat Aug 2 08:34:22 2014 New Revision: 269431 URL: http://svnweb.freebsd.org/changeset/base/269431 Log: MFV r269427: In dnode_children_t, use C99's "[]" idiom for declaring the variable sized array dnc_children at the end of the structure. This prevents the compiler from mistakenly optimizing away accesses beyond the array's defined size. Illumos issue: 5038 Remove "old-style" flexible array usage in ZFS. Author: Justin T. Gibbs <justing@spectralogic.com> MFC after: 2 weeks Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c Sat Aug 2 07:47:52 2014 (r269430) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c Sat Aug 2 08:34:22 2014 (r269431) @@ -1026,7 +1026,7 @@ dnode_buf_pageout(dmu_buf_t *db, void *a dnh->dnh_dnode = NULL; } kmem_free(children_dnodes, sizeof (dnode_children_t) + - (epb - 1) * sizeof (dnode_handle_t)); + epb * sizeof (dnode_handle_t)); } /* @@ -1111,7 +1111,7 @@ dnode_hold_impl(objset_t *os, uint64_t o int i; dnode_children_t *winner; children_dnodes = kmem_zalloc(sizeof (dnode_children_t) + - (epb - 1) * sizeof (dnode_handle_t), KM_SLEEP); + epb * sizeof (dnode_handle_t), KM_SLEEP); children_dnodes->dnc_count = epb; dnh = &children_dnodes->dnc_children[0]; for (i = 0; i < epb; i++) { @@ -1126,7 +1126,7 @@ dnode_hold_impl(objset_t *os, uint64_t o } kmem_free(children_dnodes, sizeof (dnode_children_t) + - (epb - 1) * sizeof (dnode_handle_t)); + epb * sizeof (dnode_handle_t)); children_dnodes = winner; } } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Sat Aug 2 07:47:52 2014 (r269430) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Sat Aug 2 08:34:22 2014 (r269431) @@ -245,7 +245,7 @@ typedef struct dnode_handle { typedef struct dnode_children { size_t dnc_count; /* number of children */ - dnode_handle_t dnc_children[1]; /* sized dynamically */ + dnode_handle_t dnc_children[]; /* sized dynamically */ } dnode_children_t; typedef struct free_range {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408020834.s728YMGW034378>