From 29fb845dfcf988110d01c141fdd490163a6f3714 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 23 Sep 2019 09:45:49 +0200 Subject: trafgen: reset errno before calling sscanf in str2mac When testing trafgen with the following example from the man page the error message "Failed to parse MAC address 11:22:33:44:55:66" is printed. trafgen -o lo --cpus 1 -n 3 '{ eth(da=11:22:33:44:55:66, da[0]=dinc()), tcp() }' Turns out errno was not cleared before str2mac() called sscanf(). Signed-off-by: Joachim Nilsson Signed-off-by: Tobias Klauser --- str.c | 1 + 1 file changed, 1 insertion(+) diff --git a/str.c b/str.c index 1d3e7ac..9ab94ca 100644 --- a/str.c +++ b/str.c @@ -143,6 +143,7 @@ int str2mac(const char *str, uint8_t *mac, size_t len) if (len < 6) return -ENOSPC; + errno = 0; count = sscanf(str, "%02X:%02X:%02X:%02X:%02X:%02X", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]); -- cgit v1.2.3-54-g00ecf