diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:15:24 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-08 19:15:24 +0100 |
commit | e9880491796516b7e2f835a3df6f20e5da06ebf7 (patch) | |
tree | dc10120bd50d39aa092bea82c1143e5df845ee04 /src/mds-server/receiving.c | |
parent | replace all variants of goto pfail with fail_if (diff) | |
download | mds-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/mds-server/receiving.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mds-server/receiving.c b/src/mds-server/receiving.c index 15ebb4d..100d717 100644 --- a/src/mds-server/receiving.c +++ b/src/mds-server/receiving.c @@ -183,6 +183,7 @@ static int assign_and_send_id(client_t* client, const char* message_id) char* msgbuf = NULL; char* msgbuf_; size_t n; + int rc = -1; /* Construct response. */ n = 2 * 10 + strlen(message_id) + 1; @@ -204,6 +205,7 @@ static int assign_and_send_id(client_t* client, const char* message_id) /* Queue message to be sent when this function returns. This done to simplify `multicast_message` for re-exec and termination. */ +#define pfail fail_in_mutex with_mutex (client->mutex, if (client->send_pending_size == 0) { @@ -216,20 +218,20 @@ static int assign_and_send_id(client_t* client, const char* message_id) /* Concatenate message to already pending messages. */ size_t new_len = client->send_pending_size + n; char* msg_new = client->send_pending; - if (xrealloc(msg_new, new_len, char)) - goto fail; + fail_if (xrealloc(msg_new, new_len, char)); memcpy(msg_new + client->send_pending_size, msgbuf, n * sizeof(char)); client->send_pending = msg_new; client->send_pending_size = new_len; } - fail: + (msgbuf = NULL, rc = 0, errno = 0); + fail_in_mutex: ); +#undef pfail - return 0; - - pfail: + pfail: /* Also success. */ + xperror(*argv); free(msgbuf); - return -1; + return rc; } |