[openib-general] [PATCH] SDP warnings on x86_64

Libor Michalek libor at topspin.com
Mon Feb 14 11:29:44 PST 2005


On Fri, Feb 11, 2005 at 09:58:27PM -0800, Grant Grundler wrote:
> On Fri, Feb 11, 2005 at 06:40:58PM -0800, Libor Michalek wrote:
> >   If no one objects, a patch to clean up compile warnings on x86_64.
> 
> I haven't applied this patch yet - I read mail on the other side of
> a firewall where my machines are. But I don't think it will fix
> the compile error below.
> 
> I'm not thrilled about the number of "(void *)(unsigned long)" casts.
> A small inline function to convert (int) to (void *) would be cleaner.
> E.g. (not compiled):
> static inline void * hash_arg(int x) { return (void *)(unsigned long) x; }

  Good idea, in three places I got rid of the cast, and then used an inline
in two other places. Here's the updated patch.

-Libor

Index: infiniband/ulp/sdp/sdp_actv.c
===================================================================
--- infiniband/ulp/sdp/sdp_actv.c	(revision 1778)
+++ infiniband/ulp/sdp/sdp_actv.c	(working copy)
@@ -201,7 +201,7 @@
 	 */
 	if (hello_ack->bsdh.size != sizeof(struct msg_hello_ack)) {
 
-		sdp_dbg_warn(NULL, "hello ack, size mismatch. (2) <%d:%d>",
+		sdp_dbg_warn(NULL, "hello ack, size mismatch. (2) <%d:%Zu>",
 			     hello_ack->bsdh.size,
 			     sizeof(struct msg_hello_ack));
 		return -EINVAL;
@@ -518,7 +518,7 @@
 	path->packet_life = 13;
 #endif
 	conn->cm_id = ib_create_cm_id(sdp_cm_event_handler,
-				      (void *)conn->hashent);
+				      __hashent_arg(conn->hashent));
 	if (NULL == conn->cm_id) {
 
 		sdp_dbg_warn(conn, "Failed to create CM handle, %d",
@@ -571,7 +571,7 @@
 	 */
 	if (sizeof(struct msg_hello) > conn->recv_size) {
 
-		sdp_dbg_warn(conn, "buffer size <%d> too small. <%d>",
+		sdp_dbg_warn(conn, "buffer size <%d> too small. <%Zu>",
 			     conn->recv_size, sizeof(struct msg_hello));
 		result = -ENOBUFS;
 		goto error;
Index: infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- infiniband/ulp/sdp/sdp_conn.c	(revision 1778)
+++ infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -1085,7 +1085,8 @@
 		conn->send_cq = ib_create_cq(conn->ca,
 					     sdp_cq_event_handler,
 					     NULL,
-					     (void *)conn->hashent,
+					     (void *)
+					     (unsigned long)conn->hashent,
 					     conn->send_cq_size);
 		if (IS_ERR(conn->send_cq)) {
 
@@ -1110,7 +1111,8 @@
 		conn->recv_cq = ib_create_cq(conn->ca,
 					     sdp_cq_event_handler,
 					     NULL,
-					     (void *)conn->hashent,
+					     (void *)
+					     (unsigned long)conn->hashent,
 					     conn->recv_cq_size);
 
 		if (IS_ERR(conn->recv_cq)) {
Index: infiniband/ulp/sdp/sdp_conn.h
===================================================================
--- infiniband/ulp/sdp/sdp_conn.h	(revision 1778)
+++ infiniband/ulp/sdp/sdp_conn.h	(working copy)
@@ -481,6 +481,11 @@
 #define SDP_CONN_PUT(conn)  __sdp_conn_put((conn))
 #define SDP_CONN_ERROR(conn)  __sdp_conn_error((conn))
 
+static inline void *__hashent_arg(s32 hashent) 
+{
+	return (void *)(unsigned long)hashent;
+}
+
 #endif /* _SDP_CONN_H */
 
 
Index: infiniband/ulp/sdp/sdp_iocb.c
===================================================================
--- infiniband/ulp/sdp/sdp_iocb.c	(revision 1778)
+++ infiniband/ulp/sdp/sdp_iocb.c	(working copy)
@@ -44,7 +44,7 @@
 	vma = find_vma(iocb->mm, (iocb->addr & PAGE_MASK));
 	if (NULL == vma) {
 		
-		sdp_warn("No VMA for IOCB <%lx:%d> unlock",
+		sdp_warn("No VMA for IOCB <%lx:%Zu> unlock",
 			 iocb->addr, iocb->size);
 	}
 
@@ -286,7 +286,7 @@
 	 */
 	if (result) {
 
-		sdp_dbg_err("VMA lock <%lx:%d> error <%d> <%d:%lu:%lu>",
+		sdp_dbg_err("VMA lock <%lx:%Zu> error <%d> <%d:%lu:%lu>",
 			    iocb->addr, iocb->size, result, 
 			    iocb->page_count, iocb->mm->locked_vm, limit);
 		goto err_lock;
@@ -300,7 +300,7 @@
 		/*
 		 * sanity check.
 		 */
-		sdp_warn("No VMA for IOCB! <%lx:%d> lock",
+		sdp_warn("No VMA for IOCB! <%lx:%Zu> lock",
 			 iocb->addr, iocb->size);
 	}
 
@@ -342,7 +342,7 @@
 	result = _sdp_iocb_page_save(iocb);
 	if (result) {
 
-		sdp_dbg_err("Error <%d> saving pages for IOCB <%lx:%d>", 
+		sdp_dbg_err("Error <%d> saving pages for IOCB <%lx:%Zu>", 
 			    result, iocb->addr, iocb->size);
 		goto err_save;
 	}
@@ -584,7 +584,7 @@
 	result = sdp_iocb_destroy(iocb);
 	if (0 > result) {
 
-		sdp_dbg_err("Error <%d> deleting IOCB <%d> of status <%d>",
+		sdp_dbg_err("Error <%d> deleting IOCB <%d> of status <%Zu>",
 			    result, iocb->key, iocb->status);
 	}
 
@@ -924,8 +924,8 @@
 
 		if (0 < (mask & iocb->flags) || SDP_IOCB_F_ALL == mask) {
 
-			sdp_dbg_err("IOCB <%d> cancel <%d> flag <%04x> "
-				    "size <%d:%d:%d>",
+			sdp_dbg_err("IOCB <%d> cancel <%Zu> flag <%04x> "
+				    "size <%Zu:%d:%d>",
 				    iocb->key, comp, iocb->flags, iocb->size,
 				    iocb->post, iocb->len);
 
Index: infiniband/ulp/sdp/sdp_pass.c
===================================================================
--- infiniband/ulp/sdp/sdp_pass.c	(revision 1778)
+++ infiniband/ulp/sdp/sdp_pass.c	(working copy)
@@ -41,7 +41,7 @@
 	 */
 	if (sizeof(struct msg_hello_ack) > conn->recv_size) {
 
-		sdp_dbg_warn(conn, "buffer size <%d> too small. <%d>",
+		sdp_dbg_warn(conn, "buffer size <%d> too small. <%Zu>",
 			     conn->recv_size, sizeof(struct msg_hello_ack));
 		result = -ENOBUFS;
 		goto error;
@@ -311,7 +311,7 @@
 	 */
 	if (msg_hello->bsdh.size != sizeof(struct msg_hello)) {
 
-		sdp_dbg_warn(NULL, "hello msg size mismatch. (2) <%d:%d>",
+		sdp_dbg_warn(NULL, "hello msg size mismatch. (2) <%d:%Zu>",
 			     msg_hello->bsdh.size, sizeof(struct msg_hello));
 		return -EINVAL;
 	}
@@ -438,7 +438,7 @@
 	 * update CM context to refer to the connection.
 	 */
 	conn->cm_id          = cm_id;
-	conn->cm_id->context = (void *)(unsigned long)conn->hashent;
+	conn->cm_id->context = __hashent_arg(conn->hashent);
 	/*
 	 * associate connection with a hca/port, and allocate IB.
 	 */
Index: infiniband/ulp/sdp/sdp_proc.c
===================================================================
--- infiniband/ulp/sdp/sdp_proc.c	(revision 1778)
+++ infiniband/ulp/sdp/sdp_proc.c	(working copy)
@@ -169,7 +169,7 @@
 	 */
 	if (0 && sizeof(s32) != sizeof(char *)) {
 
-		sdp_warn("integers and pointers of a different size. <%d:%d>",
+		sdp_warn("integers and pointers of a different size <%Zu:%Zu>",
 			 sizeof(s32), sizeof(char *));
 		return -EFAULT;
 	}
Index: infiniband/ulp/sdp/sdp_recv.c
===================================================================
--- infiniband/ulp/sdp/sdp_recv.c	(revision 1781)
+++ infiniband/ulp/sdp/sdp_recv.c	(working copy)
@@ -799,8 +799,9 @@
 	result = _sdp_read_buff_iocb(iocb, buff);
 	if (0 > result) {
 
-		sdp_dbg_warn(conn, "Error <%d> data copy <%d:%d> to IOCB",
-			     result, iocb->len, (buff->tail - buff->data));
+		sdp_dbg_warn(conn, "Error <%d> data copy <%d:%u> to IOCB",
+			     result, iocb->len, 
+			     (unsigned)(buff->tail - buff->data));
 
 		(void)sdp_iocb_q_put_head(&conn->r_snk, iocb);
 		return result;
@@ -850,8 +851,9 @@
 	result = _sdp_read_buff_iocb(iocb, buff);
 	if (0 > result) {
 
-		sdp_dbg_warn(conn, "Error <%d> data copy <%d:%d> to IOCB",
-			     result, iocb->len, (buff->tail - buff->data));
+		sdp_dbg_warn(conn, "Error <%d> data copy <%d:%u> to IOCB",
+			     result, iocb->len, 
+			     (unsigned)(buff->tail - buff->data));
 		return result;
 	}
 	/*
@@ -1003,12 +1005,12 @@
 static int _sdp_read_src_lookup(struct sdpc_desc *element, void *arg)
 {
 	struct sdpc_iocb *iocb = (struct sdpc_iocb *) element;
-	u32 value = (u32)(unsigned long)arg;
+	struct kiocb *req = (struct kiocb *)arg;
 
 	SDP_CHECK_NULL(element, -EINVAL);
 
 	if (SDP_DESC_TYPE_IOCB == element->type && 
-	    iocb->key == value) {
+	    iocb->key == req->ki_key) {
 
 		return 0;
 	}
@@ -1111,7 +1113,7 @@
 	 */
 	iocb = (struct sdpc_iocb *)sdp_desc_q_lookup(&conn->r_src,
 						     _sdp_read_src_lookup,
-						     (void *)req->ki_key);
+						     req);
 	if (NULL != iocb) {
 
 		iocb->flags |= SDP_IOCB_F_CANCEL;
@@ -1623,7 +1625,7 @@
 			if (NULL == iocb) {
         
 				sdp_dbg_warn(conn, 
-					     "Failed to allocate IOCB <%d:%d>",
+					     "Error allocating IOCB <%Zu:%d>",
 					     size, copied);
 				result = -ENOMEM;
 				break;
@@ -1642,7 +1644,7 @@
 			if (0 > result) {
         
 				sdp_dbg_warn(conn, 
-					     "Error <%d> IOCB lock <%d:%d>", 
+					     "Error <%d> IOCB lock <%Zu:%d>", 
 					     result, size, copied);
 				
 				(void)sdp_iocb_destroy(iocb);
@@ -1655,7 +1657,7 @@
 			if (0 > result) {
 				
 				sdp_dbg_warn(conn, 
-					     "Error <%d> IOCB queue <%d:%d>",
+					     "Error <%d> IOCB queue <%Zu:%d>",
 					     result, size, copied);
 				
 				(void)sdp_iocb_destroy(iocb);
Index: infiniband/ulp/sdp/sdp_send.c
===================================================================
--- infiniband/ulp/sdp/sdp_send.c	(revision 1781)
+++ infiniband/ulp/sdp/sdp_send.c	(working copy)
@@ -1964,11 +1964,11 @@
 static int _sdp_write_src_lookup(struct sdpc_desc *element, void *arg)
 {
 	struct sdpc_iocb *iocb = (struct sdpc_iocb *) element;
-	u32 value = (u32)(unsigned long)arg;
+	struct kiocb *req = (struct kiocb *)arg;
 
 	SDP_CHECK_NULL(element, -EINVAL);
 
-	if (SDP_DESC_TYPE_IOCB == element->type && iocb->key == value) {
+	if (SDP_DESC_TYPE_IOCB == element->type && iocb->key == req->ki_key) {
 
 		return 0;
 	}
@@ -2016,13 +2016,13 @@
 	 */
 	iocb = (struct sdpc_iocb *)sdp_desc_q_lookup(&conn->send_queue,
 						     _sdp_write_src_lookup,
-						     (void *)req->ki_key);
+						     req);
 	if (NULL != iocb) {
 		/*
 		 * always remove the IOCB.
 		 * If active, then place it into the correct active queue
 		 */
-		result = sdp_desc_q_remove((struct sdpc_desc *) iocb);
+		result = sdp_desc_q_remove((struct sdpc_desc *)iocb);
 		SDP_EXPECT(!(0 > result));
 		
 		if (0 < (SDP_IOCB_F_ACTIVE & iocb->flags)) {
@@ -2075,7 +2075,8 @@
 	 */
 	iocb = (struct sdpc_iocb *)sdp_desc_q_lookup(&conn->w_snk,
 						     _sdp_write_src_lookup,
-						     (void *)req->ki_key);
+						     req);
+
 	if (NULL != iocb) {
 
 		iocb->flags |= SDP_IOCB_F_CANCEL;
@@ -2439,7 +2440,7 @@
 		iocb = sdp_iocb_create();
 		if (NULL == iocb) {
 			
-			sdp_dbg_warn(conn, "Failed to allocate IOCB <%d:%d>",
+			sdp_dbg_warn(conn, "Failed to allocate IOCB <%Zu:%d>",
 				     size, copied);
 			result = -ENOMEM;
 			break;
@@ -2457,7 +2458,7 @@
 		result = sdp_iocb_lock(iocb);
 		if (0 > result) {
 				
-			sdp_dbg_warn(conn, "Error <%d> locking IOCB <%d:%d>", 
+			sdp_dbg_warn(conn, "Error <%d> locking IOCB <%Zu:%d>", 
 				     result, size, copied);
         
 			(void)sdp_iocb_destroy(iocb);



More information about the general mailing list