diff options
Diffstat (limited to '')
-rw-r--r-- | src/mds-registry/mds-registry.c | 9 | ||||
-rw-r--r-- | src/mds-registry/registry.c | 4 | ||||
-rw-r--r-- | src/mds-registry/slave.c | 15 |
3 files changed, 12 insertions, 16 deletions
diff --git a/src/mds-registry/mds-registry.c b/src/mds-registry/mds-registry.c index 8b2a3e5..9751ff4 100644 --- a/src/mds-registry/mds-registry.c +++ b/src/mds-registry/mds-registry.c @@ -171,7 +171,7 @@ int master_loop(void) if (r == -2) { eprint("corrupt message received, aborting."); - goto fail; + goto done; } else if (errno == EINTR) continue; @@ -182,16 +182,15 @@ int master_loop(void) mds_message_destroy(&received); mds_message_initialise(&received); connected = 0; - if (reconnect_to_display()) - goto fail; + fail_if (reconnect_to_display()); connected = 1; } rc = 0; - goto fail; + goto done; pfail: xperror(*argv); - fail: + done: /* Join with all slaves threads. */ with_mutex (slave_mutex, while (running_slaves > 0) diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c index 8b1c126..b8a24ac 100644 --- a/src/mds-registry/registry.c +++ b/src/mds-registry/registry.c @@ -74,8 +74,7 @@ static int handle_close_message(void) /* If no servers support the protocol, list the protocol for removal. */ fail_if ((keys == NULL) && xmalloc(keys, size, size_t)); - if (ptr == size ? growalloc(old_keys, keys, size, size_t) : 0) - goto fail; + fail_if (ptr == size ? growalloc(old_keys, keys, size, size_t) : 0); keys[ptr++] = entry->key; } @@ -110,7 +109,6 @@ static int handle_close_message(void) return 0; pfail: xperror(*argv); - fail: free(keys); return -1; } diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index 9999aa0..8e29f17 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -272,22 +272,18 @@ slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv { slave_t* restrict rc = NULL; - if (xmalloc(rc, 1, slave_t)) - return NULL; + fail_if (xmalloc(rc, 1, slave_t)); slave_initialise(rc); rc->wait_set = wait_set; rc->client = parse_client_id(recv_client_id); - if ((rc->client_id = strdup(recv_client_id)) == NULL) - goto fail; - - if ((rc->message_id = strdup(recv_message_id)) == NULL) - goto fail; + fail_if ((rc->client_id = strdup(recv_client_id)) == NULL); + fail_if ((rc->message_id = strdup(recv_message_id)) == NULL); return rc; - fail: + pfail: slave_destroy(rc); free(rc); return NULL; @@ -318,6 +314,9 @@ void slave_initialise(slave_t* restrict this) */ void slave_destroy(slave_t* restrict this) { + if (this == NULL) + return; + if (this->wait_set != NULL) { hash_table_destroy(this->wait_set, (free_func*)reg_table_free_key, NULL); |