]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: use hw_addr_equal() or friends
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Jun 2021 15:29:59 +0000 (00:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Jun 2021 15:29:59 +0000 (00:29 +0900)
src/network/networkctl.c
src/network/networkd-link.c

index 4423847eaf6a8f32e528b3a6b6b72aa889bf0e64..aeb3ee5c0911abc29172f80536432811f8904865 100644 (file)
@@ -554,11 +554,11 @@ static int decode_link(sd_netlink_message *m, LinkInfo *info, char **patterns, b
 
         info->has_mac_address =
                 netlink_message_read_hw_addr(m, IFLA_ADDRESS, &info->hw_address) >= 0 &&
-                memcmp(&info->hw_address, &HW_ADDR_NULL, sizeof(struct hw_addr_data)) != 0;
+                !hw_addr_is_null(&info->hw_address);
 
         info->has_permanent_mac_address =
                 ethtool_get_permanent_macaddr(NULL, info->name, &info->permanent_mac_address) >= 0 &&
-                memcmp(&info->permanent_mac_address, &ETHER_ADDR_NULL, sizeof(struct ether_addr)) != 0 &&
+                !ether_addr_is_null(&info->permanent_mac_address) &&
                 (info->hw_address.length != sizeof(struct ether_addr) ||
                  memcmp(&info->permanent_mac_address, info->hw_address.bytes, sizeof(struct ether_addr)) != 0);
 
index 1ec346ff531bb3e5ed4c58d6cbaaf165006ad8fa..911fb9b302c2581d1b99f3df261aa5a101ddc1d1 100644 (file)
@@ -1984,8 +1984,7 @@ static int link_update_hardware_address(Link *link, sd_netlink_message *message)
         if (r < 0)
                 return log_link_warning_errno(link, r, "rtnl: failed to read hardware address: %m");
 
-        if (link->hw_addr.length == hw_addr.length &&
-            memcmp(link->hw_addr.bytes, hw_addr.bytes, hw_addr.length) == 0)
+        if (hw_addr_equal(&link->hw_addr, &hw_addr))
                 return 0;
 
         link->hw_addr = hw_addr;