[gtk/wip/baedert/for-master] glcontext-wayland: Ensure if expression evaluation order




commit 4cafe2fb44ca2c32b58aa1fe0b091957cb897109
Author: Timm Bäder <mail baedert org>
Date:   Thu Dec 24 09:03:25 2020 +0100

    glcontext-wayland: Ensure if expression evaluation order
    
    The eglChooseConfig() call is supposed to set the count variable, so we
    can't check them both in the same expression since the evaluation order
    is undefined. I think.
    
    Also some whitespace stuff.

 gdk/wayland/gdkglcontext-wayland.c | 39 ++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index a668731196..726ca25f10 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -293,27 +293,27 @@ gdk_wayland_get_display (GdkWaylandDisplay *display_wayland)
   if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base"))
     {
       PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay =
-       (void *) eglGetProcAddress ("eglGetPlatformDisplay");
+        (void *) eglGetProcAddress ("eglGetPlatformDisplay");
 
       if (getPlatformDisplay)
-       dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
-                                 display_wayland->wl_display,
-                                 NULL);
+        dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
+                                  display_wayland->wl_display,
+                                  NULL);
       if (dpy)
-       return dpy;
+        return dpy;
     }
 
   if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
     {
       PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
-       (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
+        (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
 
       if (getPlatformDisplay)
-       dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
-                                 display_wayland->wl_display,
-                                 NULL);
+        dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
+                                  display_wayland->wl_display,
+                                  NULL);
       if (dpy)
-       return dpy;
+        return dpy;
     }
 
   return eglGetDisplay ((EGLNativeDisplayType) display_wayland->wl_display);
@@ -379,12 +379,13 @@ gdk_wayland_display_init_gl (GdkDisplay *display)
 
 static gboolean
 find_eglconfig_for_surface (GdkSurface  *surface,
-                           EGLConfig  *egl_config_out,
-                           GError    **error)
+                            EGLConfig   *egl_config_out,
+                            GError     **error)
 {
   GdkDisplay *display = gdk_surface_get_display (surface);
   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
   EGLint attrs[MAX_EGL_ATTRS];
+  EGLBoolean result;
   EGLint count;
   EGLConfig *configs;
   int i = 0;
@@ -407,7 +408,8 @@ find_eglconfig_for_surface (GdkSurface  *surface,
   attrs[i++] = EGL_NONE;
   g_assert (i < MAX_EGL_ATTRS);
 
-  if (!eglChooseConfig (display_wayland->egl_display, attrs, NULL, 0, &count) || count < 1)
+  result = eglChooseConfig (display_wayland->egl_display, attrs, NULL, 0, &count);
+  if (!result || count < 1)
     {
       g_set_error_literal (error, GDK_GL_ERROR,
                            GDK_GL_ERROR_UNSUPPORTED_FORMAT,
@@ -417,7 +419,8 @@ find_eglconfig_for_surface (GdkSurface  *surface,
 
   configs = g_new (EGLConfig, count);
 
-  if (!eglChooseConfig (display_wayland->egl_display, attrs, configs, count, &count) || count < 1)
+  result = eglChooseConfig (display_wayland->egl_display, attrs, configs, count, &count);
+  if (!result || count < 1)
     {
       g_set_error_literal (error, GDK_GL_ERROR,
                            GDK_GL_ERROR_UNSUPPORTED_FORMAT,
@@ -437,7 +440,7 @@ find_eglconfig_for_surface (GdkSurface  *surface,
 
 GdkGLContext *
 gdk_wayland_surface_create_gl_context (GdkSurface     *surface,
-                                     gboolean       attached,
+                                      gboolean       attached,
                                       GdkGLContext  *share,
                                       GError       **error)
 {
@@ -526,10 +529,10 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay   *display,
   else
     {
       if (display_wayland->have_egl_surfaceless_context)
-       egl_surface = EGL_NO_SURFACE;
+        egl_surface = EGL_NO_SURFACE;
       else
-       egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface,
-                                                               context_wayland->egl_config);
+        egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface,
+                                                                 context_wayland->egl_config);
     }
 
   if (!eglMakeCurrent (display_wayland->egl_display, egl_surface,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]