From 6170c42618e366f5247f162e77f9c4d9320f9c6b Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 16 Jan 2020 16:57:04 +0100 Subject: [PATCH] explicit also in MacAddr --- slsSupportLib/include/network_utils.h | 4 ++-- slsSupportLib/src/network_utils.cpp | 2 +- slsSupportLib/tests/test-network_utils.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/slsSupportLib/include/network_utils.h b/slsSupportLib/include/network_utils.h index faa2f3625..ca90002bc 100755 --- a/slsSupportLib/include/network_utils.h +++ b/slsSupportLib/include/network_utils.h @@ -40,8 +40,8 @@ class MacAddr { public: constexpr MacAddr() noexcept = default; explicit constexpr MacAddr(uint64_t mac) noexcept : addr_{mac} {} - MacAddr(std::string mac); - MacAddr(const char *address); + explicit MacAddr(std::string mac); + explicit MacAddr(const char *address); std::string str() const; std::string hex() const; constexpr bool operator==(const MacAddr &other) const noexcept { diff --git a/slsSupportLib/src/network_utils.cpp b/slsSupportLib/src/network_utils.cpp index a5630eb4e..2a55ab8ed 100755 --- a/slsSupportLib/src/network_utils.cpp +++ b/slsSupportLib/src/network_utils.cpp @@ -136,7 +136,7 @@ MacAddr InterfaceNameToMac(const std::string& inf) { if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) { perror("ioctl(SIOCGIFHWADDR) "); - return std::string("00:00:00:00:00:00"); + return MacAddr{}; } for (int j=0, k=0; j<6; j++) { k+=snprintf(mac+k, mac_len-k-1, j ? ":%02X" : "%02X", diff --git a/slsSupportLib/tests/test-network_utils.cpp b/slsSupportLib/tests/test-network_utils.cpp index 94b8fc1e2..33757d64c 100755 --- a/slsSupportLib/tests/test-network_utils.cpp +++ b/slsSupportLib/tests/test-network_utils.cpp @@ -22,8 +22,8 @@ TEST_CASE("Convert mac address using classes", "[support]") { CHECK(mac0 == vec_addr[i]); CHECK(mac1 == vec_addr[i]); - CHECK(mac0 == vec_ans[i]); - CHECK(mac1 == vec_ans[i]); + CHECK(mac0.str() == vec_ans[i]); + CHECK(mac1.str() == vec_ans[i]); CHECK(mac0.str() == vec_ans[i]); CHECK(mac1.str() == vec_ans[i]); } @@ -59,8 +59,8 @@ TEST_CASE("Convert IP using classes ", "[support]") { CHECK(ip0 == ip1); CHECK(ip0 == vec_addr[i]); CHECK(ip1 == vec_addr[i]); - CHECK(ip0 == vec_ans[i]); - CHECK(ip1 == vec_ans[i]); + CHECK(ip0.str() == vec_ans[i]); + CHECK(ip1.str() == vec_ans[i]); CHECK(ip0.str() == vec_ans[i]); CHECK(ip0.arr().data() == vec_ans[i]); CHECK(ip1.str() == vec_ans[i]);