diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-09 13:15:10 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-09 13:15:10 +0100 |
commit | 7a994c9631c590d6a73c842fa5d2d3567b4771dd (patch) | |
tree | 228ade01f99ba217151a0ed20f29c5f3a5028619 /src/libmdsserver/client-list.c | |
parent | mds-kbdc: compile-layout: macro_call: fix bug: do not duplicate the arguments if there are none (diff) | |
parent | report an error, rather than causing failure the caller but not for the called function (diff) | |
download | mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.gz mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.bz2 mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.xz |
merge track-errors and resolve conflict
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/client-list.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c index 66fc2ae..24403cb 100644 --- a/src/libmdsserver/client-list.c +++ b/src/libmdsserver/client-list.c @@ -70,10 +70,11 @@ int client_list_create(client_list_t* restrict this, size_t capacity) this->capacity = capacity = to_power_of_two(capacity); this->size = 0; this->clients = NULL; - if (xmalloc(this->clients, capacity, uint64_t)) - return -1; + fail_if (xmalloc(this->clients, capacity, uint64_t)); return 0; + fail: + return -1; } @@ -101,11 +102,11 @@ 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; - if ((new_clients = malloc(n)) == NULL) - goto fail; + fail_if ((new_clients = malloc(n)) == NULL); out->clients = new_clients; @@ -117,8 +118,9 @@ int client_list_clone(const client_list_t* restrict this, client_list_t* restric return 0; fail: + saved_errno = errno; free(new_clients); - return -1; + return errno = saved_errno, -1; } @@ -138,12 +140,14 @@ int client_list_add(client_list_t* restrict this, uint64_t client) { this->capacity >>= 1; this->clients = old; - return -1; + fail_if (1); } } this->clients[this->size++] = client; return 0; + fail: + return -1; } @@ -229,13 +233,14 @@ int client_list_unmarshal(client_list_t* restrict this, char* restrict data) n = this->capacity * sizeof(uint64_t); - if ((this->clients = malloc(n)) == NULL) - return -1; + fail_if ((this->clients = malloc(n)) == NULL); n = this->size * sizeof(uint64_t); memcpy(this->clients, data, n); return 0; + fail: + return -1; } |