commit 5c86e38d23d8c53c09e508b867afc2701d6d851b
parent feb56461038ebfe075e60d0a22b695dad07e72a8
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 30 Apr 2016 01:09:53 -0700
Style
Diffstat:
2 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/launch/launch.c b/launch/launch.c
@@ -320,21 +320,17 @@ static int
open_tty(const char *tty_name)
{
char *stdin_tty;
+ int fd;
- /* Check if we are running on the desired VT */
+ /* Check if we are already running on the desired VT */
if ((stdin_tty = ttyname(STDIN_FILENO)) && strcmp(tty_name, stdin_tty) == 0)
return STDIN_FILENO;
- else {
- int fd;
- /* Open the new TTY. */
- fd = open(tty_name, O_RDWR | O_NOCTTY);
+ fd = open(tty_name, O_RDWR | O_NOCTTY);
+ if (fd < 0)
+ die("open %s:", tty_name);
- if (fd < 0)
- die("open %s:", tty_name);
-
- return fd;
- }
+ return fd;
}
static void
@@ -482,7 +478,6 @@ main(int argc, char *argv[])
child_pid = fork();
- /* Child */
if (child_pid == 0) {
char string[64];
@@ -516,9 +511,7 @@ main(int argc, char *argv[])
execvp(argv[optind], argv + optind);
die("exec %s:", argv[optind]);
- }
- /* Parent */
- else {
+ } else {
struct pollfd pollfd;
int ret;
@@ -531,8 +524,7 @@ main(int argc, char *argv[])
if (ret == -1) {
if (errno == EINTR)
continue;
- else
- die("poll:");
+ die("poll:");
}
handle_socket_data(pollfd.fd);
diff --git a/launch/protocol.h b/launch/protocol.h
@@ -40,13 +40,11 @@ struct swc_launch_request {
uint32_t serial;
union {
- struct /* OPEN_DEVICE */
- {
+ struct /* OPEN_DEVICE */ {
int flags;
char path[];
};
- struct /* ACTIVATE_VT */
- {
+ struct /* ACTIVATE_VT */ {
unsigned vt;
};
};
@@ -60,8 +58,7 @@ struct swc_launch_event {
} type;
union {
- struct /* RESPONSE */
- {
+ struct /* RESPONSE */ {
uint32_t serial;
bool success;
};
@@ -69,8 +66,6 @@ struct swc_launch_event {
};
ssize_t send_fd(int socket, int fd, const void *buffer, ssize_t buffer_size);
-
-ssize_t receive_fd(int socket, int *fd, void *buffer,
- ssize_t buffer_size);
+ssize_t receive_fd(int socket, int *fd, void *buffer, ssize_t buffer_size);
#endif