From 718a400d599f3df3a64c2c0659a48fb9d22b6105 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 8 Dec 2014 19:28:41 +0100 Subject: m + make sure we never lose errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/client-list.c | 4 +++- src/libmdsserver/linked-list.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/libmdsserver') diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c index 5562747..1bcaa72 100644 --- a/src/libmdsserver/client-list.c +++ b/src/libmdsserver/client-list.c @@ -101,6 +101,7 @@ int client_list_clone(const client_list_t* restrict this, client_list_t* restric { size_t n = this->capacity * sizeof(uint64_t); uint64_t* restrict new_clients = NULL; + int saved_errno; out->clients = NULL; @@ -116,8 +117,9 @@ int client_list_clone(const client_list_t* restrict this, client_list_t* restric return 0; pfail: + saved_errno = errno; free(new_clients); - return -1; + return errno = saved_errno, -1; } diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c index 83f7711..d17ba8b 100644 --- a/src/libmdsserver/linked-list.c +++ b/src/libmdsserver/linked-list.c @@ -116,6 +116,7 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric ssize_t* restrict new_next = NULL; ssize_t* restrict new_previous = NULL; ssize_t* restrict new_reusable; + int saved_errno; out->values = NULL; out->next = NULL; @@ -145,10 +146,11 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric return 0; pfail: + saved_errno = errno; free(new_values); free(new_next); free(new_previous); - return -1; + return errno = saved_errno, -1; } @@ -177,6 +179,7 @@ int linked_list_pack(linked_list_t* restrict this) size_t i = 0; ssize_t node; size_t* restrict vals; + int saved_errno; if (xmalloc(vals, cap, size_t)) return -1; @@ -219,10 +222,11 @@ int linked_list_pack(linked_list_t* restrict this) return 0; pfail: + saved_errno = errno; free(vals); free(new_next); free(new_previous); - return -1; + return errno = saved_errno, -1; } -- cgit v1.2.3-70-g09d2