From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37CF0A10DA for ; Fri, 2 Aug 2019 04:59:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C18C91C227; Fri, 2 Aug 2019 04:58:39 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 2E1701C20F for ; Fri, 2 Aug 2019 04:58:34 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id n4so10602pgv.2 for ; Thu, 01 Aug 2019 19:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GRL9o22FsqlZS1KIBKGsZH8PR5E+wVCUALAgsRD4EO0=; b=VRrPHxAqwsVlETKaJ2uQ8Fy/NmgObWFUBWp5PwaFjx79w+O/tF4ZoWff8Vf3Im7Rny 0vcb6JzZTuOXrxlpvcvVMu3CDhfHzDFb6vn2MhAQJpbgmMKfVkoVqjuZWDZ6VlFef9m1 aq/UAliHZ/NTCeLeDCoOZlXcHK6pQSmuDUYVYVwkBldOXz/1sE39fNyBAP8vXZ+o4CJZ A6BHJWraj+Dx5kWu8AJzoU51gG2sNiE1qX1PC6/P5KR35qD1RMEiU4YRUk6jdO1S+bqp u4GZGY05VGsXp99yszcHiELQwgzjSFPockUiT3VAtfEfaLujcXlGoClHLLFKV7pxZVfM FF0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GRL9o22FsqlZS1KIBKGsZH8PR5E+wVCUALAgsRD4EO0=; b=gjgW93ts8Tc16RjUQovkeFmhH/5CjCvqNs7+Nltp5W4kfkv9cDB11Z72I+FgbnFi9D wZE6aW5zPoT+kpE8Mwp4/4nXly2d61JY3tOigpD/6kZ8NDSbaUhUmYiJJSgne/hm+JjC kj8ZoNpAv2lS34YIG6dO1nMen73uApzA2x3pyJ1KuIIV+hHEusmZUQp1MmX+cUuZ9Vt9 E2kElCMmjHigipruTaWewNsBZA7cXKrhMADlKF3Q9ab/KDDqTGzroSQRAV70C1DAC+hl +wRUVwbyrL4IXaEycrLF0UJNqA25/r8e70t2AWMi/N42T7gyPLi6vrr5uij1IWWA/E7q Mr0A== X-Gm-Message-State: APjAAAVGpJSlbAAQK2B+Do7Yzh6So4LlmrdsKp/r6VL4P7gqeFPFqzk8 TYbanavBDD/AQbGAz+RpDuync3c7 X-Google-Smtp-Source: APXvYqygpfqT/ZZE7sHvUncnu4jY6QV/6Y3WNMd3uW4aEy+8n+5gA3Gl4IbhZNmYOeyLBSRChqyJkA== X-Received: by 2002:aa7:9531:: with SMTP id c17mr59086508pfp.130.1564714712941; Thu, 01 Aug 2019 19:58:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a20sm5788738pjo.0.2019.08.01.19.58.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 19:58:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 1 Aug 2019 19:58:26 -0700 Message-Id: <20190802025826.1174-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190802025826.1174-1-stephen@networkplumber.org> References: <20190726165054.24078-1-stephen@networkplumber.org> <20190802025826.1174-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 4/4] examples/multi_process/client_server_mp/mp_server: use ether format address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" No need to use snprintf to print ethernet address. Signed-off-by: Stephen Hemminger --- .../client_server_mp/mp_server/main.c | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c index bfec0bef3a71..d1339d4be64c 100644 --- a/examples/multi_process/client_server_mp/mp_server/main.c +++ b/examples/multi_process/client_server_mp/mp_server/main.c @@ -56,26 +56,6 @@ struct client_rx_buf { /* One buffer per client rx queue - dynamically allocate array */ static struct client_rx_buf *cl_rx_buf; -static const char * -get_printable_mac_addr(uint16_t port) -{ - static const char err_address[] = "00:00:00:00:00:00"; - static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)]; - - if (unlikely(port >= RTE_MAX_ETHPORTS)) - return err_address; - if (unlikely(addresses[port][0] == '\0')) { - struct rte_ether_addr mac; - - rte_eth_macaddr_get(port, &mac); - snprintf(addresses[port], sizeof(addresses[port]), - "%02x:%02x:%02x:%02x:%02x:%02x\n", - mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2], - mac.addr_bytes[3], mac.addr_bytes[4], mac.addr_bytes[5]); - } - return addresses[port]; -} - /* * This function displays the recorded statistics for each port * and for each client. It uses ANSI terminal codes to clear @@ -118,9 +98,15 @@ do_stats_display(void) printf("PORTS\n"); printf("-----\n"); - for (i = 0; i < ports->num_ports; i++) - printf("Port %u: '%s'\t", ports->id[i], - get_printable_mac_addr(ports->id[i])); + for (i = 0; i < ports->num_ports; i++) { + struct rte_ether_addr mac = { }; + char buf[32]; + + rte_eth_macaddr_get(ports->id[i], &mac); + rte_ether_format_addr(buf, sizeof(buf), &mac); + printf("Port %u: '%s'\t", ports->id[i], buf); + } + printf("\n\n"); for (i = 0; i < ports->num_ports; i++) { printf("Port %u - rx: %9"PRIu64"\ttx: %9"PRIu64"\n", -- 2.20.1