diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-08 22:39:07 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-08 22:39:07 +0100 |
commit | 2064b68718ea5f15de76d661ae1f307d67a0cf26 (patch) | |
tree | 3b8f93932cb4a13ab6001f165de7714ec7e86848 /src/libmdsserver/client-list.c | |
parent | update the texinfo manual for the new use of fail_if (diff) | |
download | mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.gz mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.bz2 mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.xz |
with a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/client-list.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c index ff3ffe2..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; } @@ -139,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; } @@ -230,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; } |