diff mbox

[1/2] RDMA/libocrdma: return positive error codes

Message ID f00bc08d-df55-4008-b36b-a1607443b02e@CMEXHTCAS2.ad.emulex.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Devesh Sharma Jan. 14, 2015, 6:53 a.m. UTC
From: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>

As per the standard practice if any faiulre encountered in the
library code, the library should return a positive error code
to the user.

A bug has been reported in a used case scenario of KVM migration
as well.

This patch fixs the return code problem.

Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com>
---
 src/ocrdma_verbs.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/src/ocrdma_verbs.c b/src/ocrdma_verbs.c
index edff8b6..c089a5f 100644
--- a/src/ocrdma_verbs.c
+++ b/src/ocrdma_verbs.c
@@ -778,7 +778,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			ocrdma_del_flush_qp(qp);
 			break;
 		default:
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -794,7 +794,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			break;
 		default:
 			/* invalid state change. */
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -808,7 +808,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			break;
 		default:
 			/* invalid state change. */
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -823,7 +823,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			break;
 		default:
 			/* invalid state change. */
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -836,7 +836,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			break;
 		default:
 			/* invalid state change. */
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -847,7 +847,7 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 			break;
 		default:
 			/* invalid state change. */
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
@@ -857,12 +857,12 @@  static int ocrdma_qp_state_machine(struct ocrdma_qp *qp,
 		case OCRDMA_QPS_RST:
 			break;
 		default:
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		};
 		break;
 	default:
-		status = -EINVAL;
+		status = EINVAL;
 		break;
 	};
 	if (!status)
@@ -1226,7 +1226,7 @@  static inline int ocrdma_build_inline_sges(struct ocrdma_qp *qp,
 			ocrdma_err
 			("%s() supported_len=0x%x, unspported len req=0x%x\n",
 			__func__, qp->max_inline_data, hdr->total_len);
-			return -EINVAL;
+			return EINVAL;
 		}
 
 		dpp_addr = (char *)sge;
@@ -1391,7 +1391,7 @@  int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr,
 	if (qp->state != OCRDMA_QPS_RTS && qp->state != OCRDMA_QPS_SQD) {
 		pthread_spin_unlock(&qp->q_lock);
 		*bad_wr = wr;
-		return -EINVAL;
+		return EINVAL;
 	}
 
 	while (wr) {
@@ -1399,14 +1399,14 @@  int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr,
 		if (qp->qp_type == IBV_QPT_UD && (wr->opcode != IBV_WR_SEND &&
 		    wr->opcode != IBV_WR_SEND_WITH_IMM)) {
 			*bad_wr = wr;
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		}
 
 		if (ocrdma_hwq_free_cnt(&qp->sq) == 0 ||
 		    wr->num_sge > qp->sq.max_sges) {
 			*bad_wr = wr;
-			status = -ENOMEM;
+			status = ENOMEM;
 			break;
 		}
 		hdr = ocrdma_hwq_head(&qp->sq);
@@ -1441,7 +1441,7 @@  int ocrdma_post_send(struct ibv_qp *ib_qp, struct ibv_send_wr *wr,
 			ocrdma_build_read(qp, hdr, wr);
 			break;
 		default:
-			status = -EINVAL;
+			status = EINVAL;
 			break;
 		}
 		if (status) {
@@ -1509,13 +1509,13 @@  int ocrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
 	if (qp->state == OCRDMA_QPS_RST || qp->state == OCRDMA_QPS_ERR) {
 		pthread_spin_unlock(&qp->q_lock);
 		*bad_wr = wr;
-		return -EINVAL;
+		return EINVAL;
 	}
 
 	while (wr) {
 		if (ocrdma_hwq_free_cnt(&qp->rq) == 0 ||
 		    wr->num_sge > qp->rq.max_sges) {
-			status = -ENOMEM;
+			status = ENOMEM;
 			*bad_wr = wr;
 			break;
 		}
@@ -2098,7 +2098,7 @@  int ocrdma_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr,
 	while (wr) {
 		if (ocrdma_hwq_free_cnt(&srq->rq) == 0 ||
 		    wr->num_sge > srq->rq.max_sges) {
-			status = -ENOMEM;
+			status = ENOMEM;
 			*bad_wr = wr;
 			break;
 		}