From: Bartosz Golaszewski Date: Thu, 13 Feb 2020 14:13:42 +0000 (+0100) Subject: core: reuse the err_close_fd label in gpiod_chip_open() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=866bd1ef85a3ed09dc73826521cc16493285ec12;p=qemu-gpiodev%2Flibgpiod.git core: reuse the err_close_fd label in gpiod_chip_open() Remove redundant resource cleanup in error path after is_gpiochip_cdev() and reuse the already existing label. Signed-off-by: Bartosz Golaszewski --- diff --git a/lib/core.c b/lib/core.c index ed63012..f704b44 100644 --- a/lib/core.c +++ b/lib/core.c @@ -179,10 +179,8 @@ struct gpiod_chip *gpiod_chip_open(const char *path) * We were able to open the file but is it really a gpiochip character * device? */ - if (!is_gpiochip_cdev(path)) { - close(fd); - return NULL; - } + if (!is_gpiochip_cdev(path)) + goto err_close_fd; chip = malloc(sizeof(*chip)); if (!chip)