wapi: fix coverity warning
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
13a0d539fe
commit
8c8ebf4503
@ -90,6 +90,7 @@ static int wapi_set_addr(int sock, FAR const char *ifname, int cmd,
|
|||||||
WAPI_VALIDATE_PTR(addr);
|
WAPI_VALIDATE_PTR(addr);
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
|
sin.sin_port = 0;
|
||||||
memcpy(&sin.sin_addr, addr, sizeof(struct in_addr));
|
memcpy(&sin.sin_addr, addr, sizeof(struct in_addr));
|
||||||
memcpy(&ifr.ifr_addr, &sin, sizeof(struct sockaddr_in));
|
memcpy(&ifr.ifr_addr, &sin, sizeof(struct sockaddr_in));
|
||||||
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
@ -114,7 +114,7 @@ errout:
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ errout:
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
@ -1068,21 +1068,19 @@ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power,
|
|||||||
|
|
||||||
/* Get flag. */
|
/* Get flag. */
|
||||||
|
|
||||||
if (IW_TXPOW_DBM == (wrq.u.txpower.flags & IW_TXPOW_DBM))
|
switch (wrq.u.txpower.flags & IW_TXPOW_TYPE)
|
||||||
{
|
{
|
||||||
|
case IW_TXPOW_DBM:
|
||||||
*flag = WAPI_TXPOWER_DBM;
|
*flag = WAPI_TXPOWER_DBM;
|
||||||
}
|
break;
|
||||||
else if (IW_TXPOW_MWATT == (wrq.u.txpower.flags & IW_TXPOW_MWATT))
|
case IW_TXPOW_MWATT:
|
||||||
{
|
|
||||||
*flag = WAPI_TXPOWER_MWATT;
|
*flag = WAPI_TXPOWER_MWATT;
|
||||||
}
|
break;
|
||||||
else if (IW_TXPOW_RELATIVE ==
|
case IW_TXPOW_RELATIVE:
|
||||||
(wrq.u.txpower.flags & IW_TXPOW_RELATIVE))
|
|
||||||
{
|
|
||||||
*flag = WAPI_TXPOWER_RELATIVE;
|
*flag = WAPI_TXPOWER_RELATIVE;
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
default:
|
||||||
WAPI_ERROR("ERROR: Unknown flag: %d\n", wrq.u.txpower.flags);
|
WAPI_ERROR("ERROR: Unknown flag: %d\n", wrq.u.txpower.flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user