egl: drop an indentation level in _eglFindDisplay() by replacing break/if with a...
authorEric Engestrom <eric@engestrom.ch>
Tue, 18 Aug 2020 09:45:34 +0000 (11:45 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 22:10:06 +0000 (22:10 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6361>

src/egl/main/egldisplay.c

index d882a8f617c20097594d0ae818ca8c095ea78e1e..3df75ccd46c493660cb1f93754e508b384e9b019 100644 (file)
@@ -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: