[Mesa-dev] [PATCH 3/4] egl: Refactor errors for bad EGLSync attributes
Chad Versace
chad.versace at intel.com
Fri Jul 8 22:44:20 UTC 2016
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
More information about the mesa-dev
mailing list