mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
treewide: replace util_mem_is_zero with l_memeqzero
This commit is contained in:
parent
a2926bd3ed
commit
7de5b4adef
@ -3849,7 +3849,7 @@ static void print_wfd_session_info(unsigned int level, const char *label,
|
|||||||
|
|
||||||
print_address(level + 2, "Device address", bytes + 1);
|
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 "
|
print_attr(level+ + 2, "Not associated to an "
|
||||||
"infrastructure AP");
|
"infrastructure AP");
|
||||||
else
|
else
|
||||||
|
2
src/ap.c
2
src/ap.c
@ -2651,7 +2651,7 @@ struct ap_state *ap_start(struct netdev *netdev, struct ap_config *config,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (L_WARN_ON(!config->profile && !config->passphrase[0] &&
|
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;
|
return NULL;
|
||||||
|
|
||||||
ap = l_new(struct ap_state, 1);
|
ap = l_new(struct ap_state, 1);
|
||||||
|
@ -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) ||
|
if ((type == EAP_TYPE_NAK && len == 1 && pkt[0] == 0) ||
|
||||||
(type != EAP_TYPE_NAK && len == 8 &&
|
(type != EAP_TYPE_NAK && len == 8 &&
|
||||||
util_mem_is_zero(pkt, 8)))
|
l_memeqzero(pkt, 8)))
|
||||||
l_debug("EAP peer proposed no alternative methods");
|
l_debug("EAP peer proposed no alternative methods");
|
||||||
else if (type == EAP_TYPE_NAK)
|
else if (type == EAP_TYPE_NAK)
|
||||||
while (len) {
|
while (len) {
|
||||||
|
@ -55,7 +55,7 @@ static void *tx_user_data;
|
|||||||
|
|
||||||
#define VERIFY_IS_ZERO(field) \
|
#define VERIFY_IS_ZERO(field) \
|
||||||
do { \
|
do { \
|
||||||
if (!util_mem_is_zero((field), sizeof((field)))) \
|
if (!l_memeqzero((field), sizeof((field)))) \
|
||||||
return false; \
|
return false; \
|
||||||
} while (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->key_rsc);
|
||||||
VERIFY_IS_ZERO(ek->reserved);
|
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 false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -157,7 +157,7 @@ static const char *hotspot_network_get_path(const struct network_info *info)
|
|||||||
if (config->rc)
|
if (config->rc)
|
||||||
l_checksum_update(sha, config->rc, config->rc_len);
|
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);
|
l_checksum_update(sha, config->hessid, 6);
|
||||||
|
|
||||||
digest = l_checksum_get_string(sha);
|
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,
|
struct hs20_config *config = l_container_of(info, struct hs20_config,
|
||||||
super);
|
super);
|
||||||
|
|
||||||
if (util_mem_is_zero(config->hessid, 6) || !hessid)
|
if (l_memeqzero(config->hessid, 6) || !hessid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !memcmp(config->hessid, hessid, 6);
|
return !memcmp(config->hessid, hessid, 6);
|
||||||
|
@ -2850,7 +2850,7 @@ static int netdev_start_powered_mac_change(struct netdev *netdev)
|
|||||||
uint8_t new_addr[6];
|
uint8_t new_addr[6];
|
||||||
|
|
||||||
/* No address set in handshake, use per-network MAC generation */
|
/* 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,
|
wiphy_generate_address_from_ssid(netdev->wiphy,
|
||||||
(const char *)netdev->handshake->ssid,
|
(const char *)netdev->handshake->ssid,
|
||||||
new_addr);
|
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)
|
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;
|
return false;
|
||||||
|
|
||||||
l_debug("Setting initial address on ifindex: %d to: " MAC,
|
l_debug("Setting initial address on ifindex: %d to: " MAC,
|
||||||
|
@ -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')
|
if (dev->go_group_id.ssid[bss->ssid_len] != '\0')
|
||||||
continue;
|
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,
|
memcmp(bss->addr, dev->conn_peer_interface_addr,
|
||||||
6))
|
6))
|
||||||
l_debug("SSID matched but BSSID didn't match the GO's "
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!util_mem_is_zero(amacs, 30)) {
|
if (!l_memeqzero(amacs, 30)) {
|
||||||
bool amacs_match = false;
|
bool amacs_match = false;
|
||||||
int i;
|
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) ||
|
if (memcmp(mpdu->address_1, dev->addr, 6) ||
|
||||||
(memcmp(mpdu->address_3, dev->addr, 6) &&
|
(memcmp(mpdu->address_3, dev->addr, 6) &&
|
||||||
memcmp(mpdu->address_3, mpdu->address_2, 6) &&
|
memcmp(mpdu->address_3, mpdu->address_2, 6) &&
|
||||||
!util_mem_is_zero(mpdu->address_3, 6)))
|
!l_memeqzero(mpdu->address_3, 6)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
peer = l_queue_find(dev->peer_list, p2p_peer_match, mpdu->address_2);
|
peer = l_queue_find(dev->peer_list, p2p_peer_match, mpdu->address_2);
|
||||||
|
@ -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
|
* check for table requests since we just return whatever we
|
||||||
* have cached.
|
* have cached.
|
||||||
*/
|
*/
|
||||||
if (!util_mem_is_zero(request + 2, 2))
|
if (!l_memeqzero(request + 2, 2))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ bool util_ssid_is_hidden(size_t len, const uint8_t *ssid)
|
|||||||
if (!len)
|
if (!len)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return util_mem_is_zero(ssid, len);
|
return l_memeqzero(ssid, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *util_address_to_string(const uint8_t *addr)
|
const char *util_address_to_string(const uint8_t *addr)
|
||||||
|
11
src/util.h
11
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;
|
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)
|
static inline void util_set_bit(uint8_t *field, unsigned int bit)
|
||||||
{
|
{
|
||||||
field[bit / 8] = 1 << (bit % 8);
|
field[bit / 8] = 1 << (bit % 8);
|
||||||
|
@ -515,7 +515,7 @@ static void wiphy_address_constrain(struct wiphy *wiphy, uint8_t addr[static 6])
|
|||||||
* also not valid
|
* also not valid
|
||||||
*/
|
*/
|
||||||
addr[5] &= 0xfe;
|
addr[5] &= 0xfe;
|
||||||
if (util_mem_is_zero(addr + 3, 3))
|
if (l_memeqzero(addr + 3, 3))
|
||||||
addr[5] = 0x01;
|
addr[5] = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,7 +1257,7 @@ void wiphy_create_complete(struct wiphy *wiphy)
|
|||||||
{
|
{
|
||||||
wiphy_register(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);
|
int err = wiphy_get_permanent_addr_from_sysfs(wiphy);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -813,7 +813,7 @@ static const char *authorized_macs_to_string(const uint8_t *authorized_macs)
|
|||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
const uint8_t *addr = authorized_macs + i * 6;
|
const uint8_t *addr = authorized_macs + i * 6;
|
||||||
|
|
||||||
if (util_mem_is_zero(addr, 6))
|
if (l_memeqzero(addr, 6))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
offset += sprintf(buf + offset, "%s",
|
offset += sprintf(buf + offset, "%s",
|
||||||
|
@ -2100,7 +2100,7 @@ static void wfa_build_authorized_macs(struct wsc_attr_builder *builder,
|
|||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 1; count < 5; 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;
|
break;
|
||||||
|
|
||||||
wsc_attr_builder_put_u8(builder, WSC_WFA_EXTENSION_AUTHORIZED_MACS);
|
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();
|
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);
|
wfa_build_authorized_macs(builder, beacon->authorized_macs);
|
||||||
|
|
||||||
if (beacon->reg_config_methods) {
|
if (beacon->reg_config_methods) {
|
||||||
@ -2265,7 +2265,7 @@ uint8_t *wsc_build_probe_response(
|
|||||||
|
|
||||||
START_WFA_VENDOR_EXTENSION();
|
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,
|
wfa_build_authorized_macs(builder,
|
||||||
probe_response->authorized_macs);
|
probe_response->authorized_macs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user