Move the error handling into a little helper function. This will keep
the code clean when later adding error handling for attribute
EGL_SYNC_NATIVE_FENCE_FD_ANDROID.

And fix the log message to work when EGLAttrib is 32-bit or 64-bit.
---
 src/egl/main/eglsync.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c
index 48714d1..e90aeb4 100644
--- a/src/egl/main/eglsync.c
+++ b/src/egl/main/eglsync.c
@@ -67,11 +67,18 @@ _eglParseSyncAttribList(_EGLSync *sync, const EGLint 
*attrib_list)
 }
 
 
+static EGLint
+badSyncAttrib(EGLAttrib attr)
+{
+   _eglLog(_EGL_DEBUG, "bad sync attribute 0x0*%" PRIxPTR,
+           2 * sizeof(attr), attr);
+   return EGL_BAD_ATTRIBUTE;
+}
+
+
 static EGLint
 _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib *attrib_list)
 {
-   EGLint err = EGL_SUCCESS;
-
    if (!attrib_list)
       return EGL_SUCCESS;
 
@@ -81,24 +88,16 @@ _eglParseSyncAttribList64(_EGLSync *sync, const EGLAttrib 
*attrib_list)
 
       switch (attr) {
       case EGL_CL_EVENT_HANDLE_KHR:
-         if (sync->Type == EGL_SYNC_CL_EVENT_KHR) {
-            sync->CLEvent = val;
-            break;
-         }
-         /* fall through */
-      default:
-         (void) val;
-         err = EGL_BAD_ATTRIBUTE;
+         if (sync->Type != EGL_SYNC_CL_EVENT_KHR)
+            return badSyncAttrib(attr);
+         sync->CLEvent = val;
          break;
-      }
-
-      if (err != EGL_SUCCESS) {
-         _eglLog(_EGL_DEBUG, "bad sync attribute 0x%" PRIxPTR, attr);
-         return err;
+      default:
+         return badSyncAttrib(attr);
       }
    }
 
-   return err;
+   return EGL_SUCCESS;
 }
 
 
-- 
2.9.0.rc2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to