Fix various issues noted by Coverity
This commit is contained in:
parent
56bb76caca
commit
fb50c44d08
@ -77,7 +77,7 @@
|
||||
|
||||
int nxsem_getvalue(FAR sem_t *sem, FAR int *sval)
|
||||
{
|
||||
if (sem && sval)
|
||||
if (sem != NULL && sval != NULL)
|
||||
{
|
||||
*sval = sem->semcount;
|
||||
return OK;
|
||||
|
@ -1174,7 +1174,7 @@ int psock_tcp_cansend(FAR struct socket *psock)
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
||||
if (tcp_wrbuffer_test())
|
||||
if (tcp_wrbuffer_test() < 0)
|
||||
{
|
||||
return -EWOULDBLOCK;
|
||||
}
|
||||
|
@ -211,8 +211,15 @@ void tcp_wrbuffer_release(FAR struct tcp_wrbuffer_s *wrb)
|
||||
int tcp_wrbuffer_test(void)
|
||||
{
|
||||
int val = 0;
|
||||
nxsem_getvalue(&g_wrbuffer.sem, &val);
|
||||
return val > 0 ? OK : ERROR;
|
||||
int ret;
|
||||
|
||||
ret = nxsem_getvalue(&g_wrbuffer.sem, &val);
|
||||
if (ret >= 0)
|
||||
{
|
||||
ret = val > 0 ? OK : -ENOSPC;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_TCP && CONFIG_NET_TCP_WRITE_BUFFERS */
|
||||
|
@ -302,7 +302,7 @@ ssize_t nxmq_do_receive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
||||
* time the task is unblocked
|
||||
*/
|
||||
|
||||
DEBUGASSERT(btcb);
|
||||
DEBUGASSERT(btcb != NULL);
|
||||
|
||||
btcb->msgwaitq = NULL;
|
||||
msgq->nwaitnotfull--;
|
||||
|
@ -104,22 +104,24 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy,
|
||||
/* Get the scheduler parameters of the thread. */
|
||||
|
||||
ret = nxsched_getparam((pid_t)thread, param);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -ret;
|
||||
}
|
||||
|
||||
/* Get the scheduler policy. */
|
||||
|
||||
ret = nxsched_getscheduler((pid_t)thread);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
*policy = ret;
|
||||
ret = OK;
|
||||
/* Get the scheduler policy. */
|
||||
|
||||
ret = nxsched_getscheduler((pid_t)thread);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = -ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
*policy = ret;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,10 +153,10 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex)
|
||||
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
|
||||
mutex->nlocks = 0;
|
||||
#endif
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
sched_unlock();
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
sinfo("Returning %d\n", ret);
|
||||
|
@ -141,6 +141,7 @@ int nxsched_setscheduler(pid_t pid, int policy,
|
||||
{
|
||||
default:
|
||||
DEBUGPANIC();
|
||||
break;
|
||||
|
||||
case SCHED_FIFO:
|
||||
{
|
||||
|
@ -309,12 +309,17 @@ FAR struct ieee802154_primitive_s *ieee802154_primitive_allocate(void)
|
||||
|
||||
/* Check if we allocated the primitive structure */
|
||||
|
||||
if (prim != NULL)
|
||||
if (prim == NULL)
|
||||
{
|
||||
/* Yes... remember that this primitive structure was dynamically allocated */
|
||||
/* No.. memory not available */
|
||||
|
||||
pool = POOL_PRIMITIVE_DYNAMIC;
|
||||
wlerr("ERROR: Failed to allocate primitive.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remember that this primitive structure was dynamically allocated */
|
||||
|
||||
pool = POOL_PRIMITIVE_DYNAMIC;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user