aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/client-list.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-08 22:39:07 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-08 22:39:07 +0100
commit2064b68718ea5f15de76d661ae1f307d67a0cf26 (patch)
tree3b8f93932cb4a13ab6001f165de7714ec7e86848 /src/libmdsserver/client-list.c
parentupdate the texinfo manual for the new use of fail_if (diff)
downloadmds-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.c14
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;
}