Mesa (master): egl/dri2: remove error checks on return values from mtx_lock and cnd_wait

Emil Velikov evelikov at kemper.freedesktop.org
Tue Aug 23 11:14:52 UTC 2016


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

Author: Dongwon Kim <dongwon.kim at intel.com>
Date:   Mon Aug 15 15:12:03 2016 -0700

egl/dri2: remove error checks on return values from mtx_lock and cnd_wait

This removes unnecessary error checks on return result of mtx_lock
and cnd_wait calls as in all other places in MESA source since there
is no chance that any of these functions return any of error codes
in current implementation.

This patch also removes a redundent _eglError call that follows
EGL_FALSE check in the bottom of dri2_client_wait_sync.

Signed-off-by: Dongwon Kim <dongwon.kim at intel.com>
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

---

 src/egl/drivers/dri2/egl_dri2.c | 47 +++++++++++------------------------------
 1 file changed, 12 insertions(+), 35 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 3e3d1c8..ac5ecbb 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2666,19 +2666,9 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
 
       /* if timeout is EGL_FOREVER_KHR, it should wait without any timeout.*/
       if (timeout == EGL_FOREVER_KHR) {
-         if (mtx_lock(&dri2_sync->mutex)) {
-            ret = EGL_FALSE;
-            goto cleanup;
-         }
-
-         ret = cnd_wait(&dri2_sync->cond, &dri2_sync->mutex);
-
+         mtx_lock(&dri2_sync->mutex);
+         cnd_wait(&dri2_sync->cond, &dri2_sync->mutex);
          mtx_unlock(&dri2_sync->mutex);
-
-         if (ret) {
-            _eglError(EGL_BAD_PARAMETER, "eglClientWaitSyncKHR");
-            ret = EGL_FALSE;
-         }
       } else {
          /* if reusable sync has not been yet signaled */
          if (dri2_sync->base.SyncStatus != EGL_SIGNALED_KHR) {
@@ -2697,38 +2687,25 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
                expire.nsec -= 1000000000L;
             }
 
-            if (mtx_lock(&dri2_sync->mutex)) {
-               ret = EGL_FALSE;
-               goto cleanup;
-            }
-
+            mtx_lock(&dri2_sync->mutex);
             ret = cnd_timedwait(&dri2_sync->cond, &dri2_sync->mutex, &expire);
-
             mtx_unlock(&dri2_sync->mutex);
 
-            if (ret)
-               if (ret == thrd_busy) {
-                  if (dri2_sync->base.SyncStatus == EGL_UNSIGNALED_KHR) {
-                     ret = EGL_TIMEOUT_EXPIRED_KHR;
-                  } else {
-                     _eglError(EGL_BAD_ACCESS, "eglClientWaitSyncKHR");
-                     ret = EGL_FALSE;
-                  }
+            if (ret == thrd_busy) {
+               if (dri2_sync->base.SyncStatus == EGL_UNSIGNALED_KHR) {
+                  ret = EGL_TIMEOUT_EXPIRED_KHR;
+               } else {
+                  _eglError(EGL_BAD_ACCESS, "eglClientWaitSyncKHR");
+                  ret = EGL_FALSE;
                }
+            }
          }
       }
       break;
   }
+  dri2_egl_unref_sync(dri2_dpy, dri2_sync);
 
- cleanup:
-   dri2_egl_unref_sync(dri2_dpy, dri2_sync);
-
-   if (ret == EGL_FALSE) {
-      _eglError(EGL_BAD_ACCESS, "eglClientWaitSyncKHR");
-      return EGL_FALSE;
-   }
-
-   return ret;
+  return ret;
 }
 
 static EGLBoolean




More information about the mesa-commit mailing list