compositor: fix return code from main()

There were a few cases of 'goto out' in main() that did not set ret to
EXIT_FAILURE. Shell failing to init is the one I hit when writing tests
for ivi-shell.

Rather than adding a few more 'ret = EXIT_FAILURE', make that the
default and remove the redundant assignments. When Weston exits
properly ec->exit_code will take care of the exit code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
dev
Pekka Paalanen 10 years ago
parent 8fd4de458e
commit 111c6f9bb7
  1. 17
      src/compositor.c

@ -5213,7 +5213,7 @@ weston_transform_to_string(uint32_t output_transform)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret = EXIT_SUCCESS; int ret = EXIT_FAILURE;
struct wl_display *display; struct wl_display *display;
struct weston_compositor *ec; struct weston_compositor *ec;
struct wl_event_source *signals[4]; struct wl_event_source *signals[4];
@ -5289,10 +5289,8 @@ int main(int argc, char *argv[])
signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler, signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
NULL); NULL);
if (!signals[0] || !signals[1] || !signals[2] || !signals[3]) { if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
ret = EXIT_FAILURE;
goto out_signals; goto out_signals;
}
if (noconfig == 0) if (noconfig == 0)
config = weston_config_parse("weston.ini"); config = weston_config_parse("weston.ini");
@ -5312,15 +5310,12 @@ int main(int argc, char *argv[])
} }
backend_init = weston_load_module(backend, "backend_init"); backend_init = weston_load_module(backend, "backend_init");
if (!backend_init) { if (!backend_init)
ret = EXIT_FAILURE;
goto out_signals; goto out_signals;
}
ec = backend_init(display, &argc, argv, config); ec = backend_init(display, &argc, argv, config);
if (ec == NULL) { if (ec == NULL) {
weston_log("fatal: failed to create compositor\n"); weston_log("fatal: failed to create compositor\n");
ret = EXIT_FAILURE;
goto out_signals; goto out_signals;
} }
@ -5337,10 +5332,8 @@ int main(int argc, char *argv[])
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
weston_log("fatal: unhandled option: %s\n", argv[i]); weston_log("fatal: unhandled option: %s\n", argv[i]);
if (argc > 1) { if (argc > 1)
ret = EXIT_FAILURE;
goto out; goto out;
}
weston_compositor_log_capabilities(ec); weston_compositor_log_capabilities(ec);
@ -5358,7 +5351,6 @@ int main(int argc, char *argv[])
primary_client = wl_client_create(display, fd); primary_client = wl_client_create(display, fd);
if (!primary_client) { if (!primary_client) {
weston_log("fatal: failed to add client: %m\n"); weston_log("fatal: failed to add client: %m\n");
ret = EXIT_FAILURE;
goto out; goto out;
} }
primary_client_destroyed.notify = primary_client_destroyed.notify =
@ -5366,7 +5358,6 @@ int main(int argc, char *argv[])
wl_client_add_destroy_listener(primary_client, wl_client_add_destroy_listener(primary_client,
&primary_client_destroyed); &primary_client_destroyed);
} else if (weston_create_listening_socket(display, socket_name)) { } else if (weston_create_listening_socket(display, socket_name)) {
ret = EXIT_FAILURE;
goto out; goto out;
} }

Loading…
Cancel
Save