Date: Fri, 19 Oct 2012 13:26:41 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241733 - in head/sys/dev: cxgb/ulp/tom cxgbe cxgbe/tom Message-ID: <201210191326.q9JDQfGu000947@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Fri Oct 19 13:26:40 2012 New Revision: 241733 URL: http://svn.freebsd.org/changeset/base/241733 Log: Prefer __containerof() over __member2struct(). The former works better with qualifiers, but also properly type checks the input pointer. Modified: head/sys/dev/cxgb/ulp/tom/cxgb_tom.h head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_l2t.h head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_tom.h Modified: head/sys/dev/cxgb/ulp/tom/cxgb_tom.h ============================================================================== --- head/sys/dev/cxgb/ulp/tom/cxgb_tom.h Fri Oct 19 13:05:51 2012 (r241732) +++ head/sys/dev/cxgb/ulp/tom/cxgb_tom.h Fri Oct 19 13:26:40 2012 (r241733) @@ -142,7 +142,8 @@ void t3_process_tid_release_list(void *d static inline struct tom_data * t3_tomdata(struct toedev *tod) { - return (member2struct(tom_data, tod, tod)); + + return (__containerof(tod, struct tom_data, tod)); } union listen_entry { Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Fri Oct 19 13:05:51 2012 (r241732) +++ head/sys/dev/cxgbe/adapter.h Fri Oct 19 13:26:40 2012 (r241733) @@ -435,7 +435,7 @@ static inline struct sge_rxq * iq_to_rxq(struct sge_iq *iq) { - return (member2struct(sge_rxq, iq, iq)); + return (__containerof(iq, struct sge_rxq, iq)); } @@ -450,7 +450,7 @@ static inline struct sge_ofld_rxq * iq_to_ofld_rxq(struct sge_iq *iq) { - return (member2struct(sge_ofld_rxq, iq, iq)); + return (__containerof(iq, struct sge_ofld_rxq, iq)); } #endif Modified: head/sys/dev/cxgbe/t4_l2t.h ============================================================================== --- head/sys/dev/cxgbe/t4_l2t.h Fri Oct 19 13:05:51 2012 (r241732) +++ head/sys/dev/cxgbe/t4_l2t.h Fri Oct 19 13:26:40 2012 (r241733) @@ -94,7 +94,7 @@ int do_l2t_write_rpl(struct sge_iq *, co static inline void t4_l2t_release(struct l2t_entry *e) { - struct l2t_data *d = member2struct(l2t_data, l2tab[e->idx], e); + struct l2t_data *d = __containerof(e, struct l2t_data, l2tab[e->idx]); if (atomic_fetchadd_int(&e->refcnt, -1) == 1) atomic_add_int(&d->nfree, 1); Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Fri Oct 19 13:05:51 2012 (r241732) +++ head/sys/dev/cxgbe/t4_main.c Fri Oct 19 13:26:40 2012 (r241733) @@ -3057,8 +3057,8 @@ t4_register_an_handler(struct adapter *s static int fw_msg_not_handled(struct adapter *sc, const __be64 *rpl) { - __be64 *r = __DECONST(__be64 *, rpl); - struct cpl_fw6_msg *cpl = member2struct(cpl_fw6_msg, data, r); + const struct cpl_fw6_msg *cpl = + __containerof(rpl, struct cpl_fw6_msg, data[0]); #ifdef INVARIANTS panic("%s: fw_msg type %d", __func__, cpl->type); Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Fri Oct 19 13:05:51 2012 (r241732) +++ head/sys/dev/cxgbe/tom/t4_tom.h Fri Oct 19 13:26:40 2012 (r241733) @@ -205,7 +205,7 @@ static inline struct tom_data * tod_td(struct toedev *tod) { - return (member2struct(tom_data, tod, tod)); + return (__containerof(tod, struct tom_data, tod)); } static inline struct adapter *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210191326.q9JDQfGu000947>