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 1D86EA0487 for ; Fri, 5 Jul 2019 19:17:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 92F851BE57; Fri, 5 Jul 2019 19:16:54 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 26ED41BE29 for ; Fri, 5 Jul 2019 19:16:45 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id r1so4558993pfq.12 for ; Fri, 05 Jul 2019 10:16:45 -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=STPG36kStuIdOqB694tQF/jXWcSCbokAw/TP1zVi51DPshVCyJhYRT4uuIeqwkG7Hw 9qfK8AAiVHLLz/aa6DW8LNCEeBiH8fpyv8LC/IlotvvKtaS8NIErcNnyiTJ8yRuyARh6 VB6NDCHQpRWi1oa+IaHT5z7+hMJS/Pnpjy56arFL3qbeQqbhd6RzSEgmKtMgxTEKMNn9 T8En33qdv886vKBBRkmjk1a3rVzA3jG8+5C0X6OWfMHBIpCdr4lUQpSy0Jkdu2jzMiP2 FJu7dEZRgecz0K2PCc6mMjcyPTFIa6mN3XOwDiSLK2+yyBcxncCUnp/UcBWxM99g7Szz xiZA== 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=fF7Am7HDTTs0HpCcxF4KEEhmYZXLuBcCnsB8x5CjdrvRUZBFRXkb95zeztbOAjM4Bw +OFA2MMSLZyiTqIgpVIKYzxBa/tsa1ZP/2GvNkD/kmvypZEiZvJDOPwNkfYYRDU88Wi8 lBmY7EtHR0J12RC4WHXYuR8+HIAUog51vBkwINNg/9NABIyH4/pcu/tKAE9yVxURQR6I +rQvZC37M9eT0Jch8LbPe7g3lcjxsEdRmcbhEXMdsn1MkLtR+KDTVwe40UbfRpVbrsDO lnPcui1sKZ40FiFNQgvhheEAIaJL1ynRYCKZQM7GWshPLjryv+lLubsa9slQ3aYhlkD+ pfFg== X-Gm-Message-State: APjAAAUJCoQfKPw5lfcXQ5/1nJ3sVE2n9TpvKiI7EPcGA4fEyWxvQ0Tr Hp8dq8xhQ9WCY4btCaQf1ox+HjKYLSs= X-Google-Smtp-Source: APXvYqz/ytM6aYBptQp9nRQ4JYd5GOnJcyjxsi68BEf2dGHmh4RnzB3Amyuohp6kKG2QcoxQjrc4oQ== X-Received: by 2002:a63:e20a:: with SMTP id q10mr6561551pgh.24.1562347004036; Fri, 05 Jul 2019 10:16:44 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 21sm8991014pjh.25.2019.07.05.10.16.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:16:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 5 Jul 2019 10:16:23 -0700 Message-Id: <20190705171626.13448-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190705171626.13448-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190705171626.13448-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v8 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 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