Call nxsem_destroy or nxmutex_destry in the error path

1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
anjiahao
2022-09-06 14:18:45 +08:00
committed by Petro Karashchenko
parent 99cfffc96a
commit d7b4e91dda
53 changed files with 606 additions and 619 deletions
+4 -3
View File
@@ -716,7 +716,7 @@ static int ads7843e_interrupt(int irq, FAR void *context, FAR void *arg)
static int ads7843e_open(FAR struct file *filep)
{
#ifdef CONFIG_ADS7843E_REFCNT
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct ads7843e_dev_s *priv;
uint8_t tmp;
int ret;
@@ -772,7 +772,7 @@ errout_with_lock:
static int ads7843e_close(FAR struct file *filep)
{
#ifdef CONFIG_ADS7843E_REFCNT
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct ads7843e_dev_s *priv;
int ret;
@@ -943,7 +943,7 @@ errout:
static int ads7843e_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct ads7843e_dev_s *priv;
int ret;
@@ -1214,6 +1214,7 @@ int ads7843e_register(FAR struct spi_dev_s *spi,
errout_with_priv:
nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_ADS7843E_MULTIPLE
kmm_free(priv);
#endif
+8 -7
View File
@@ -850,7 +850,7 @@ static ssize_t ft5x06_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
FAR struct inode *inode;
FAR struct ft5x06_dev_s *priv;
FAR struct ft5x06_dev_s *priv;
int ret;
DEBUGASSERT(filep);
@@ -921,9 +921,9 @@ errout:
static int ft5x06_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct ft5x06_dev_s *priv;
int ret;
int ret;
iinfo("cmd: %d arg: %ld\n", cmd, arg);
DEBUGASSERT(filep);
@@ -975,12 +975,12 @@ static int ft5x06_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
****************************************************************************/
static int ft5x06_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
bool setup)
{
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct ft5x06_dev_s *priv;
int ret;
int i;
int ret;
int i;
iinfo("setup: %d\n", (int)setup);
DEBUGASSERT(filep && fds);
@@ -1176,6 +1176,7 @@ int ft5x06_register(FAR struct i2c_master_s *i2c,
errout_with_priv:
nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
kmm_free(priv);
return ret;
}
+4 -3
View File
@@ -709,7 +709,7 @@ static int max11802_interrupt(int irq, FAR void *context, FAR void *arg)
static int max11802_open(FAR struct file *filep)
{
#ifdef CONFIG_MAX11802_REFCNT
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct max11802_dev_s *priv;
uint8_t tmp;
int ret;
@@ -765,7 +765,7 @@ errout_with_lock:
static int max11802_close(FAR struct file *filep)
{
#ifdef CONFIG_MAX11802_REFCNT
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct max11802_dev_s *priv;
int ret;
@@ -936,7 +936,7 @@ errout:
static int max11802_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode;
FAR struct inode *inode;
FAR struct max11802_dev_s *priv;
int ret;
@@ -1248,6 +1248,7 @@ int max11802_register(FAR struct spi_dev_s *spi,
errout_with_priv:
nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_MAX11802_MULTIPLE
kmm_free(priv);
#endif
+1 -1
View File
@@ -188,7 +188,7 @@ static int nunchuck_sample(FAR struct nunchuck_dev_s *priv,
{
uint8_t cmd[2];
uint8_t data[6];
static bool initialized = false;
static bool initialized;
if (!initialized)
{
+24 -23
View File
@@ -293,7 +293,7 @@ static djoy_buttonset_t djoy_supported(
static djoy_buttonset_t djoy_sample(
FAR const struct djoy_lowerhalf_s *lower)
{
FAR struct spq10kbd_dev_s *priv =
FAR struct spq10kbd_dev_s *priv =
(FAR struct spq10kbd_dev_s *)(lower->config);
return priv->djoystate;
}
@@ -311,7 +311,7 @@ static void djoy_enable(FAR const struct djoy_lowerhalf_s *lower,
djoy_buttonset_t press, djoy_buttonset_t release,
djoy_interrupt_t handler, FAR void *arg)
{
FAR struct spq10kbd_dev_s *priv =
FAR struct spq10kbd_dev_s *priv =
(FAR struct spq10kbd_dev_s *)(lower->config);
priv->djoypressmask = press;
priv->djoyreleasemask = release;
@@ -326,11 +326,11 @@ static void djoy_enable(FAR const struct djoy_lowerhalf_s *lower,
static void spq10kbd_worker(FAR void *arg)
{
FAR struct spq10kbd_dev_s *priv = (FAR struct spq10kbd_dev_s *)arg;
uint16_t regval;
uint8_t key;
uint8_t state;
int ret;
FAR struct spq10kbd_dev_s *priv = (FAR struct spq10kbd_dev_s *)arg;
uint16_t regval;
uint8_t key;
uint8_t state;
int ret;
ret = nxmutex_lock(&priv->lock);
if (ret < 0)
@@ -420,8 +420,8 @@ static void spq10kbd_worker(FAR void *arg)
static int spq10kbd_interrupt(int irq, FAR void *context, FAR void *arg)
{
FAR struct spq10kbd_dev_s *priv = (FAR struct spq10kbd_dev_s *)arg;
int ret;
FAR struct spq10kbd_dev_s *priv = (FAR struct spq10kbd_dev_s *)arg;
int ret;
/* Let the event worker know that it has an interrupt event to handle
* It is possbile that we will already have work scheduled from a
@@ -451,8 +451,8 @@ static int spq10kbd_interrupt(int irq, FAR void *context, FAR void *arg)
static int spq10kbd_open(FAR struct file *filep)
{
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
DEBUGASSERT(filep && filep->f_inode);
inode = filep->f_inode;
@@ -475,8 +475,8 @@ static int spq10kbd_open(FAR struct file *filep)
static int spq10kbd_close(FAR struct file *filep)
{
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
DEBUGASSERT(filep && filep->f_inode);
inode = filep->f_inode;
@@ -502,11 +502,11 @@ static int spq10kbd_close(FAR struct file *filep)
static ssize_t spq10kbd_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
size_t nbytes;
uint16_t tail;
int ret;
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
size_t nbytes;
uint16_t tail;
int ret;
DEBUGASSERT(filep && filep->f_inode && buffer);
inode = filep->f_inode;
@@ -603,10 +603,10 @@ static ssize_t spq10kbd_write(FAR struct file *filep, FAR const char *buffer,
static int spq10kbd_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
int ret;
int i;
FAR struct inode *inode;
FAR struct spq10kbd_dev_s *priv;
int ret;
int i;
DEBUGASSERT(filep && filep->f_inode && fds);
inode = filep->f_inode;
@@ -994,7 +994,7 @@ int spq10kbd_register(FAR struct i2c_master_s *i2c,
priv->waiting = false;
#ifdef CONFIG_SPQ10KBD_DJOY
priv->djoylower.config = (FAR void *)priv;
priv->djoylower.config = priv;
priv->djoylower.dl_supported = djoy_supported;
priv->djoylower.dl_sample = djoy_sample;
priv->djoylower.dl_enable = djoy_enable;
@@ -1045,6 +1045,7 @@ int spq10kbd_register(FAR struct i2c_master_s *i2c,
errout_with_priv:
nxmutex_destroy(&priv->lock);
nxsem_destroy(&priv->waitsem);
kmm_free(priv);
return ret;
}
+1
View File
@@ -1290,6 +1290,7 @@ int tsc2007_register(FAR struct i2c_master_s *dev,
errout_with_priv:
nxmutex_destroy(&priv->devlock);
nxsem_destroy(&priv->waitsem);
#ifdef CONFIG_TSC2007_MULTIPLE
kmm_free(priv);
#endif