From patchwork Tue Oct 20 05:58:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 54889 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9K5x027005874 for ; Tue, 20 Oct 2009 05:59:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754327AbZJTF6e (ORCPT ); Tue, 20 Oct 2009 01:58:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752929AbZJTF6e (ORCPT ); Tue, 20 Oct 2009 01:58:34 -0400 Received: from 139-142-54-143.atc.vaillant.ca ([139.142.54.143]:38375 "EHLO quartz.edm.orcorp.ca" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753540AbZJTF6d (ORCPT ); Tue, 20 Oct 2009 01:58:33 -0400 Received: from [10.0.0.11] (helo=jggl.edm.orcorp.ca) by quartz.edm.orcorp.ca with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.68) (envelope-from ) id 1N07ju-000073-Ux; Mon, 19 Oct 2009 23:58:34 -0600 Received: from jgg by jggl.edm.orcorp.ca with local (Exim 4.69) (envelope-from ) id 1N07ju-0006vs-Sw; Mon, 19 Oct 2009 23:58:34 -0600 Date: Mon, 19 Oct 2009 23:58:34 -0600 From: Jason Gunthorpe To: Sean Hefty , Linux RDMA list Subject: [PATCH libibcm] Return errors from the kernel consistently Message-ID: <20091020055834.GA26350@obsidianresearch.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.11 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org 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; }