aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmdsserver')
-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;
}