commit 5c86e38

Michael Forney  ·  2016-04-30 08:09:53 +0000 UTC
parent feb5646
Style
2 files changed,  +12, -25
+8, -16
 1@@ -320,21 +320,17 @@ static int
 2 open_tty(const char *tty_name)
 3 {
 4 	char *stdin_tty;
 5+	int fd;
 6 
 7-	/* Check if we are running on the desired VT */
 8+	/* Check if we are already running on the desired VT */
 9 	if ((stdin_tty = ttyname(STDIN_FILENO)) && strcmp(tty_name, stdin_tty) == 0)
10 		return STDIN_FILENO;
11-	else {
12-		int fd;
13 
14-		/* Open the new TTY. */
15-		fd = open(tty_name, O_RDWR | O_NOCTTY);
16+	fd = open(tty_name, O_RDWR | O_NOCTTY);
17+	if (fd < 0)
18+		die("open %s:", tty_name);
19 
20-		if (fd < 0)
21-			die("open %s:", tty_name);
22-
23-		return fd;
24-	}
25+	return fd;
26 }
27 
28 static void
29@@ -482,7 +478,6 @@ main(int argc, char *argv[])
30 
31 	child_pid = fork();
32 
33-	/* Child */
34 	if (child_pid == 0) {
35 		char string[64];
36 
37@@ -516,9 +511,7 @@ main(int argc, char *argv[])
38 
39 		execvp(argv[optind], argv + optind);
40 		die("exec %s:", argv[optind]);
41-	}
42-	/* Parent */
43-	else {
44+	} else {
45 		struct pollfd pollfd;
46 		int ret;
47 
48@@ -531,8 +524,7 @@ main(int argc, char *argv[])
49 			if (ret == -1) {
50 				if (errno == EINTR)
51 					continue;
52-				else
53-					die("poll:");
54+				die("poll:");
55 			}
56 
57 			handle_socket_data(pollfd.fd);
+4, -9
 1@@ -40,13 +40,11 @@ struct swc_launch_request {
 2 	uint32_t serial;
 3 
 4 	union {
 5-		struct /* OPEN_DEVICE */
 6-		    {
 7+		struct /* OPEN_DEVICE */ {
 8 			int flags;
 9 			char path[];
10 		};
11-		struct /* ACTIVATE_VT */
12-		    {
13+		struct /* ACTIVATE_VT */ {
14 			unsigned vt;
15 		};
16 	};
17@@ -60,8 +58,7 @@ struct swc_launch_event {
18 	} type;
19 
20 	union {
21-		struct /* RESPONSE */
22-		    {
23+		struct /* RESPONSE */ {
24 			uint32_t serial;
25 			bool success;
26 		};
27@@ -69,8 +66,6 @@ struct swc_launch_event {
28 };
29 
30 ssize_t send_fd(int socket, int fd, const void *buffer, ssize_t buffer_size);
31-
32-ssize_t receive_fd(int socket, int *fd, void *buffer,
33-                   ssize_t buffer_size);
34+ssize_t receive_fd(int socket, int *fd, void *buffer, ssize_t buffer_size);
35 
36 #endif