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 0D78FA00E6 for ; Mon, 8 Jul 2019 20:28:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C6EF91BDF7; Mon, 8 Jul 2019 20:26:45 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 3EF491B9D9 for ; Mon, 8 Jul 2019 20:26:32 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id a93so8703637pla.7 for ; Mon, 08 Jul 2019 11:26:32 -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=+EmzYVztBuqkWPa3J9xFCquV2rAKQo18WvoWOlsEX30=; b=ydxH3IB4nYQFo/v1FZQfq1orexlv2KALzkMsCc+L9i2M2gkQ7v9dSzRXdCIthj8K4f iw0IuXbu3OMCNvzSlZ9Rd1lkfoAj6DuZtZrdFKDP1vAEqhtLoLMb+eJaUmH6TwHEehi4 fY54j5gqV6WHD7sHwu9O85mQMOPK2BBBuOu60mLb3mNfU4VkDaU30R6HeSdxlxWNvocD Ll748MIWCygxuPUz1UJsUzYwnx4ILY1BJNv+pK1H87FBYYIQJlN9h8EApwmyEtPsvq0Z za81lyQE8Pymx3bo3iA09Ri6xqtaPRK0Vy83Da7qqOpO7GN/9TffjnqS8FhYOwYaX6Ml Oj8Q== 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=+EmzYVztBuqkWPa3J9xFCquV2rAKQo18WvoWOlsEX30=; b=F35+hvrxsaHD7vkaPqzsg+jAOSQMnzVvJV3E7mAkM6SKhDJVw8KXiLkd7+fseGUBxp NRSV8PrhExDFkiKCvCzE1ZDjKcNEqkE6TrejlPC629P2uD59TF+sPr+KHwyEWd9EuMHa e9Bobv/5nKUzzOsH8T+OWTnAFggPPQO3LnvGxGwHZx8i/xmRH6omBrewOJFQxRMIuKE8 lYV1wwxVYm7kfEPvcSrGssUHfylQ35y+NRk2Srj11EVWvcohA++pWbOXKmi9UZTCgE2V cn16OWYT4zbs6J43VFroh7btZlXV8nQ482bbLWvRsj5eXsWlQPTqc398oXvY1ghMoM3z 05nQ== X-Gm-Message-State: APjAAAWz+bYzmsC91I9FaoZ4WKUEJbbFEkKXsAHZv8/f44eTHdh4v3iO p6lciG1XN8M7nOOvHWEsyoKHqwf7sPw= X-Google-Smtp-Source: APXvYqw2PV/4EHFe7YDJ8/iN5uXfwYZuAtTc52l+l0YGez4RPn1aFjCwb/7W098tZLh8w3XmYiSSIA== X-Received: by 2002:a17:902:6a88:: with SMTP id n8mr26824151plk.70.1562610391267; Mon, 08 Jul 2019 11:26:31 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id o15sm18769295pgj.18.2019.07.08.11.26.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 11:26:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 8 Jul 2019 11:26:11 -0700 Message-Id: <20190708182614.1677-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190708182614.1677-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190708182614.1677-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v9 08/11] 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 c3ab9a21d107..fab87eb5b60f 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -224,17 +224,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