mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
lcm1602: fix potential reference of uninitialized memory
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
654c3be71e
commit
bfe64789b6
@ -55,6 +55,8 @@ lcm1602_context lcm1602_i2c_init(int bus, int address, bool is_expander,
|
|||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
memset((void *)dev, 0, sizeof(struct _lcm1602_context));
|
||||||
|
|
||||||
// make sure MRAA is initialized
|
// make sure MRAA is initialized
|
||||||
int mraa_rv;
|
int mraa_rv;
|
||||||
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
|
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
|
||||||
@ -64,8 +66,6 @@ lcm1602_context lcm1602_i2c_init(int bus, int address, bool is_expander,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset((void *)dev, 0, sizeof(struct _lcm1602_context));
|
|
||||||
|
|
||||||
// initialize the MRAA context
|
// initialize the MRAA context
|
||||||
|
|
||||||
if (!(dev->i2c = mraa_i2c_init(bus)))
|
if (!(dev->i2c = mraa_i2c_init(bus)))
|
||||||
@ -146,6 +146,8 @@ lcm1602_context lcm1602_gpio_init(uint8_t rs, uint8_t enable,
|
|||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
memset((void *)dev, 0, sizeof(struct _lcm1602_context));
|
||||||
|
|
||||||
// make sure MRAA is initialized
|
// make sure MRAA is initialized
|
||||||
int mraa_rv;
|
int mraa_rv;
|
||||||
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
|
if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
|
||||||
@ -155,8 +157,6 @@ lcm1602_context lcm1602_gpio_init(uint8_t rs, uint8_t enable,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset((void *)dev, 0, sizeof(struct _lcm1602_context));
|
|
||||||
|
|
||||||
// initialize the MRAA contexts
|
// initialize the MRAA contexts
|
||||||
|
|
||||||
if (!(dev->gpioRS = mraa_gpio_init(rs)))
|
if (!(dev->gpioRS = mraa_gpio_init(rs)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user