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 82551A0487 for ; Wed, 3 Jul 2019 00:14:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C92D1BE43; Wed, 3 Jul 2019 00:13:11 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id E28591BE29 for ; Wed, 3 Jul 2019 00:13:04 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id 196so81505pgc.6 for ; Tue, 02 Jul 2019 15:13:04 -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=hwEmjfBCDm2MyBGuk9lC8m9EUUnn0LmDNhMzslFOsA0=; b=0kh2uWhgIed6rTYBhqbYu5oVjI+X+Vfzmx10KI1miXI2j5FBamNBYwKXs9jikuMq4I WrHtvXhpGHegpbL1u9MO6V2sH9gssFt7FR6B9uzOysxpn2rJcRw0VGE/FWZxZUqNrcLF JfOi5k00oAlRbutvdFSzcVgUDYBS4bl0Mg01xnNiNuHRF0iG9uz14fu9Vh6eL3wWD7Oo btAku5NFFY8nzmeJafqkRZhrmPg4SOy4IEqUcDBAR3NuXSJOEtFEXYMFhc12CGFnRynu bYmGf/i3Nog5ZNvLfHGKp8CdpvKyeei0bOPODx5fzGnILWlqpqbAaKaMAP7GYueQQs5E k2lw== 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=hwEmjfBCDm2MyBGuk9lC8m9EUUnn0LmDNhMzslFOsA0=; b=E2lXH8WPTIXDZ9+Jwhvcxpur9MCWYIsyEzwXD+xje7hN0JpCkVVxXpItIZaqwxvXQi 3AqNlwGOWKznJbrriTZnbbdTGMd9BwgAwIj5QFh/pDbY9RQQSvXovZFikQDdrQqyahIu RAS2ergxErooyyyzCvSnLtCwMDnKpkIYgTSEp5V72N7K66JpaIPM5f2Vi/PKV7GEU+Jc K7063srKMqBXiGG56Etc+H0HsVNJJWaNL/dfQ5YSq+33laOkGKWI4PK5w/8IHA740g/p ueoAcqSVWHHyijYtCzPMV8KMVqXuke6/4bRO2DePzkl0mtYRj7KKmXimYs00RTEvJmvZ j9Iw== X-Gm-Message-State: APjAAAXqJXDbF3iwf3VxN/ggmlmQk6ckkzA58ut1pa3lw0AJSsJPlkpO 4Sw5Yo29BH2FrNCh9ZRRFITHn9xv X-Google-Smtp-Source: APXvYqxGOPnjxJdIv8T3hG3GWtDOg7BvBiDJxT5AQL34LCsTw87yTS3AKkCF7Z/ZS2D3T9xoTLoCOw== X-Received: by 2002:a17:90a:b908:: with SMTP id p8mr8191208pjr.94.1562105583488; Tue, 02 Jul 2019 15:13:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q4sm25035pjq.27.2019.07.02.15.13.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 15:13:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Jul 2019 15:12:44 -0700 Message-Id: <20190702221247.28391-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702221247.28391-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702221247.28391-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 09/12] net/virtio: use new ether addr parsing 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" Use rte_ether_unformat_addr rather than sscanf. Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index e743695e4510..0bac725e7cdd 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -225,17 +225,13 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) static inline void parse_mac(struct virtio_user_dev *dev, const char *mac) { - int i, r; - uint32_t tmp[RTE_ETHER_ADDR_LEN]; + struct rte_ether_addr tmp; if (!mac) return; - r = sscanf(mac, "%x:%x:%x:%x:%x:%x", &tmp[0], - &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]); - if (r == RTE_ETHER_ADDR_LEN) { - for (i = 0; i < RTE_ETHER_ADDR_LEN; ++i) - dev->mac_addr[i] = (uint8_t)tmp[i]; + if (rte_ether_unformat_addr(mac, &tmp) == 0) { + memcpy(dev->mac_addr, &tmp, RTE_ETHER_ADDR_LEN); dev->mac_specified = 1; } else { /* ignore the wrong mac, use random mac */ -- 2.20.1