aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-registry/mds-registry.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/mds-registry/mds-registry.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/mds-registry/mds-registry.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/mds-registry/mds-registry.c b/src/mds-registry/mds-registry.c
index 44cbe86..4b49525 100644
--- a/src/mds-registry/mds-registry.c
+++ b/src/mds-registry/mds-registry.c
@@ -82,6 +82,7 @@ int preinitialise_server(void)
*/
int initialise_server(void)
{
+ int stage = 0;
const char* const message =
"Command: intercept\n"
"Message ID: 0\n"
@@ -103,14 +104,8 @@ int initialise_server(void)
that happen between the crash and the recovery.
*/
- if (full_send(message, strlen(message)))
- return 1;
- if (hash_table_create_tuned(&reg_table, 32))
- {
- xperror(*argv);
- hash_table_destroy(&reg_table, NULL, NULL);
- return 1;
- }
+ fail_if (full_send(message, strlen(message))); stage++;
+ fail_if (hash_table_create_tuned(&reg_table, 32)); stage++;
reg_table.key_comparator = (compare_func*)string_comparator;
reg_table.hasher = (hash_func*)string_hash;
fail_if (server_initialised() < 0);
@@ -119,7 +114,10 @@ int initialise_server(void)
return 0;
fail:
xperror(*argv);
- mds_message_destroy(&received);
+ if (stage == 1)
+ hash_table_destroy(&reg_table, NULL, NULL);
+ if (stage == 2)
+ mds_message_destroy(&received);
return 1;
}
@@ -135,13 +133,12 @@ int postinitialise_server(void)
if (connected)
return 0;
- if (reconnect_to_display())
- {
- mds_message_destroy(&received);
- return 1;
- }
+ fail_if (reconnect_to_display());
connected = 1;
return 0;
+ fail:
+ mds_message_destroy(&received);
+ return 1;
}