[openib-general] Re: [openib-commits] r2063 - in gen2/trunk/src/linux-kernel/infiniband: core include

Libor Michalek libor at topspin.com
Tue Mar 29 12:31:27 PST 2005


On Tue, Mar 29, 2005 at 12:25:44PM -0800, Tom Duffy wrote:
> On Mon, 2005-03-28 at 18:06 -0800, libor at openib.org wrote:
> > Initial commit for kernel portion of the userspace CM interface.
> 
> I am getting a few compile warnings when compiling x86_64:
> 
> It seems that since context is a void*, if you are using this as an id,
> and id is only 32bits, you may lose information on a 64-bit archs.
> 
> This simple patch will fix the last warning:

Hal reported the same issue on ia64. The cast of the id to 32bits won't
lose info, since the assignment to context is from an int. The original
id comes from the idr table and according to idr.c:

   * @id returns a value in the range 0 ... 0x7fffffff

The context should be cast to long before assigning the value to an int
or u32, Here is the full patch:


Index: infiniband/core/ucm.c
===================================================================
--- infiniband/core/ucm.c	(revision 2063)
+++ infiniband/core/ucm.c	(working copy)
@@ -185,7 +185,7 @@
 static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
 				 struct ib_cm_req_event_param *kreq)
 {
-	ureq->listen_id = (int)kreq->listen_id->context;
+	ureq->listen_id = (long)kreq->listen_id->context;
 
 	ureq->remote_ca_guid	     = kreq->remote_ca_guid;
 	ureq->remote_qkey		= kreq->remote_qkey;
@@ -248,7 +248,7 @@
 static void ib_ucm_event_sidr_req_get(struct ib_ucm_sidr_req_event_resp *ureq,
 				      struct ib_cm_sidr_req_event_param *kreq)
 {
-	ureq->listen_id = (int)kreq->listen_id->context;
+	ureq->listen_id = (long)kreq->listen_id->context;
 	ureq->pkey      = kreq->pkey;
 }
 
@@ -383,13 +383,13 @@
 	 */
 	switch (event->event) {
 	case IB_CM_REQ_RECEIVED:
-		id = (int)event->param.req_rcvd.listen_id->context;
+		id = (long)event->param.req_rcvd.listen_id->context;
 		break;
 	case IB_CM_SIDR_REQ_RECEIVED:
-		id = (int)event->param.sidr_req_rcvd.listen_id->context;
+		id = (long)event->param.sidr_req_rcvd.listen_id->context;
 		break;
 	default:
-		id = (int)cm_id->context;
+		id = (long)cm_id->context;
 		break;
 	}
 
@@ -1239,7 +1239,7 @@
 	if (copy_from_user(&hdr, buf, sizeof(hdr)))
 		return -EFAULT;
 
-	printk(KERN_ERR "UCM: Write. cmd <%d> in <%d> out <%d> len <%d>\n",
+	printk(KERN_ERR "UCM: Write. cmd <%d> in <%d> out <%d> len <%Zu>\n",
 	       hdr.cmd, hdr.in, hdr.out, len);
 
 	if (hdr.cmd < 0 || hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))




More information about the general mailing list