From feb7f2b3fcbe621daa80b7cd4d1ef83de05c3248 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 8 Jun 2018 14:54:01 +0900 Subject: [PATCH] iscsi: simplify nesting and order in iscsi_conn_read_data() Try to make the logic of the function a little clearer. Change-Id: Ic78bed73feef94d94487f0a4240019789be8d2bc Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/414353 Tested-by: SPDK Automated Test System Reviewed-by: Dariusz Stojaczyk Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/iscsi/conn.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 8e47ab173..2286c5b0d 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -732,30 +732,26 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes, if (ret > 0) { spdk_trace_record(TRACE_READ_FROM_SOCKET_DONE, conn->id, ret, 0, 0); + return ret; } if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { return 0; - } else { - /* For connect reset issue, do not output error log */ - if (errno == ECONNRESET) { - SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_sock_recv() failed, errno %d: %s\n", - errno, spdk_strerror(errno)); - } else { - SPDK_ERRLOG("spdk_sock_recv() failed, errno %d: %s\n", - errno, spdk_strerror(errno)); - } } - return SPDK_ISCSI_CONNECTION_FATAL; + + /* For connect reset issue, do not output error log */ + if (errno == ECONNRESET) { + SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_sock_recv() failed, errno %d: %s\n", + errno, spdk_strerror(errno)); + } else { + SPDK_ERRLOG("spdk_sock_recv() failed, errno %d: %s\n", + errno, spdk_strerror(errno)); + } } /* connection closed */ - if (ret == 0) { - return SPDK_ISCSI_CONNECTION_FATAL; - } - - return ret; + return SPDK_ISCSI_CONNECTION_FATAL; } void