From: Emil Velikov <emil.veli...@collabora.com>

Drop the goto label and bail directly from the macro. The current
strange construct has gotten us once, so we might as well try to avoid
it for the future.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/egl/wegl_platform.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index a59b070..350e6a1 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -56,15 +56,14 @@ wegl_platform_teardown(struct wegl_platform *self)
 bool
 wegl_platform_init(struct wegl_platform *self)
 {
-    bool ok = true;
-
+    // On failure the caller of wegl_platform_init will trigger it's own
+    // destruction which will execute wegl_platform_teardown.
     self->eglHandle = dlopen(libEGL_filename, RTLD_LAZY | RTLD_LOCAL);
     if (!self->eglHandle) {
         wcore_errorf(WAFFLE_ERROR_FATAL,
                      "dlopen(\"%s\") failed: %s",
                      libEGL_filename, dlerror());
-        ok = false;
-        goto error;
+        return false;
     }
 
 #define OPTIONAL_EGL_SYMBOL(function)                                  \
@@ -73,11 +72,10 @@ wegl_platform_init(struct wegl_platform *self)
 #define RETRIEVE_EGL_SYMBOL(function)                                  \
     OPTIONAL_EGL_SYMBOL(function)                                      \
     if (!self->function) {                                             \
-        wcore_errorf(WAFFLE_ERROR_FATAL,                             \
+        wcore_errorf(WAFFLE_ERROR_FATAL,                               \
                      "dlsym(\"%s\", \"" #function "\") failed: %s",    \
                      libEGL_filename, dlerror());                      \
-        ok = false;                                                    \
-        goto error;                                                    \
+        return false;                                                  \
     }
 
     OPTIONAL_EGL_SYMBOL(eglCreateImageKHR);
@@ -110,8 +108,5 @@ wegl_platform_init(struct wegl_platform *self)
 #undef OPTIONAL_EGL_SYMBOL
 #undef RETRIEVE_EGL_SYMBOL
 
-error:
-    // On failure the caller of wegl_platform_init will trigger it's own
-    // destruction which will execute wegl_platform_teardown.
-    return ok;
+    return true;
 }
-- 
2.6.2

_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to