Soft Patch Panel
 help / color / mirror / Atom feed
From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 3/6] spp_vf: remove no meaning int variables
Date: Fri,  2 Aug 2019 18:33:55 +0900	[thread overview]
Message-ID: <20190802093358.13696-4-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190802093358.13696-1-yasufum.o@gmail.com>

In main(), there are many no meaning variables for receiveing results
of functions such as `ret_do` or `ret_parse` or so and each of which is
used only one time for checking. It is enough by using `int ret`
defined at the head of the function.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/vf/spp_vf.c | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/vf/spp_vf.c b/src/vf/spp_vf.c
index e10ae71..b2f2af4 100644
--- a/src/vf/spp_vf.c
+++ b/src/vf/spp_vf.c
@@ -211,17 +211,16 @@ main(int argc, char *argv[])
 	int ret;
 	char ctl_ip[IPADDR_LEN] = { 0 };
 	int ctl_port;
-	int ret_cmd_init;
 	unsigned int master_lcore;
 	unsigned int lcore_id;
 
 #ifdef SPP_DEMONIZE
 	/* Daemonize process */
-	int ret_daemon = daemon(0, 0);
-	if (unlikely(ret_daemon != 0)) {
+	ret = daemon(0, 0);
+	if (unlikely(ret != 0)) {
 		RTE_LOG(ERR, APP, "daemonize is failed. (ret = %d)\n",
-				ret_daemon);
-		return ret_daemon;
+				ret);
+		return ret;
 	}
 #endif
 
@@ -248,8 +247,8 @@ main(int argc, char *argv[])
 	 */
 	while (1) {
 		/* Parse spp_vf specific parameters */
-		int ret_parse = parse_app_args(argc, argv);
-		if (unlikely(ret_parse != SPPWK_RET_OK))
+		ret = parse_app_args(argc, argv);
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 
 		if (sppwk_set_mng_data(&g_iface_info, g_component_info,
@@ -261,12 +260,12 @@ main(int argc, char *argv[])
 			break;
 		}
 
-		int ret_mng = init_mng_data();
-		if (unlikely(ret_mng != SPPWK_RET_OK))
+		ret = init_mng_data();
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 
-		int ret_classifier_mac_init = init_cls_mng_info();
-		if (unlikely(ret_classifier_mac_init != SPPWK_RET_OK))
+		ret = init_cls_mng_info();
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 
 		init_forwarder();
@@ -275,8 +274,8 @@ main(int argc, char *argv[])
 		/* Setup connection for accepting commands from controller */
 		get_spp_ctl_ip(ctl_ip);
 		ctl_port = get_spp_ctl_port();
-		ret_cmd_init = sppwk_cmd_runner_conn(ctl_ip, ctl_port);
-		if (unlikely(ret_cmd_init != SPPWK_RET_OK))
+		ret = sppwk_cmd_runner_conn(ctl_ip, ctl_port);
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 
 #ifdef SPP_RINGLATENCYSTATS_ENABLE
@@ -291,10 +290,10 @@ main(int argc, char *argv[])
 			if (port_type == RING)
 				nof_rings++;
 		}
-		int ret_ringlatency = spp_ringlatencystats_init(
+		ret = spp_ringlatencystats_init(
 				SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL,
 				nof_rings);
-		if (unlikely(ret_ringlatency != SPPWK_RET_OK))
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 
@@ -305,8 +304,8 @@ main(int argc, char *argv[])
 
 		/* Set the status of main thread to idle */
 		g_core_info[master_lcore].status = SPPWK_LCORE_IDLING;
-		int ret_wait = check_core_status_wait(SPPWK_LCORE_IDLING);
-		if (unlikely(ret_wait != SPPWK_RET_OK))
+		ret = check_core_status_wait(SPPWK_LCORE_IDLING);
+		if (unlikely(ret != SPPWK_RET_OK))
 			break;
 
 		/* Start forwarding */
@@ -318,7 +317,6 @@ main(int argc, char *argv[])
 		backup_mng_info(&g_backup_info);
 
 		/* Enter loop for accepting commands */
-		int ret_do = SPPWK_RET_OK;
 #ifndef USE_UT_SPP_VF
 		while (likely(g_core_info[master_lcore].status !=
 				SPPWK_LCORE_REQ_STOP)) {
@@ -326,8 +324,8 @@ main(int argc, char *argv[])
 		{
 #endif
 			/* Receive command */
-			ret_do = sppwk_run_cmd();
-			if (unlikely(ret_do != SPPWK_RET_OK))
+			ret = sppwk_run_cmd();
+			if (unlikely(ret != SPPWK_RET_OK))
 				break;
 
 		       /*
@@ -340,7 +338,7 @@ main(int argc, char *argv[])
 #endif /* SPP_RINGLATENCYSTATS_ENABLE */
 		}
 
-		if (unlikely(ret_do != SPPWK_RET_OK)) {
+		if (unlikely(ret != SPPWK_RET_OK)) {
 			set_all_core_status(SPPWK_LCORE_REQ_STOP);
 			break;
 		}
@@ -351,8 +349,8 @@ main(int argc, char *argv[])
 
 	/* Finalize to exit */
 	g_core_info[master_lcore].status = SPPWK_LCORE_STOPPED;
-	int ret_core_end = check_core_status_wait(SPPWK_LCORE_STOPPED);
-	if (unlikely(ret_core_end != SPPWK_RET_OK))
+	ret = check_core_status_wait(SPPWK_LCORE_STOPPED);
+	if (unlikely(ret != SPPWK_RET_OK))
 		RTE_LOG(ERR, APP, "Failed to terminate master thread.\n");
 
 	/*
-- 
2.17.1


  parent reply	other threads:[~2019-08-02  9:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  9:33 [spp] [PATCH 0/6] Refactor classifier of spp_vf Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 1/6] spp_vf: rename file classifier_mac Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 2/6] spp_vf: rename func spp_classifier_mac_init Yasufumi Ogawa
2019-08-02  9:33 ` Yasufumi Ogawa [this message]
2019-08-02  9:33 ` [spp] [PATCH 4/6] spp_vf: rename management_info to cls_mng_info Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 5/6] spp_vf: refactor variables in classifier.c Yasufumi Ogawa
2019-08-02  9:33 ` [spp] [PATCH 6/6] spp_vf: rename spp_classifier_mac_do Yasufumi Ogawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190802093358.13696-4-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).