Prefer __containerof() over __member2struct().
The former works better with qualifiers, but also properly type checks the input pointer.
This commit is contained in:
parent
4c0d7cdf5d
commit
6b946662d9
@ -142,7 +142,8 @@ void t3_process_tid_release_list(void *data, int pending);
|
||||
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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -94,7 +94,7 @@ int do_l2t_write_rpl(struct sge_iq *, const struct rss_header *, struct mbuf *);
|
||||
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);
|
||||
|
@ -3057,8 +3057,8 @@ t4_register_an_handler(struct adapter *sc, an_handler_t h)
|
||||
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);
|
||||
|
@ -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 *
|
||||
|
Loading…
x
Reference in New Issue
Block a user