[openib-general] [PATCH] positive error values cleanup

Michael S. Tsirkin mst at mellanox.co.il
Wed Jun 15 02:47:47 PDT 2005


sdp_cm_actv_error and sdp_conn_inet_error were accepting
positive result as error value, and inverting it internally.
Clean this up and do a couple of cosmetic cleanups as well.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: sdp_inet.c
===================================================================
--- sdp_inet.c	(revision 2608)
+++ sdp_inet.c	(working copy)
@@ -278,7 +278,7 @@ error:
 	/*
 	 * abortive close.
 	 */
-	sdp_conn_inet_error(conn, ECONNRESET);
+	sdp_conn_inet_error(conn, -ECONNRESET);
 	(void)ib_send_cm_dreq(conn->cm_id, NULL, 0);
 
 	return result;
Index: sdp_conn.c
===================================================================
--- sdp_conn.c	(revision 2608)
+++ sdp_conn.c	(working copy)
@@ -84,21 +84,21 @@ void sdp_conn_inet_error(struct sdp_opt 
 	(void)sdp_inet_accept_q_remove(conn);
 
 	SDP_CONN_ST_SET(conn, SDP_CONN_ST_ERROR);
-	SDP_CONN_SET_ERR(conn, error);
+	SDP_CONN_SET_ERR(conn, -error);
 	conn->shutdown = SHUTDOWN_MASK;
 	conn->send_buf = 0;
 
 	if (conn->sk->sk_socket)
 		conn->sk->sk_socket->state = SS_UNCONNECTED;
 
-	sdp_iocb_q_cancel_all(conn, -error);
+	sdp_iocb_q_cancel_all(conn, error);
 	sdp_inet_wake_error(conn->sk);
 }
 
 void sdp_conn_abort(struct sdp_opt *conn)
 {
 	int result;
-	int error = ECONNRESET;
+	int error = -ECONNRESET;
 
 	sdp_dbg_ctrl(conn, "Abort send. src <%08x:%04x> dst <%08x:%04x>",
 		     conn->src_addr, conn->src_port, 
@@ -133,7 +133,7 @@ void sdp_conn_abort(struct sdp_opt *conn
 
 		conn->flags &= ~SDP_CONN_F_DIS_PEND;
 	case SDP_CONN_ST_DIS_RECV_1:
-		error = EPIPE;
+		error = -EPIPE;
 	case SDP_CONN_ST_ESTABLISHED:
 		/*
 		 * abortive close.
@@ -150,7 +150,7 @@ void sdp_conn_abort(struct sdp_opt *conn
 		 * outstanding CM request. Mark it in error, and CM
 		 * completion needs to complete the closing.
 		 */
-		error = ECONNREFUSED;
+		error = -ECONNREFUSED;
 		break;
 	case SDP_CONN_ST_ERROR:
 	case SDP_CONN_ST_CLOSED:
Index: sdp_actv.c
===================================================================
--- sdp_actv.c	(revision 2608)
+++ sdp_actv.c	(working copy)
@@ -41,8 +41,6 @@ void sdp_cm_actv_error(struct sdp_opt *c
 {
 	int result;
 	/*
-	 * error value is positive error.
-	 *
 	 * Handle errors within active connections stream.
 	 * First generate appropriate response, REJ, DREQ or nothing.
 	 * Second the socket must be notified of the error.
@@ -88,14 +86,14 @@ void sdp_cm_actv_error(struct sdp_opt *c
 		break;
 	}
 
-	SDP_CONN_SET_ERR(conn, error);
+	SDP_CONN_SET_ERR(conn, -error);
 	conn->shutdown = SHUTDOWN_MASK;
 	conn->send_buf = 0;
 
 	if (conn->sk->sk_socket)
 		conn->sk->sk_socket->state = SS_UNCONNECTED;
 
-	sdp_iocb_q_cancel_all(conn, (0 - error));
+	sdp_iocb_q_cancel_all(conn, error);
 	sdp_inet_wake_error(conn->sk);
 }
 
@@ -319,7 +317,7 @@ int sdp_cm_rep_handler(struct ib_cm_id *
 
 	return 0;
 error:
-	sdp_cm_actv_error(conn, (0 - result));
+	sdp_cm_actv_error(conn, result);
 
 	if (conn->state == SDP_CONN_ST_CLOSED) {
 		conn->cm_id = NULL;
@@ -511,7 +509,7 @@ static void sdp_cm_path_complete(u64 id,
 
 	goto done;
 failed:
-	sdp_cm_actv_error(conn, (0 - status));
+	sdp_cm_actv_error(conn, status);
 done:
 	sdp_conn_unlock(conn);
 	sdp_conn_put(conn); /* address resolution reference */
Index: sdp_pass.c
===================================================================
--- sdp_pass.c	(revision 2608)
+++ sdp_pass.c	(working copy)
@@ -41,7 +41,7 @@ int sdp_cm_pass_establish(struct sdp_opt
 {
         struct ib_qp_attr *qp_attr;
 	int attr_mask = 0;
-	int result = 0;
+	int result;
 
 	sdp_dbg_ctrl(conn, "Passive Establish src <%08x:%04x> dst <%08x:%04x>",
 		     conn->src_addr, conn->src_port, 
@@ -62,27 +62,26 @@ int sdp_cm_pass_establish(struct sdp_opt
 
 	result = ib_cm_init_qp_attr(conn->cm_id, qp_attr, &attr_mask);
 	if (result) {
-		sdp_dbg_warn(conn, "Error <%d> QP attributes for RTS",
-			     result);
+		sdp_dbg_warn(conn, "Error <%d> QP attributes for RTS", result);
 		goto error;
 	}
 
         result = ib_modify_qp(conn->qp, qp_attr, attr_mask);
 	if (result) {
-		sdp_dbg_warn(conn, "Error <%d> modifiying QP to RTS", result);
+		sdp_dbg_warn(conn, "Error <%d> modifying QP to RTS", result);
 		goto error;
 	}
 
 	conn->send_buf = SDP_INET_SEND_SIZE;
 
 	result = sdp_send_flush(conn);
-	if (0 > result) {
+	if (result < 0) {
 		sdp_dbg_warn(conn, "Error <%d> flushing sends.", result);
 		goto error;
 	}
 
 	result = sdp_recv_flush(conn);
-	if (0 > result) {
+	if (result < 0) {
 		sdp_dbg_warn(conn, "Error <%d> flushing receives.", result);
 		goto error;
 	}
@@ -94,7 +93,7 @@ int sdp_cm_pass_establish(struct sdp_opt
 error:
         kfree(qp_attr);
 done:
-	sdp_conn_inet_error(conn, -result);
+	sdp_conn_inet_error(conn, result);
 	return result;
 }
 /*
Index: sdp_event.c
===================================================================
--- sdp_event.c	(revision 2608)
+++ sdp_event.c	(working copy)
@@ -184,7 +184,7 @@ void sdp_cq_event_handler(struct ib_cq *
 
 static void sdp_cm_to_error(struct sdp_opt *conn)
 {
-	sdp_conn_inet_error(conn, ECONNRESET);
+	sdp_conn_inet_error(conn, -ECONNRESET);
 	conn->cm_id = NULL;
 	sdp_conn_put(conn);	/* CM reference */
 }
@@ -202,11 +202,11 @@ static int sdp_cm_idle(struct ib_cm_id *
 	 */
 	switch (conn->state) {
 	case SDP_CONN_ST_REQ_SENT:
-		sdp_cm_actv_error(conn, ECONNREFUSED);
+		sdp_cm_actv_error(conn, -ECONNREFUSED);
 		break;
 	case SDP_CONN_ST_REQ_RECV:
 	case SDP_CONN_ST_ESTABLISHED:
-		sdp_conn_inet_error(conn, ECONNREFUSED);
+		sdp_conn_inet_error(conn, -ECONNREFUSED);
 		break;
 	case SDP_CONN_ST_TIME_WAIT_1:
 		sdp_dbg_warn(conn, "Unexpected connection state");
-- 
MST



More information about the general mailing list