console-server: Consistently use cleanup labels on error
We've already allocated the `struct console` object here, and some error
paths before and after jump to the `out_*` labels, but others just
`return EXIT_FAILURE`. Pick a consistent strategy, and also one that
aligns with useful leak analysis results.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I2e9be530823fb117bf2d013757c99d8d43e680d7
diff --git a/console-server.c b/console-server.c
index c5596dd..23f0065 100644
--- a/console-server.c
+++ b/console-server.c
@@ -702,8 +702,6 @@
struct config *config;
int rc;
- rc = -1;
-
for (;;) {
int c;
int idx;
@@ -737,6 +735,7 @@
config = config_init(config_filename);
if (!config) {
warnx("Can't read configuration, exiting.");
+ rc = -1;
goto out_free;
}
@@ -747,11 +746,13 @@
if (!config_tty_kname) {
warnx("No TTY device specified");
usage(argv[0]);
- return EXIT_FAILURE;
+ rc = -1;
+ goto out_config_fini;
}
if (set_socket_info(console, config)) {
- return EXIT_FAILURE;
+ rc = -1;
+ goto out_config_fini;
}
console->tty_kname = config_tty_kname;