summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-06 09:38:15 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commitba5360ac03286364abd9fde6b500e2c0fabe56b1 (patch)
tree591d1a14ab552696b2b58bda9d6f79113d4107f9
parentdc747bcc7b70476ac14cde38e5e90a60bc057546 (diff)
main: further simplification
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--src/main.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 03aa202..1ac26f1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -154,33 +154,44 @@ int binding_init_() {
if (g_wayland != nullptr) {
AFB_ERROR("Wayland context already initialized?");
- return -1;
+ return 0;
}
if (getenv("XDG_RUNTIME_DIR") == nullptr) {
AFB_ERROR("Environment variable XDG_RUNTIME_DIR not set");
- return -1;
+ goto error;
}
g_wayland = new wayland;
if (g_wayland->init() == -1) {
AFB_ERROR("Could not connect to compositor");
- delete g_wayland;
- return -1;
+ goto error;
}
if (char const *e = init_layout()) {
AFB_ERROR("Could not init layout: %s", e);
- return -1;
+ goto error;
}
- sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
- g_wayland->display->get_fd(), EPOLLIN,
- display_event_callback, g_wayland);
+ {
+ int ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
+ g_wayland->display->get_fd(), EPOLLIN,
+ display_event_callback, g_wayland);
+ if (ret < 0) {
+ AFB_ERROR("Could not initialize wayland event handler: %s",
+ std::strerror(-ret));
+ goto error;
+ }
+ }
atexit([] { delete g_wayland; });
return 0;
+
+error:
+ delete g_wayland;
+ g_wayland = nullptr;
+ return -1;
}
int binding_init() noexcept {
@@ -248,7 +259,7 @@ void debug_status(struct afb_req req) noexcept {
}
}
-void debug_surfaces(afb_req req) {
+void debug_surfaces(afb_req req) noexcept {
CHECK_WAYLAND();
auto a = json_object_new_array();
@@ -262,7 +273,7 @@ void debug_surfaces(afb_req req) {
afb_req_success(req, a, "surfaces");
}
-void debug_layers(afb_req req) {
+void debug_layers(afb_req req) noexcept {
CHECK_WAYLAND();
auto a = json_object_new_array();