Fix various issues noted by Coverity
This commit is contained in:
parent
56bb76caca
commit
fb50c44d08
8 changed files with 34 additions and 19 deletions
|
@ -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--;
|
||||
|
|
|
@ -108,7 +108,8 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy,
|
|||
{
|
||||
ret = -ret;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Get the scheduler policy. */
|
||||
|
||||
ret = nxsched_getscheduler((pid_t)thread);
|
||||
|
@ -122,6 +123,7 @@ int pthread_getschedparam(pthread_t thread, FAR int *policy,
|
|||
ret = OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sinfo("Returning %d\n", ret);
|
||||
return ret;
|
||||
|
|
|
@ -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,14 +309,19 @@ 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 */
|
||||
|
||||
wlerr("ERROR: Failed to allocate primitive.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remember that this primitive structure was dynamically allocated */
|
||||
|
||||
pool = POOL_PRIMITIVE_DYNAMIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We have successfully allocated memory from some source.
|
||||
* Zero and tag the alloated primitive structure.
|
||||
|
|
Loading…
Reference in a new issue