core: don't set the error number if zalloc() fails
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 13:56:46 +0000 (14:56 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 2 Jan 2017 13:56:46 +0000 (14:56 +0100)
zalloc() is implemented locally and already sets the error number on
failure.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c

diff --git a/core.c b/core.c
index cc72c4de6ff16add640c2c06c6c7b6e9f0908884..1a4f8f58fb84e053495763dc09287e7228746443 100644 (file)
--- a/core.c
+++ b/core.c
@@ -310,7 +310,6 @@ struct gpiod_chip * gpiod_chip_open(const char *path)
        chip = zalloc(sizeof(*chip));
        if (!chip) {
                close(fd);
-               set_last_error(ENOMEM);
                return NULL;
        }
 
@@ -327,7 +326,6 @@ struct gpiod_chip * gpiod_chip_open(const char *path)
        if (!chip->lines) {
                close(chip->fd);
                free(chip);
-               set_last_error(ENOMEM);
                return NULL;
        }
 
@@ -456,10 +454,8 @@ struct gpiod_chip_iter * gpiod_chip_iter_new(void)
        struct gpiod_chip_iter *new;
 
        new = zalloc(sizeof(*new));
-       if (!new) {
-               set_last_error(ENOMEM);
+       if (!new)
                return NULL;
-       }
 
        new->dir = opendir(dev_dir);
        if (!new->dir) {