STM32/STM32 F7: Fix some errors found by Coverity.

This commit is contained in:
Gregory Nutt 2017-09-13 13:05:13 -06:00
parent cca15891c9
commit 13006ecca9
3 changed files with 22 additions and 8 deletions

View File

@ -246,9 +246,11 @@ static int stm32_interrupt(int irq, void *context, FAR void *arg)
static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen)
{
if (sem_wait(&g_rngdev.rd_devsem) != OK)
int ret;
if (sem_wait(&g_rngdev.rd_devsem) < 0)
{
return -errno;
return -get_errno();
}
else
{
@ -272,13 +274,17 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen)
/* Wait until the buffer is filled */
sem_wait(&g_rngdev.rd_readsem);
ret = sem_wait(&g_rngdev.rd_readsem);
if (ret < 0)
{
ret = -get_errno();
}
/* Free RNG for next use */
sem_post(&g_rngdev.rd_devsem);
return buflen;
return ret < 0 ? ret : buflen;
}
}

View File

@ -3369,6 +3369,8 @@ static int stm32_phyinit(struct stm32_ethmac_s *priv)
default:
nerr("ERROR: Unrecognized PHY status setting\n");
/* Falls through */
case CONFIG_STM32F7_PHYSR_10HD:
priv->fduplex = 0;
priv->mbps100 = 0;

View File

@ -267,9 +267,11 @@ static int stm32_rnginterrupt(int irq, void *context, FAR void *arg)
static ssize_t stm32_rngread(struct file *filep, char *buffer, size_t buflen)
{
if (sem_wait(&g_rngdev.rd_devsem) != OK)
int ret;
if (sem_wait(&g_rngdev.rd_devsem) < 0)
{
return -errno;
return -get_errno();
}
else
{
@ -293,7 +295,11 @@ static ssize_t stm32_rngread(struct file *filep, char *buffer, size_t buflen)
/* Wait until the buffer is filled */
sem_wait(&g_rngdev.rd_readsem);
ret = sem_wait(&g_rngdev.rd_readsem);
if (ret < 0)
{
ret = -get_errno();
}
/* Done with the operation semaphore */
@ -303,7 +309,7 @@ static ssize_t stm32_rngread(struct file *filep, char *buffer, size_t buflen)
sem_post(&g_rngdev.rd_devsem);
return buflen;
return ret < 0 ? ret : buflen;
}
}