drivers/sensors/apds9960.c: Initial state of allocated structure was not being set. Noted by Leif Jacob.

This commit is contained in:
Gregory Nutt
2019-05-06 09:09:19 -06:00
parent 40be068528
commit 49b2b74105
3 changed files with 3 additions and 15 deletions
+1 -1
View File
@@ -1177,7 +1177,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
priv = (FAR struct ft5x06_dev_s *)kmm_zalloc(sizeof(struct ft5x06_dev_s)); priv = (FAR struct ft5x06_dev_s *)kmm_zalloc(sizeof(struct ft5x06_dev_s));
if (!priv) if (!priv)
{ {
ierr("ERROR: kmm_malloc(%d) failed\n", sizeof(struct ft5x06_dev_s)); ierr("ERROR: kmm_zalloc(%d) failed\n", sizeof(struct ft5x06_dev_s));
return -ENOMEM; return -ENOMEM;
} }
+1 -2
View File
@@ -1251,7 +1251,7 @@ int apds9960_register(FAR const char *devpath,
/* Initialize the APDS9960 device structure */ /* Initialize the APDS9960 device structure */
FAR struct apds9960_dev_s *priv = FAR struct apds9960_dev_s *priv =
(FAR struct apds9960_dev_s *)kmm_malloc(sizeof(struct apds9960_dev_s)); (FAR struct apds9960_dev_s *)kmm_zalloc(sizeof(struct apds9960_dev_s));
if (priv == NULL) if (priv == NULL)
{ {
@@ -1260,7 +1260,6 @@ int apds9960_register(FAR const char *devpath,
} }
priv->config = config; priv->config = config;
priv->work.worker = NULL;
priv->gesture_motion = DIR_NONE; priv->gesture_motion = DIR_NONE;
nxsem_init(&priv->sample_sem, 0, 0); nxsem_init(&priv->sample_sem, 0, 0);
+1 -12
View File
@@ -1460,7 +1460,7 @@ int nrf24l01_register(FAR struct spi_dev_s *spi,
DEBUGASSERT((spi != NULL) & (cfg != NULL)); DEBUGASSERT((spi != NULL) & (cfg != NULL));
if ((dev = kmm_malloc(sizeof(struct nrf24l01_dev_s))) == NULL) if ((dev = kmm_zalloc(sizeof(struct nrf24l01_dev_s))) == NULL)
{ {
return -ENOMEM; return -ENOMEM;
} }
@@ -1469,16 +1469,9 @@ int nrf24l01_register(FAR struct spi_dev_s *spi,
dev->config = cfg; dev->config = cfg;
dev->state = ST_UNKNOWN; dev->state = ST_UNKNOWN;
dev->en_aa = 0;
dev->ce_enabled = false; dev->ce_enabled = false;
nxsem_init(&(dev->devsem), 0, 1); nxsem_init(&(dev->devsem), 0, 1);
dev->nopens = 0;
#ifndef CONFIG_DISABLE_POLL
dev->pfd = NULL;
#endif
nxsem_init(&dev->sem_tx, 0, 0); nxsem_init(&dev->sem_tx, 0, 0);
nxsem_setprotocol(&dev->sem_tx, SEM_PRIO_NONE); nxsem_setprotocol(&dev->sem_tx, SEM_PRIO_NONE);
@@ -1490,10 +1483,6 @@ int nrf24l01_register(FAR struct spi_dev_s *spi,
} }
dev->rx_fifo = rx_fifo; dev->rx_fifo = rx_fifo;
dev->nxt_read = 0;
dev->nxt_write = 0;
dev->fifo_len = 0;
dev->irq_work.worker = 0;
nxsem_init(&(dev->sem_fifo), 0, 1); nxsem_init(&(dev->sem_fifo), 0, 1);
nxsem_init(&(dev->sem_rx), 0, 0); nxsem_init(&(dev->sem_rx), 0, 0);