Valgrind is complaining about invalid reads and writes from the two
line test cases. The culprit is the order in which the cleanup
functions are called.
Declare the chip pointers above the line handles so that we don't
free the resources associated with the chip before releasing the
lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
static void line_request_output(void)
{
+ GU_CLEANUP(gu_close_chip) struct gpiod_chip *chip = NULL;
GU_CLEANUP(gu_release_line) struct gpiod_line *line_0 = NULL;
GU_CLEANUP(gu_release_line) struct gpiod_line *line_1 = NULL;
- GU_CLEANUP(gu_close_chip) struct gpiod_chip *chip = NULL;
int status;
chip = gpiod_chip_open(gu_chip_path(0));
static void line_set_value(void)
{
- GU_CLEANUP(gu_release_line) struct gpiod_line *line = NULL;
GU_CLEANUP(gu_close_chip) struct gpiod_chip *chip = NULL;
+ GU_CLEANUP(gu_release_line) struct gpiod_line *line = NULL;
int status;
chip = gpiod_chip_open(gu_chip_path(0));