Skip to contentSkip to conversation

opensm/osm_req.c: Fix transaction id casting

PATCH New Hal Rosenstock 1 participant 1 message Jun 28, 2012 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 opensm/osm_req.c: Fix transaction id casting

cl_atomic() returns signed int32, so without the casting sm_trans_id > 0x7fffffff were messed up.

---
 opensm/osm_req.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
opensm/osm_req.c +6 -3
index 7e9e664..ee2a64e 100644
@@ -91,7 +91,8 @@ ib_api_status_t osm_req_get(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
 		goto Exit;
 	}
 
-	tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id));
+	tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id) &
+						 (uint64_t)(0xFFFFFFFF));
 
 	OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
 		"Getting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64 "\n",
@@ -161,7 +162,8 @@ ib_api_status_t osm_req_set(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
 		goto Exit;
 	}
 
-	tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id));
+	tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id) &
+						 (uint64_t)(0xFFFFFFFF));
 
 	OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
 		"Setting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64 "\n",
@@ -248,7 +250,8 @@ int osm_send_trap144(osm_sm_t * sm, ib_net16_t local)
 	smp->mgmt_class = IB_MCLASS_SUBN_LID;
 	smp->class_ver = 1;
 	smp->method = IB_MAD_METHOD_TRAP;
-	smp->trans_id = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id));
+	smp->trans_id = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id) &
+							   (uint64_t)(0xFFFFFFFF));
 	smp->attr_id = IB_MAD_ATTR_NOTICE;
 
 	ntc = (ib_mad_notice_attr_t *) smp->data;
Signature · 6 lines
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html