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);
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = 0;
|
||||
memcpy(&sin.sin_addr, addr, sizeof(struct in_addr));
|
||||
memcpy(&ifr.ifr_addr, &sin, sizeof(struct sockaddr_in));
|
||||
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||
|
@ -114,7 +114,7 @@ errout:
|
||||
free(buf);
|
||||
}
|
||||
|
||||
if (fd > 0)
|
||||
if (fd >= 0)
|
||||
{
|
||||
close(fd);
|
||||
}
|
||||
@ -512,7 +512,7 @@ errout:
|
||||
free(buf);
|
||||
}
|
||||
|
||||
if (fd > 0)
|
||||
if (fd >= 0)
|
||||
{
|
||||
close(fd);
|
||||
}
|
||||
|
@ -1068,23 +1068,21 @@ int wapi_get_txpower(int sock, FAR const char *ifname, FAR int *power,
|
||||
|
||||
/* Get flag. */
|
||||
|
||||
if (IW_TXPOW_DBM == (wrq.u.txpower.flags & IW_TXPOW_DBM))
|
||||
switch (wrq.u.txpower.flags & IW_TXPOW_TYPE)
|
||||
{
|
||||
*flag = WAPI_TXPOWER_DBM;
|
||||
}
|
||||
else if (IW_TXPOW_MWATT == (wrq.u.txpower.flags & IW_TXPOW_MWATT))
|
||||
{
|
||||
*flag = WAPI_TXPOWER_MWATT;
|
||||
}
|
||||
else if (IW_TXPOW_RELATIVE ==
|
||||
(wrq.u.txpower.flags & IW_TXPOW_RELATIVE))
|
||||
{
|
||||
*flag = WAPI_TXPOWER_RELATIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
WAPI_ERROR("ERROR: Unknown flag: %d\n", wrq.u.txpower.flags);
|
||||
return -1;
|
||||
case IW_TXPOW_DBM:
|
||||
*flag = WAPI_TXPOWER_DBM;
|
||||
break;
|
||||
case IW_TXPOW_MWATT:
|
||||
*flag = WAPI_TXPOWER_MWATT;
|
||||
break;
|
||||
case IW_TXPOW_RELATIVE:
|
||||
*flag = WAPI_TXPOWER_RELATIVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
WAPI_ERROR("ERROR: Unknown flag: %d\n", wrq.u.txpower.flags);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get power. */
|
||||
|
Loading…
Reference in New Issue
Block a user