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 B357CA046B for ; Fri, 26 Jul 2019 18:51:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E96F31C52A; Fri, 26 Jul 2019 18:51:20 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 938B91C505 for ; Fri, 26 Jul 2019 18:51:07 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id k8so24982032plt.3 for ; Fri, 26 Jul 2019 09:51:07 -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=Lb/NsSj2iSVmJnwv/Z1M4hAA3ZsHWrFGgw/JlQnvE+RqE6Qa/uG/nxflxBgd05Bf9P gmI81FNywl4pNfPL4qD2nWhyMkbH3hWbqm1MT36ObxUrTE8q6m1lvdH0Zd/sXjmshpuz BwaLuX++FAscOK3MI09MFaarZJwEnhQkOHiXmEWxHU8SjU/LW3CEqLrwRSZLD1Tuof89 a8LjaSjJMrlUSwjjqzTF+tK/0tCdIwylnS3lCbtlhng8Fh8Mn9hFqv6tl87fNSzLYYA7 FnM4Y45vpfrLo43SBXdagGrDO+8kR45Dw4yHzgWIBe67PmH8dvZBDu2jyXbTv0F0uIbP iFVg== 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=XgCyrskjEyNNuHOHM9UddnCKVyktxWBqtvtD3zUcRyspl3Mh6lI5JtiNqKrqxpHVqp Vok8us60EkXGnWud2QR3KY6xip5wGV4/qPIqEnZCCxqLoESbto9zBnch5zYFPfrEq+Bm 3pvRgBR17vZpJz7xGOQiGvggtlis7wBA40V/kUOJ1sC8hemoCAX8+YN9fdLaJAj9OS4U eIfbmSB/57gCRYh2eT44uG2eCJDYnlXocos/CTunnxyFY/+mHoBUYIHjlg+yY1fpaxFf Z9TseSAmpfy9sWY+mIbAGuhBSAuf8gaoX6kTwuIX68U9/r+dL48+s2jA/E5c6hpvF/92 62YQ== X-Gm-Message-State: APjAAAW7gLgQPbHvoXopbZCPYJ013G7o1iAeIORyOEbK6r/4WYVyFp6J CX6uKNCMZo2yN0eCxvbRLESZITxk X-Google-Smtp-Source: APXvYqzxda7+fi+Yd1i8hMIwkvL6QgsK/3v2fCmh+z8JmQ977kD+gbjBBwIT1Hq81g0by7FJeXxKDw== X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr95253879plo.290.1564159866533; Fri, 26 Jul 2019 09:51:06 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id s3sm14747747pgq.17.2019.07.26.09.51.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 09:51:06 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 26 Jul 2019 09:50:54 -0700 Message-Id: <20190726165054.24078-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190726165054.24078-1-stephen@networkplumber.org> References: <20190709150939.31338-1-stephen@networkplumber.org> <20190726165054.24078-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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