staging: ks7010: add explicit check to memcmp() calls
Calls to functions memcmp() and strcmp() are more clearly readable when the return value is explicitly checked. i.e if (memcmp(foo, bar, size) == 0) Modify driver to use an explicit check on the value returned by memcmp(). Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
58af272b33
commit
b5ca039ac1
@@ -271,7 +271,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
|
|||||||
memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
|
memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
|
||||||
break;
|
break;
|
||||||
case 221: /* WPA */
|
case 221: /* WPA */
|
||||||
if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
|
if (memcmp(bp + 2, "\x00\x50\xf2\x01", 4) == 0) { /* WPA OUI check */
|
||||||
ap->wpa_ie.id = *bp;
|
ap->wpa_ie.id = *bp;
|
||||||
if (*(bp + 1) <= RSN_IE_BODY_MAX) {
|
if (*(bp + 1) <= RSN_IE_BODY_MAX) {
|
||||||
ap->wpa_ie.size = *(bp + 1);
|
ap->wpa_ie.size = *(bp + 1);
|
||||||
@@ -325,7 +325,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
|
|||||||
eth_proto = ntohs(eth_hdr->h_proto);
|
eth_proto = ntohs(eth_hdr->h_proto);
|
||||||
|
|
||||||
/* source address check */
|
/* source address check */
|
||||||
if (!memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN))
|
if (memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
|
if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
|
||||||
@@ -353,7 +353,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
|
|||||||
(uint8_t)0, /* priority */
|
(uint8_t)0, /* priority */
|
||||||
(uint8_t *)michael_mic.Result);
|
(uint8_t *)michael_mic.Result);
|
||||||
}
|
}
|
||||||
if (memcmp(michael_mic.Result, RecvMIC, 8)) {
|
if (memcmp(michael_mic.Result, RecvMIC, 8) != 0) {
|
||||||
now = jiffies;
|
now = jiffies;
|
||||||
mic_failure = &priv->wpa.mic_failure;
|
mic_failure = &priv->wpa.mic_failure;
|
||||||
/* MIC FAILURE */
|
/* MIC FAILURE */
|
||||||
@@ -421,7 +421,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
|
|||||||
DPRINTK(3, "ether protocol = %04X\n", eth_proto);
|
DPRINTK(3, "ether protocol = %04X\n", eth_proto);
|
||||||
|
|
||||||
/* source address check */
|
/* source address check */
|
||||||
if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) {
|
if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
|
||||||
DPRINTK(1, "invalid : source is own mac address !!\n");
|
DPRINTK(1, "invalid : source is own mac address !!\n");
|
||||||
DPRINTK(1,
|
DPRINTK(1,
|
||||||
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
|
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||||
@@ -836,9 +836,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
|
|||||||
|
|
||||||
if (priv->scan_ind_count) {
|
if (priv->scan_ind_count) {
|
||||||
for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
|
for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
|
||||||
if (!memcmp
|
if (memcmp(ap_info->bssid,
|
||||||
(ap_info->bssid,
|
priv->aplist.ap[i].bssid, ETH_ALEN) == 0) {
|
||||||
priv->aplist.ap[i].bssid, ETH_ALEN)) {
|
|
||||||
if (ap_info->frame_type ==
|
if (ap_info->frame_type ==
|
||||||
FRAME_TYPE_PROBE_RESP)
|
FRAME_TYPE_PROBE_RESP)
|
||||||
get_ap_information(priv, ap_info,
|
get_ap_information(priv, ap_info,
|
||||||
@@ -1168,7 +1167,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet)
|
|||||||
|
|
||||||
/* packet check */
|
/* packet check */
|
||||||
eth = (struct ethhdr *)packet->data;
|
eth = (struct ethhdr *)packet->data;
|
||||||
if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) {
|
if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
|
||||||
DPRINTK(1, "invalid mac address !!\n");
|
DPRINTK(1, "invalid mac address !!\n");
|
||||||
DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
|
DPRINTK(1, "ethernet->h_source=%pM\n", eth->h_source);
|
||||||
ret = -ENXIO;
|
ret = -ENXIO;
|
||||||
|
@@ -1924,9 +1924,8 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
|
|||||||
if (list_empty(&priv->pmklist.head)) { /* new list */
|
if (list_empty(&priv->pmklist.head)) { /* new list */
|
||||||
for (i = 0; i < PMK_LIST_MAX; i++) {
|
for (i = 0; i < PMK_LIST_MAX; i++) {
|
||||||
pmk = &priv->pmklist.pmk[i];
|
pmk = &priv->pmklist.pmk[i];
|
||||||
if (!memcmp
|
if (memcmp("\x00\x00\x00\x00\x00\x00",
|
||||||
("\x00\x00\x00\x00\x00\x00", pmk->bssid,
|
pmk->bssid, ETH_ALEN) == 0)
|
||||||
ETH_ALEN))
|
|
||||||
break; /* loop */
|
break; /* loop */
|
||||||
}
|
}
|
||||||
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
|
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
|
||||||
@@ -1938,7 +1937,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
|
|||||||
/* search cache data */
|
/* search cache data */
|
||||||
list_for_each(ptr, &priv->pmklist.head) {
|
list_for_each(ptr, &priv->pmklist.head) {
|
||||||
pmk = list_entry(ptr, struct pmk_t, list);
|
pmk = list_entry(ptr, struct pmk_t, list);
|
||||||
if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list move to head. */
|
if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
|
||||||
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
|
memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN);
|
||||||
list_move(&pmk->list, &priv->pmklist.head);
|
list_move(&pmk->list, &priv->pmklist.head);
|
||||||
break; /* list_for_each */
|
break; /* list_for_each */
|
||||||
@@ -1950,8 +1949,8 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
|
|||||||
if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */
|
if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */
|
||||||
for (i = 0; i < PMK_LIST_MAX; i++) {
|
for (i = 0; i < PMK_LIST_MAX; i++) {
|
||||||
pmk = &priv->pmklist.pmk[i];
|
pmk = &priv->pmklist.pmk[i];
|
||||||
if (!memcmp("\x00\x00\x00\x00\x00\x00",
|
if (memcmp("\x00\x00\x00\x00\x00\x00",
|
||||||
pmk->bssid, ETH_ALEN))
|
pmk->bssid, ETH_ALEN) == 0)
|
||||||
break; /* loop */
|
break; /* loop */
|
||||||
}
|
}
|
||||||
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
|
memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN);
|
||||||
@@ -1973,7 +1972,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
|
|||||||
/* search cache data */
|
/* search cache data */
|
||||||
list_for_each(ptr, &priv->pmklist.head) {
|
list_for_each(ptr, &priv->pmklist.head) {
|
||||||
pmk = list_entry(ptr, struct pmk_t, list);
|
pmk = list_entry(ptr, struct pmk_t, list);
|
||||||
if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list del. */
|
if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) {
|
||||||
eth_zero_addr(pmk->bssid);
|
eth_zero_addr(pmk->bssid);
|
||||||
memset(pmk->pmkid, 0, IW_PMKID_LEN);
|
memset(pmk->pmkid, 0, IW_PMKID_LEN);
|
||||||
list_del_init(&pmk->list);
|
list_del_init(&pmk->list);
|
||||||
|
Reference in New Issue
Block a user