From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gris Ge Subject: [PATCH V3 2/3] multipath-tools: Set errno mpath_recv_reply() when failure. Date: Fri, 1 Jul 2016 20:46:55 +0800 Message-ID: <20160701124656.169890-3-fge@redhat.com> References: <1455264623-16199-2-git-send-email-fge@redhat.com> <20160701124656.169890-1-fge@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160701124656.169890-1-fge@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: dm-devel@redhat.com Cc: Gris Ge List-Id: dm-devel.ids Enforce what mpath_cmd.h states "-1 on failure (with errno set)" for mpath_recv_reply() by set errno and return -1 on failure. Signed-off-by: Gris Ge --- libmpathcmd/mpath_cmd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c index 2290ecb..309634e 100644 --- a/libmpathcmd/mpath_cmd.c +++ b/libmpathcmd/mpath_cmd.c @@ -141,9 +141,11 @@ int mpath_recv_reply(int fd, char **reply, unsigned int timeout) *reply = NULL; len = mpath_recv_reply_len(fd, timeout); if (len <= 0) - return len; - if (len > MAX_REPLY_LEN) - return -EINVAL; + return -1; + if (len > MAX_REPLY_LEN) { + errno = EINVAL; + return -1; + } *reply = malloc(len); if (!*reply) return -1; @@ -151,7 +153,7 @@ int mpath_recv_reply(int fd, char **reply, unsigned int timeout) if (err) { free(*reply); *reply = NULL; - return err; + return -1; } return 0; } -- 2.9.0