diff mbox

[libibcm] Return errors from the kernel consistently

Message ID 20091020055834.GA26350@obsidianresearch.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Jason Gunthorpe Oct. 20, 2009, 5:58 a.m. UTC
None
diff mbox

Patch

diff --git a/src/cm.c b/src/cm.c
index 7370abe..4807e2d 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -261,7 +261,7 @@  int ib_cm_destroy_id(struct ib_cm_id *cm_id)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
 
@@ -292,7 +292,7 @@  int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
 
@@ -322,7 +322,7 @@  int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
 
@@ -348,7 +348,7 @@  int ib_cm_listen(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -407,7 +407,7 @@  int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -442,7 +442,7 @@  int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -467,7 +467,7 @@  static inline int cm_send_private_data(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -508,7 +508,7 @@  static int cm_establish(struct ib_cm_id *cm_id)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -533,7 +533,7 @@  int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event)
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -567,7 +567,7 @@  static inline int cm_send_status(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -617,7 +617,7 @@  int ib_cm_send_mra(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -652,7 +652,7 @@  int ib_cm_send_lap(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -692,7 +692,7 @@  int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -726,7 +726,7 @@  int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
 
 	result = write(cm_id->device->fd, msg, size);
 	if (result != size)
-		return (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 
 	return 0;
 }
@@ -836,7 +836,7 @@  int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
 
 	result = write(device->fd, msg, size);
 	if (result != size) {
-		result = (result > 0) ? -ENODATA : result;
+		return (result >= 0) ? -ENODATA : -1*errno;
 		goto done;
 	}