aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mds-clipboard.c6
-rw-r--r--src/mds-echo.c4
-rw-r--r--src/mds-kbdc/raw-data.c4
-rw-r--r--src/mds-kkbd.c7
-rw-r--r--src/mds-registry/mds-registry.c4
-rw-r--r--src/mds-registry/registry.c10
-rw-r--r--src/mds-respawn.c3
-rw-r--r--src/mds-server/mds-server.c4
-rw-r--r--src/mds-vt.c11
-rw-r--r--src/mds.c25
10 files changed, 33 insertions, 45 deletions
diff --git a/src/mds-clipboard.c b/src/mds-clipboard.c
index 1d4de37..09cb599 100644
--- a/src/mds-clipboard.c
+++ b/src/mds-clipboard.c
@@ -361,8 +361,8 @@ int master_loop(void)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost connection to server.");
mds_message_destroy(&received);
@@ -854,7 +854,7 @@ int clipboard_set_size(int level, size_t size)
if (xrealloc(clipboard[level], size, clipitem_t))
{
clipboard[level] = old;
- goto pfail;
+ fail_if (1);
}
clipboard_size[level] = size;
}
diff --git a/src/mds-echo.c b/src/mds-echo.c
index 31e8b86..e7fc4d4 100644
--- a/src/mds-echo.c
+++ b/src/mds-echo.c
@@ -233,8 +233,8 @@ int master_loop(void)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost connection to server.");
mds_message_destroy(&received);
diff --git a/src/mds-kbdc/raw-data.c b/src/mds-kbdc/raw-data.c
index 4a6a6ba..c47269a 100644
--- a/src/mds-kbdc/raw-data.c
+++ b/src/mds-kbdc/raw-data.c
@@ -130,8 +130,8 @@ static char* read_file(const char* restrict pathname, size_t* restrict size)
/* Read a chunk of the file. */
got = read(fd, content + buf_ptr, (buf_size - buf_ptr) * sizeof(char));
if ((got < 0) && (errno == EINTR)) continue;
- else if (got < 0) goto pfail;
- else if (got == 0) break;
+ if (got == 0) break;
+ fail_if (got < 0);
buf_ptr += (size_t)got;
}
diff --git a/src/mds-kkbd.c b/src/mds-kkbd.c
index 73dbc8a..32ae6db 100644
--- a/src/mds-kkbd.c
+++ b/src/mds-kkbd.c
@@ -441,8 +441,8 @@ int master_loop(void)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost connection to server.");
mds_message_destroy(&received);
@@ -487,8 +487,7 @@ void* keyboard_loop(void* data)
while (!reexecing && !terminating)
if (fetch_keys() < 0)
- if (errno != EINTR)
- goto pfail;
+ fail_if (errno != EINTR);
return NULL;
diff --git a/src/mds-registry/mds-registry.c b/src/mds-registry/mds-registry.c
index 741423c..8b2a3e5 100644
--- a/src/mds-registry/mds-registry.c
+++ b/src/mds-registry/mds-registry.c
@@ -175,8 +175,8 @@ int master_loop(void)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost connection to server.");
mds_message_destroy(&received);
diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c
index 2d0643f..89f1d80 100644
--- a/src/mds-registry/registry.c
+++ b/src/mds-registry/registry.c
@@ -132,8 +132,7 @@ static int registry_action_add(int has_key, char* command, size_t command_key, u
/* Add server to protocol if the protocol is already in the table. */
size_t address = hash_table_get(&reg_table, command_key);
client_list_t* list = (client_list_t*)(void*)address;
- if (client_list_add(list, client) < 0)
- goto pfail;
+ fail_if (client_list_add(list, client) < 0);
}
else
{
@@ -142,13 +141,12 @@ static int registry_action_add(int has_key, char* command, size_t command_key, u
/* Allocate list of servers for the protocol. */
client_list_t* list = malloc(sizeof(client_list_t));
void* address = list;
- if (list == NULL)
- goto pfail;
+ fail_if (list == NULL);
/* Duplicate the protocol name so it can be accessed later. */
if ((command = strdup(command)) == NULL)
{
free(list);
- goto pfail;
+ fail_if (1);
}
/* Create list of servers, add server to list and add the protocol to the table. */
command_key = (size_t)(void*)command;
@@ -159,7 +157,7 @@ static int registry_action_add(int has_key, char* command, size_t command_key, u
client_list_destroy(list);
free(list);
free(command);
- goto pfail;
+ fail_if (1);
}
}
diff --git a/src/mds-respawn.c b/src/mds-respawn.c
index bcbb7fe..3e3406a 100644
--- a/src/mds-respawn.c
+++ b/src/mds-respawn.c
@@ -292,8 +292,7 @@ int postinitialise_server(void)
if (commands_args[i] == NULL)
j++;
else if (strequals(commands_args[i], "--initial-spawn"))
- if ((commands_args[i] = strdup("--respawn")) == NULL)
- goto pfail;
+ fail_if ((commands_args[i] = strdup("--respawn")) == NULL);
/* Respawn dead and dead and buried servers.*/
diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c
index 58eec60..f058396 100644
--- a/src/mds-server/mds-server.c
+++ b/src/mds-server/mds-server.c
@@ -435,14 +435,14 @@ void queue_message_multicast(char* message, size_t length, client_t* sender)
if ((header_values[i] = strdup(msg)) == NULL)
{
header_count = i;
- goto pfail;
+ fail_if (1);
}
*colon = '\0';
if ((headers[i] = strdup(msg)) == NULL)
{
free(headers[i]);
header_count = i;
- goto pfail;
+ fail_if (1);
}
*colon = ':';
*end = '\n';
diff --git a/src/mds-vt.c b/src/mds-vt.c
index c0a13ef..0aae0c2 100644
--- a/src/mds-vt.c
+++ b/src/mds-vt.c
@@ -247,8 +247,7 @@ int initialise_server(void)
if (is_respawn == 0)
{
display_vt = select_vt();
- if (display_vt < 0)
- goto pfail;
+ fail_if (display_vt < 0);
display_tty_fd = vt_open(display_vt, &old_vt_stat);
fail_if (write_vt_file() < 0);
fail_if (vt_set_active(display_vt) < 0);
@@ -434,8 +433,8 @@ int master_loop(void)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost primary connection to server.");
mds_message_destroy(&received);
@@ -494,8 +493,8 @@ void* secondary_loop(void* data)
}
else if (errno == EINTR)
continue;
- else if (errno != ECONNRESET)
- goto pfail;
+ else
+ fail_if (errno != ECONNRESET);
eprint("lost secondary connection to server.");
mds_message_destroy(&secondary_received);
diff --git a/src/mds.c b/src/mds.c
index 6d8707a..c940175 100644
--- a/src/mds.c
+++ b/src/mds.c
@@ -336,8 +336,7 @@ int spawn_and_respawn_server(int fd)
respawn:
pid = fork();
- if (pid == (pid_t)-1)
- goto pfail;
+ fail_if (pid == (pid_t)-1);
if (pid == 0) /* Child. */
{
@@ -347,7 +346,7 @@ int spawn_and_respawn_server(int fd)
umask(saved_umask);
/* Change image into the master server. */
exec_master_server(child_args);
- goto pfail;
+ fail_if (1);
}
@@ -358,8 +357,7 @@ int spawn_and_respawn_server(int fd)
xperror(*argv);
/* Wait for master server to die. */
- if (uninterruptable_waitpid(pid, &status, 0) == (pid_t)-1)
- goto pfail;
+ fail_if (uninterruptable_waitpid(pid, &status, 0) == (pid_t)-1);
/* If the server exited normally or SIGTERM, do not respawn. */
if (WIFEXITED(status) ? (WEXITSTATUS(status) == 0) :
@@ -396,8 +394,7 @@ int spawn_and_respawn_server(int fd)
first_spawn = 0;
free(child_args[argc + 0]);
child_args[argc + 0] = strdup("--respawn");
- if (child_args[argc + 0] == NULL)
- goto pfail;
+ fail_if (child_args[argc + 0] == NULL);
}
goto respawn;
@@ -443,14 +440,12 @@ int create_directory_root(const char* pathname)
/* Directory is missing, create it. */
if (mkdir(pathname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0)
{
- if (errno != EEXIST) /* Unlikely race condition. */
- goto pfail;
+ fail_if (errno != EEXIST); /* Unlikely race condition. */
}
else
{
/* Set ownership. */
- if (chown(pathname, ROOT_USER_UID, ROOT_GROUP_GID) < 0)
- goto pfail;
+ fail_if (chown(pathname, ROOT_USER_UID, ROOT_GROUP_GID) < 0);
}
return 0;
@@ -525,7 +520,7 @@ int unlink_recursive(const char* pathname)
if (stat(pathname, &_attr) < 0)
return 0; /* Directory does not exist. */
errno = errno_;
- goto pfail;
+ fail_if (1);
}
/* Remove the content of the directory. */
@@ -534,14 +529,12 @@ int unlink_recursive(const char* pathname)
strcmp(file->d_name, "..") &&
(unlink(file->d_name) < 0))
{
- if (errno != EISDIR)
- goto pfail;
+ fail_if (errno != EISDIR);
unlink_recursive(file->d_name);
}
/* Remove the drectory. */
- if (rmdir(pathname) < 0)
- goto pfail;
+ fail_if (rmdir(pathname) < 0);
done:
if (dir != NULL)