From owner-svn-src-all@FreeBSD.ORG Fri Oct 19 13:26:41 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8428B4BE; Fri, 19 Oct 2012 13:26:41 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 611CB8FC0A; Fri, 19 Oct 2012 13:26:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9JDQfA6000953; Fri, 19 Oct 2012 13:26:41 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9JDQfGu000947; Fri, 19 Oct 2012 13:26:41 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201210191326.q9JDQfGu000947@svn.freebsd.org> From: Ed Schouten Date: Fri, 19 Oct 2012 13:26:41 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2012 13:26:41 -0000 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 *