[openib-general] [PATCH][CORE] use be32_to_cpu instead of be32_to_cpup
Tom Duffy
tduffy at sun.com
Wed Apr 20 13:48:01 PDT 2005
On Wed, 2005-04-20 at 13:34 -0700, Roland Dreier wrote:
> Those are doing be32_to_cpup() -- notice the "p" at the end, which
> means it dereferences a pointer. be32_to_cpup(&val) is rather
> obfuscated but still technically correct. It's sort of like writing
> "*&val" instead of just "val."
>
> In other words, it's probably worth cleaning up those other places,
> but they're not actually bugs.
Ah, didn't see that. Good eye. I propose the following patch then.
Pointed-out-by: Roland Dreier <roland at topspin.com>
Signed-off-by: Tom Duffy <tduffy at sun.com>
Index: linux-2.6.11-openib/drivers/infiniband/core/agent.c
===================================================================
--- linux-2.6.11-openib/drivers/infiniband/core/agent.c (revision 2198)
+++ linux-2.6.11-openib/drivers/infiniband/core/agent.c (working copy)
@@ -155,10 +155,10 @@ static int agent_mad_send(struct ib_mad_
/* Should sgid be looked up ? */
ah_attr.grh.sgid_index = 0;
ah_attr.grh.hop_limit = grh->hop_limit;
- ah_attr.grh.flow_label = be32_to_cpup(
- &grh->version_tclass_flow) & 0xfffff;
- ah_attr.grh.traffic_class = (be32_to_cpup(
- &grh->version_tclass_flow) >> 20) & 0xff;
+ ah_attr.grh.flow_label = be32_to_cpu(
+ grh->version_tclass_flow) & 0xfffff;
+ ah_attr.grh.traffic_class = (be32_to_cpu(
+ grh->version_tclass_flow) >> 20) & 0xff;
memcpy(ah_attr.grh.dgid.raw,
grh->sgid.raw,
sizeof(ah_attr.grh.dgid));
Index: linux-2.6.11-openib/drivers/infiniband/core/verbs.c
===================================================================
--- linux-2.6.11-openib/drivers/infiniband/core/verbs.c (revision 2198)
+++ linux-2.6.11-openib/drivers/infiniband/core/verbs.c (working copy)
@@ -112,7 +112,7 @@ struct ib_ah *ib_create_ah_from_wc(struc
return ERR_PTR(ret);
ah_attr.grh.sgid_index = (u8) gid_index;
- flow_class = be32_to_cpu(&grh->version_tclass_flow);
+ flow_class = be32_to_cpu(grh->version_tclass_flow);
ah_attr.grh.flow_label = flow_class & 0xFFFFF;
ah_attr.grh.traffic_class = (flow_class >> 20) & 0xFF;
ah_attr.grh.hop_limit = grh->hop_limit;
Index: linux-2.6.11-openib/drivers/infiniband/core/ping.c
===================================================================
--- linux-2.6.11-openib/drivers/infiniband/core/ping.c (revision 2198)
+++ linux-2.6.11-openib/drivers/infiniband/core/ping.c (working copy)
@@ -133,10 +133,10 @@ static int ping_mad_send(struct ib_mad_a
/* Should sgid be looked up ? */
ah_attr.grh.sgid_index = 0;
ah_attr.grh.hop_limit = grh->hop_limit;
- ah_attr.grh.flow_label = be32_to_cpup(
- &grh->version_tclass_flow) & 0xfffff;
- ah_attr.grh.traffic_class = (be32_to_cpup(
- &grh->version_tclass_flow) >> 20) & 0xff;
+ ah_attr.grh.flow_label = be32_to_cpu(
+ grh->version_tclass_flow) & 0xfffff;
+ ah_attr.grh.traffic_class = (be32_to_cpu(
+ grh->version_tclass_flow) >> 20) & 0xff;
memcpy(ah_attr.grh.dgid.raw,
grh->sgid.raw,
sizeof(ah_attr.grh.dgid));
More information about the general
mailing list