From: Stephen Hemminger Date: Fri, 5 Jul 2019 17:16:23 +0000 (-0700) Subject: net/virtio: use new ethernet address parser X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8eb49a1860ebfc9055f0374d1301d4bf42ba8bfc;p=dpdk.git net/virtio: use new ethernet address parser Use rte_ether_unformat_addr rather than sscanf. Signed-off-by: Stephen Hemminger Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index c3ab9a21d1..fab87eb5b6 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 @@ out: 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 */