[Mesa-dev] [PATCH 5/7] egl: Cleanup control flow in _eglParseSyncAttribList

Chad Versace chadversary at chromium.org
Wed Sep 28 06:28:07 UTC 2016


When the function encountered an error, it effectively returned
immediately. However, it did so indirectly by breaking out of a loop.
Replace the loop breakout with a explicit 'return'.

Do the same for _eglParseSyncAttribList64 too.
---
 src/egl/main/eglsync.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c
index f325031..6f77992 100644
--- a/src/egl/main/eglsync.c
+++ b/src/egl/main/eglsync.c
@@ -41,7 +41,7 @@
 static EGLint
 _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
 {
-   EGLint i, err = EGL_SUCCESS;
+   EGLint i;
 
    if (!attrib_list)
       return EGL_SUCCESS;
@@ -49,6 +49,7 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
    for (i = 0; attrib_list[i] != EGL_NONE; i++) {
       EGLint attr = attrib_list[i++];
       EGLint val = attrib_list[i];
+      EGLint err = EGL_SUCCESS;
 
       switch (attr) {
       default:
@@ -59,18 +60,18 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
 
       if (err != EGL_SUCCESS) {
          _eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr);
-         break;
+         return err;
       }
    }
 
-   return err;
+   return EGL_SUCCESS;
 }
 
 
 static EGLint
 _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib *attrib_list)
 {
-   EGLint i, err = EGL_SUCCESS;
+   EGLint i;
 
    if (!attrib_list)
       return EGL_SUCCESS;
@@ -78,6 +79,7 @@ _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib *attrib_list)
    for (i = 0; attrib_list[i] != EGL_NONE; i++) {
       EGLAttrib attr = attrib_list[i++];
       EGLAttrib val = attrib_list[i];
+      EGLint err = EGL_SUCCESS;
 
       switch (attr) {
       case EGL_CL_EVENT_HANDLE_KHR:
@@ -94,11 +96,11 @@ _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib *attrib_list)
 
       if (err != EGL_SUCCESS) {
          _eglLog(_EGL_DEBUG, "bad sync attribute 0x%" PRIxPTR, attr);
-         break;
+         return err;
       }
    }
 
-   return err;
+   return EGL_SUCCESS;
 }
 
 
-- 
2.10.0



More information about the mesa-dev mailing list