From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw1135.ocn.ad.jp (mogw1135.ocn.ad.jp [153.149.229.36]) by dpdk.org (Postfix) with ESMTP id 543242C58 for ; Mon, 12 Mar 2018 06:35:44 +0100 (CET) Received: from mf-smf-ucb025c2 (mf-smf-ucb025c2.ocn.ad.jp [153.153.66.164]) by mogw1135.ocn.ad.jp (Postfix) with ESMTP id C4383100023F; Mon, 12 Mar 2018 14:35:42 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb024 ([153.149.142.98]) by mf-smf-ucb025c2 with ESMTP id vG7Ye8evnyvP3vG7aebJiH; Mon, 12 Mar 2018 14:35:42 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.165]) by ntt.pod01.mv-mta-ucb024 with id Ltbi1x0073akymp01tbiyX; Mon, 12 Mar 2018 05:35:42 +0000 Received: from linaloe.flets-east.jp (sp1-66-103-93.msc.spmode.ne.jp [1.66.103.93]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Mon, 12 Mar 2018 14:35:42 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com Cc: Yasufumi Ogawa Date: Mon, 12 Mar 2018 14:35:24 +0900 Message-Id: <1520832924-28387-10-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520832924-28387-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <8b08be87-6b64-8a4a-53e0-29269011d81c@lab.ntt.co.jp> <1520832924-28387-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 9/9] shared: fix bug for print port status 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: Mon, 12 Mar 2018 05:35:44 -0000 From: Yasufumi Ogawa Result of print_active_ports() is invalid format if sec has no ports. This update is to fix for this case. Signed-off-by: Yasufumi Ogawa --- src/shared/common.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/shared/common.c b/src/shared/common.c index 1ef63de..b11cb6d 100644 --- a/src/shared/common.c +++ b/src/shared/common.c @@ -32,7 +32,6 @@ */ #include - #include "common.h" /* Check the link status of all ports in up to 9s, and print them finally */ @@ -263,9 +262,10 @@ print_active_ports(char *str, struct port_map *port_map) { unsigned int i; + const char *port_prefix = "ports: '"; /* Every elements value */ - sprintf(str, "ports: "); + sprintf(str, "%s", port_prefix); for (i = 0; i < RTE_MAX_ETHPORTS; i++) { if (ports_fwd_array[i].in_port_id == PORT_RESET) continue; @@ -313,7 +313,7 @@ print_active_ports(char *str, break; case UNDEF: RTE_LOG(INFO, APP, "Type: UDF\n"); - /* TODO(yasufum) remove print for undefined ? */ + /* TODO(yasufum) Need to remove print for undefined ? */ sprintf(str + strlen(str), "udf-"); break; } @@ -352,11 +352,22 @@ print_active_ports(char *str, break; case UNDEF: RTE_LOG(INFO, APP, "Type: UDF\n"); - /* TODO(yasufum) remove print for undefined ? */ + /** + * TODO(yasufum) Need to remove print for + * undefined ? + */ sprintf(str + strlen(str), "udf,"); break; } } } - sprintf(str + strlen(str) - 1, "%c", '\0'); + + // If there are no ports, it's formatted as "ports: ''" + if (strcmp(str, port_prefix) == 0) { + sprintf(str + strlen(str), "'"); + } else { // Remove last ',' + sprintf(str + strlen(str) - 1, "'"); + } + // make sure to be terminated with null character + sprintf(str + strlen(str), "%c", '\0'); } -- 2.7.4