diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-07 09:55:39 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-07 09:55:39 -0600 |
commit | 5f28283b77cd122d85c5228114e7d21863852b84 (patch) | |
tree | 4e145ce3171617e21b21bdbfe211b348c4a2d1b8 | |
parent | 42e65f3eb7e48fc9dae49886de9147c4e660710a (diff) | |
download | nuttx-5f28283b77cd122d85c5228114e7d21863852b84.tar.gz nuttx-5f28283b77cd122d85c5228114e7d21863852b84.tar.bz2 nuttx-5f28283b77cd122d85c5228114e7d21863852b84.zip |
maXTouch: Check for successful memory allocation was backward
-rw-r--r-- | nuttx/drivers/input/mxt.c | 6 | ||||
-rw-r--r-- | nuttx/include/nuttx/i2c.h | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/nuttx/drivers/input/mxt.c b/nuttx/drivers/input/mxt.c index 4b6d37de3..faa410a46 100644 --- a/nuttx/drivers/input/mxt.c +++ b/nuttx/drivers/input/mxt.c @@ -1498,7 +1498,7 @@ static int mxt_hwinitialize(FAR struct mxt_dev_s *priv) /* Allocate memory for the object table */ priv->objtab = kzalloc(info->nobjects * sizeof(struct mxt_object_s)); - if (priv->objtab != NULL) + if (priv->objtab == NULL) { idbg("ERROR: Failed to allocate object table\n"); return -ENOMEM; @@ -1568,7 +1568,7 @@ static int mxt_hwinitialize(FAR struct mxt_dev_s *priv) priv->sample = (FAR struct mxt_sample_s *) kzalloc(nslots * sizeof(struct mxt_sample_s)); - if (!priv->sample) + if (priv->sample == NULL) { idbg("ERROR: Failed to allocate object table\n"); goto errout_with_objtab; @@ -1632,7 +1632,7 @@ int mxt_register(FAR struct i2c_dev_s *i2c, /* Create and initialize a maXTouch device driver instance */ priv = (FAR struct mxt_dev_s *)kzalloc(sizeof(struct mxt_dev_s)); - if (!priv) + if (priv == NULL) { idbg("ERROR: Failed allocate device structure\n"); return -ENOMEM; diff --git a/nuttx/include/nuttx/i2c.h b/nuttx/include/nuttx/i2c.h index 5e3c3a107..c22329ad2 100644 --- a/nuttx/include/nuttx/i2c.h +++ b/nuttx/include/nuttx/i2c.h @@ -83,11 +83,12 @@ /* Bit definitions for the flags field in struct i2c_msg_s */ -#define I2C_M_READ 0x0001 /* read data, from slave to master */ -#define I2C_M_TEN 0x0002 /* ten bit address */ -#define I2C_M_NORESTART 0x0080 /* message should not begin with (re-)start of transfer */ +#define I2C_M_READ 0x0001 /* Read data, from slave to master */ +#define I2C_M_TEN 0x0002 /* Ten bit address */ +#define I2C_M_NORESTART 0x0080 /* Message should not begin with + * (re-)start of transfer */ -/* Access macros */ +/* Access macros ************************************************************/ /**************************************************************************** * Name: I2C_SETFREQUENCY |