diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 586f97ad..200e03d5 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -3849,7 +3849,7 @@ static void print_wfd_session_info(unsigned int level, const char *label, print_address(level + 2, "Device address", bytes + 1); - if (util_mem_is_zero(bytes + 7, 6)) + if (l_memeqzero(bytes + 7, 6)) print_attr(level+ + 2, "Not associated to an " "infrastructure AP"); else diff --git a/src/ap.c b/src/ap.c index 77d691f3..5a86527f 100644 --- a/src/ap.c +++ b/src/ap.c @@ -2651,7 +2651,7 @@ struct ap_state *ap_start(struct netdev *netdev, struct ap_config *config, return NULL; if (L_WARN_ON(!config->profile && !config->passphrase[0] && - util_mem_is_zero(config->psk, sizeof(config->psk)))) + l_memeqzero(config->psk, sizeof(config->psk)))) return NULL; ap = l_new(struct ap_state, 1); diff --git a/src/eap.c b/src/eap.c index dea0c3cf..9f658d8c 100644 --- a/src/eap.c +++ b/src/eap.c @@ -427,7 +427,7 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt, if ((type == EAP_TYPE_NAK && len == 1 && pkt[0] == 0) || (type != EAP_TYPE_NAK && len == 8 && - util_mem_is_zero(pkt, 8))) + l_memeqzero(pkt, 8))) l_debug("EAP peer proposed no alternative methods"); else if (type == EAP_TYPE_NAK) while (len) { diff --git a/src/eapol.c b/src/eapol.c index ecb8b4f8..f385ad2a 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -55,7 +55,7 @@ static void *tx_user_data; #define VERIFY_IS_ZERO(field) \ do { \ - if (!util_mem_is_zero((field), sizeof((field)))) \ + if (!l_memeqzero((field), sizeof((field)))) \ return false; \ } while (false) \ @@ -456,7 +456,7 @@ bool eapol_verify_ptk_1_of_4(const struct eapol_key *ek, size_t mic_len) VERIFY_IS_ZERO(ek->key_rsc); VERIFY_IS_ZERO(ek->reserved); - if (!util_mem_is_zero(EAPOL_KEY_MIC(ek), mic_len)) + if (!l_memeqzero(EAPOL_KEY_MIC(ek), mic_len)) return false; return true; diff --git a/src/hotspot.c b/src/hotspot.c index ea11d59a..06e8cbdd 100644 --- a/src/hotspot.c +++ b/src/hotspot.c @@ -157,7 +157,7 @@ static const char *hotspot_network_get_path(const struct network_info *info) if (config->rc) l_checksum_update(sha, config->rc, config->rc_len); - if (!util_mem_is_zero(config->hessid, 6)) + if (!l_memeqzero(config->hessid, 6)) l_checksum_update(sha, config->hessid, 6); digest = l_checksum_get_string(sha); @@ -187,7 +187,7 @@ static bool hotspot_match_hessid(const struct network_info *info, struct hs20_config *config = l_container_of(info, struct hs20_config, super); - if (util_mem_is_zero(config->hessid, 6) || !hessid) + if (l_memeqzero(config->hessid, 6) || !hessid) return false; return !memcmp(config->hessid, hessid, 6); diff --git a/src/netdev.c b/src/netdev.c index 1f2aa51c..c5028b5c 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2850,7 +2850,7 @@ static int netdev_start_powered_mac_change(struct netdev *netdev) uint8_t new_addr[6]; /* No address set in handshake, use per-network MAC generation */ - if (util_mem_is_zero(netdev->handshake->spa, ETH_ALEN)) + if (l_memeqzero(netdev->handshake->spa, ETH_ALEN)) wiphy_generate_address_from_ssid(netdev->wiphy, (const char *)netdev->handshake->ssid, new_addr); @@ -4843,7 +4843,7 @@ static void netdev_initial_up_cb(int error, uint16_t type, const void *data, static bool netdev_check_set_mac(struct netdev *netdev) { - if (util_mem_is_zero(netdev->set_mac_once, 6)) + if (l_memeqzero(netdev->set_mac_once, 6)) return false; l_debug("Setting initial address on ifindex: %d to: " MAC, diff --git a/src/p2p.c b/src/p2p.c index 22b28f1c..a3d53abf 100644 --- a/src/p2p.c +++ b/src/p2p.c @@ -1323,7 +1323,7 @@ static bool p2p_provision_scan_notify(int err, struct l_queue *bss_list, if (dev->go_group_id.ssid[bss->ssid_len] != '\0') continue; - if (!util_mem_is_zero(dev->conn_peer_interface_addr, 6) && + if (!l_memeqzero(dev->conn_peer_interface_addr, 6) && memcmp(bss->addr, dev->conn_peer_interface_addr, 6)) l_debug("SSID matched but BSSID didn't match the GO's " @@ -1419,7 +1419,7 @@ static bool p2p_provision_scan_notify(int err, struct l_queue *bss_list, continue; } - if (!util_mem_is_zero(amacs, 30)) { + if (!l_memeqzero(amacs, 30)) { bool amacs_match = false; int i; @@ -1945,7 +1945,7 @@ static void p2p_device_go_negotiation_req_cb(const struct mmpdu_header *mpdu, if (memcmp(mpdu->address_1, dev->addr, 6) || (memcmp(mpdu->address_3, dev->addr, 6) && memcmp(mpdu->address_3, mpdu->address_2, 6) && - !util_mem_is_zero(mpdu->address_3, 6))) + !l_memeqzero(mpdu->address_3, 6))) return; peer = l_queue_find(dev->peer_list, p2p_peer_match, mpdu->address_2); diff --git a/src/rrm.c b/src/rrm.c index 1a9ab140..3a530316 100644 --- a/src/rrm.c +++ b/src/rrm.c @@ -478,7 +478,7 @@ static bool rrm_verify_beacon_request(const uint8_t *request, size_t len) * check for table requests since we just return whatever we * have cached. */ - if (!util_mem_is_zero(request + 2, 2)) + if (!l_memeqzero(request + 2, 2)) return false; } diff --git a/src/util.c b/src/util.c index 009596ba..66915060 100644 --- a/src/util.c +++ b/src/util.c @@ -101,7 +101,7 @@ bool util_ssid_is_hidden(size_t len, const uint8_t *ssid) if (!len) return true; - return util_mem_is_zero(ssid, len); + return l_memeqzero(ssid, len); } const char *util_address_to_string(const uint8_t *addr) diff --git a/src/util.h b/src/util.h index d2fe0d75..e61bef75 100644 --- a/src/util.h +++ b/src/util.h @@ -55,17 +55,6 @@ static inline bool util_is_bit_set(const uint8_t oct, int bit) return oct & mask ? true : false; } -static inline bool util_mem_is_zero(const uint8_t *field, size_t size) -{ - size_t i; - - for (i = 0; i < size; i++) - if (field[i] != 0) - return false; - - return true; -} - static inline void util_set_bit(uint8_t *field, unsigned int bit) { field[bit / 8] = 1 << (bit % 8); diff --git a/src/wiphy.c b/src/wiphy.c index 3adc5669..e1de3140 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -515,7 +515,7 @@ static void wiphy_address_constrain(struct wiphy *wiphy, uint8_t addr[static 6]) * also not valid */ addr[5] &= 0xfe; - if (util_mem_is_zero(addr + 3, 3)) + if (l_memeqzero(addr + 3, 3)) addr[5] = 0x01; } @@ -1257,7 +1257,7 @@ void wiphy_create_complete(struct wiphy *wiphy) { wiphy_register(wiphy); - if (util_mem_is_zero(wiphy->permanent_addr, 6)) { + if (l_memeqzero(wiphy->permanent_addr, 6)) { int err = wiphy_get_permanent_addr_from_sysfs(wiphy); if (err < 0) diff --git a/src/wsc.c b/src/wsc.c index f8fb1aad..23ba755e 100644 --- a/src/wsc.c +++ b/src/wsc.c @@ -813,7 +813,7 @@ static const char *authorized_macs_to_string(const uint8_t *authorized_macs) for (i = 0; i < 5; i++) { const uint8_t *addr = authorized_macs + i * 6; - if (util_mem_is_zero(addr, 6)) + if (l_memeqzero(addr, 6)) continue; offset += sprintf(buf + offset, "%s", diff --git a/src/wscutil.c b/src/wscutil.c index 81b175d8..49e73d7f 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -2100,7 +2100,7 @@ static void wfa_build_authorized_macs(struct wsc_attr_builder *builder, int count; for (count = 1; count < 5; count++) - if (util_mem_is_zero(authorized_macs + count * 6, 6)) + if (l_memeqzero(authorized_macs + count * 6, 6)) break; wsc_attr_builder_put_u8(builder, WSC_WFA_EXTENSION_AUTHORIZED_MACS); @@ -2170,7 +2170,7 @@ uint8_t *wsc_build_beacon(const struct wsc_beacon *beacon, size_t *out_len) START_WFA_VENDOR_EXTENSION(); - if (!util_mem_is_zero(beacon->authorized_macs, 6)) + if (!l_memeqzero(beacon->authorized_macs, 6)) wfa_build_authorized_macs(builder, beacon->authorized_macs); if (beacon->reg_config_methods) { @@ -2265,7 +2265,7 @@ uint8_t *wsc_build_probe_response( START_WFA_VENDOR_EXTENSION(); - if (!util_mem_is_zero(probe_response->authorized_macs, 6)) + if (!l_memeqzero(probe_response->authorized_macs, 6)) wfa_build_authorized_macs(builder, probe_response->authorized_macs);