From 6b0120f6f78e103753b8fa2f0332735be2b098d5 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 2 Jan 2017 14:56:46 +0100 Subject: [PATCH] core: don't set the error number if zalloc() fails zalloc() is implemented locally and already sets the error number on failure. Signed-off-by: Bartosz Golaszewski --- core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core.c b/core.c index cc72c4d..1a4f8f5 100644 --- 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) { -- 2.30.2