aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-08 19:15:24 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-08 19:15:24 +0100
commite9880491796516b7e2f835a3df6f20e5da06ebf7 (patch)
treedc10120bd50d39aa092bea82c1143e5df845ee04 /src/libmdsserver
parentreplace all variants of goto pfail with fail_if (diff)
downloadmds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.gz
mds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.bz2
mds-e9880491796516b7e2f835a3df6f20e5da06ebf7.tar.xz
no more goto fail
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/client-list.c5
-rw-r--r--src/libmdsserver/linked-list.c26
-rw-r--r--src/libmdsserver/util.c5
3 files changed, 17 insertions, 19 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c
index 66fc2ae..5562747 100644
--- a/src/libmdsserver/client-list.c
+++ b/src/libmdsserver/client-list.c
@@ -104,8 +104,7 @@ int client_list_clone(const client_list_t* restrict this, client_list_t* restric
out->clients = NULL;
- if ((new_clients = malloc(n)) == NULL)
- goto fail;
+ fail_if ((new_clients = malloc(n)) == NULL);
out->clients = new_clients;
@@ -116,7 +115,7 @@ int client_list_clone(const client_list_t* restrict this, client_list_t* restric
return 0;
- fail:
+ pfail:
free(new_clients);
return -1;
}
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c
index 6c8e185..83f7711 100644
--- a/src/libmdsserver/linked-list.c
+++ b/src/libmdsserver/linked-list.c
@@ -95,10 +95,10 @@ int linked_list_create(linked_list_t* restrict this, size_t capacity)
*/
void linked_list_destroy(linked_list_t* restrict this)
{
- free(this->reusable); this->reusable = NULL;
- free(this->values); this->values = NULL;
- free(this->next); this->next = NULL;
- free(this->previous); this->previous = NULL;
+ free(this->reusable), this->reusable = NULL;
+ free(this->values), this->values = NULL;
+ free(this->next), this->next = NULL;
+ free(this->previous), this->previous = NULL;
}
@@ -122,10 +122,10 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric
out->previous = NULL;
out->reusable = NULL;
- if ((new_values = malloc(n)) == NULL) goto fail;
- if ((new_next = malloc(n)) == NULL) goto fail;
- if ((new_previous = malloc(n)) == NULL) goto fail;
- if ((new_reusable = malloc(n)) == NULL) goto fail;
+ fail_if ((new_values = malloc(n)) == NULL);
+ fail_if ((new_next = malloc(n)) == NULL);
+ fail_if ((new_previous = malloc(n)) == NULL);
+ fail_if ((new_reusable = malloc(n)) == NULL);
out->values = new_values;
out->next = new_next;
@@ -144,7 +144,7 @@ int linked_list_clone(const linked_list_t* restrict this, linked_list_t* restric
return 0;
- fail:
+ pfail:
free(new_values);
free(new_next);
free(new_previous);
@@ -191,9 +191,9 @@ int linked_list_pack(linked_list_t* restrict this)
if (cap != this->capacity)
{
- if (xmalloc(new_next, cap, ssize_t)) goto fail;
- if (xmalloc(new_previous, cap, ssize_t)) goto fail;
- if (xmalloc(new_reusable, cap, ssize_t)) goto fail;
+ fail_if (xmalloc(new_next, cap, ssize_t));
+ fail_if (xmalloc(new_previous, cap, ssize_t));
+ fail_if (xmalloc(new_reusable, cap, ssize_t));
free(this->next);
free(this->previous);
@@ -218,7 +218,7 @@ int linked_list_pack(linked_list_t* restrict this)
return 0;
- fail:
+ pfail:
free(vals);
free(new_next);
free(new_previous);
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c
index b1dff3c..70faf3d 100644
--- a/src/libmdsserver/util.c
+++ b/src/libmdsserver/util.c
@@ -360,8 +360,7 @@ pid_t uninterruptable_waitpid(pid_t pid, int* restrict status, int options)
rc = waitpid(pid, status, options);
if (rc == (pid_t)-1)
{
- if (errno != EINTR)
- goto fail;
+ fail_if (errno != EINTR);
if (have_time && (monotone(&time_intr) >= 0))
if (time_start.tv_sec != time_intr.tv_sec)
intr_count = 0;
@@ -370,7 +369,7 @@ pid_t uninterruptable_waitpid(pid_t pid, int* restrict status, int options)
/* Don't let the CPU catch fire! */
errno = EINTR;
}
- fail:
+ pfail:
return rc;
}