Mesa (master): egl: drop an indentation level in _eglFindDisplay() by replacing break/if with a goto

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 19 22:29:41 UTC 2020


Module: Mesa
Branch: master
Commit: 8b2fc1d1b5a822692321af1a2a01dddbc9cff356
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b2fc1d1b5a822692321af1a2a01dddbc9cff356

Author: Eric Engestrom <eric at engestrom.ch>
Date:   Tue Aug 18 11:45:34 2020 +0200

egl: drop an indentation level in _eglFindDisplay() by replacing break/if with a goto

Signed-off-by: Eric Engestrom <eric at engestrom.ch>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6361>

---

 src/egl/main/egldisplay.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index d882a8f617c..3df75ccd46c 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -255,31 +255,30 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy,
    for (disp = _eglGlobal.DisplayList; disp; disp = disp->Next) {
       if (disp->Platform == plat && disp->PlatformDisplay == plat_dpy &&
           _eglSameAttribs(disp->Options.Attribs, attrib_list))
-         break;
+         goto out;
    }
 
    /* create a new display */
-   if (!disp) {
-      disp = calloc(1, sizeof(_EGLDisplay));
-      if (disp) {
-         mtx_init(&disp->Mutex, mtx_plain);
-         disp->Platform = plat;
-         disp->PlatformDisplay = plat_dpy;
-         num_attribs = _eglNumAttribs(attrib_list);
-         if (num_attribs) {
-            disp->Options.Attribs = calloc(num_attribs, sizeof(EGLAttrib));
-            if (!disp->Options.Attribs) {
-               free(disp);
-               disp = NULL;
-               goto out;
-            }
-            memcpy(disp->Options.Attribs, attrib_list,
-                   num_attribs * sizeof(EGLAttrib));
+   assert(!disp);
+   disp = calloc(1, sizeof(_EGLDisplay));
+   if (disp) {
+      mtx_init(&disp->Mutex, mtx_plain);
+      disp->Platform = plat;
+      disp->PlatformDisplay = plat_dpy;
+      num_attribs = _eglNumAttribs(attrib_list);
+      if (num_attribs) {
+         disp->Options.Attribs = calloc(num_attribs, sizeof(EGLAttrib));
+         if (!disp->Options.Attribs) {
+            free(disp);
+            disp = NULL;
+            goto out;
          }
-         /* add to the display list */
-         disp->Next = _eglGlobal.DisplayList;
-         _eglGlobal.DisplayList = disp;
+         memcpy(disp->Options.Attribs, attrib_list,
+                num_attribs * sizeof(EGLAttrib));
       }
+      /* add to the display list */
+      disp->Next = _eglGlobal.DisplayList;
+      _eglGlobal.DisplayList = disp;
    }
 
 out:



More information about the mesa-commit mailing list