[openib-general] [PATCH] ib_mad.c: Fix list handling in ib_mad_recv_done_handler
Sean Hefty
mshefty at ichips.intel.com
Tue Sep 28 10:23:38 PDT 2004
On Tue, 28 Sep 2004 11:12:23 -0400
Hal Rosenstock <halr at voltaire.com> wrote:
> + rbuf = list_entry(&port_priv->recv_posted_mad_list[qpn],
> + struct ib_mad_recv_buf,
> + list);
> + rbuf = (struct ib_mad_recv_buf *)rbuf->list.next;
> + recv = (struct ib_mad_private *)((char *)rbuf -
> + sizeof(struct
> ib_mad_recv_wc));
> +
Can you change this to use container_of, rather than assuming the position of the fields in the structure? I think this would work:
ib_mad_private_header *mad_priv_hdr;
...
mad_priv_hdr = container_of(rbuf, struct ib_mad_private_header, recv_buf);
recv = container_of(mad_priv_hdr, struct ib_mad_private, header);
More information about the general
mailing list