From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id C8F1D2965 for ; Thu, 28 Dec 2017 05:56:12 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id vBS4uAQR025202 for unknown; Thu, 28 Dec 2017 13:56:10 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u8GG027386 for unknown; Thu, 28 Dec 2017 13:56:08 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27376; Thu, 28 Dec 2017 13:56:08 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u7o6011123 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Received: from mgate01.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u7mt011091 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Message-Id: <201712280456.vBS4u7mt011091@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4b8025622 ; Thu, 28 Dec 2017 13:56:06 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:55:41 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> References: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 34/57] spp_vf: modify conditional statement X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Dec 2017 04:56:13 -0000 From: Hiroyuki Nakamura Modify followings: * Comments on function's return value. * Conditional statement for the actions corresponding to return values of spp_receive_message. Signed-off-by: Daiki Yamashita Signed-off-by: Yasufum Ogawa --- src/vf/command_conn.h | 8 ++++---- src/vf/command_proc.c | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/vf/command_conn.h b/src/vf/command_conn.h index 932c647..d414ec6 100644 --- a/src/vf/command_conn.h +++ b/src/vf/command_conn.h @@ -15,8 +15,8 @@ * @param controller_port * controller listen port number. * - * @retval 0 succeeded. - * @retval SPP_CONNERR_TEMPORARY temporary error. please retry. + * @retval 0 succeeded. + * @retval -1 failed. */ int spp_command_conn_init(const char *controller_ip, int controller_port); @@ -28,8 +28,8 @@ int spp_command_conn_init(const char *controller_ip, int controller_port); * @param sock * socket that connect to controller. * - * @retval 0 succeeded. - * @retval -1 failed. + * @retval 0 succeeded. + * @retval SPP_CONNERR_TEMPORARY temporary error. please retry. */ int spp_connect_to_controller(int *sock); diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c index c921b51..50418cc 100644 --- a/src/vf/command_proc.c +++ b/src/vf/command_proc.c @@ -418,10 +418,13 @@ spp_command_proc_do(void) return 0; msg_ret = spp_receive_message(&sock, &msgbuf); - if (unlikely(msg_ret == 0 || msg_ret == SPP_CONNERR_TEMPORARY)) { - return 0; - } else if (unlikely(msg_ret < 0)) { - return -1; + if (unlikely(msg_ret <= 0)) { + if (likely(msg_ret == 0)) + return 0; + else if (unlikely(msg_ret == SPP_CONNERR_TEMPORARY)) + return 0; + else + return -1; } for (i = 0; i < msg_ret; ++i) { -- 1.9.1