aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2017-06-20 15:40:28 +0100
committerEmil Velikov <[email protected]>2017-06-26 12:41:00 +0100
commitc58af5cbb295760687b23428f8ac240459e5cf56 (patch)
tree0bf1c53aedde3010b4254c12531c6249e85d13ca /src/egl/drivers/dri2
parentd42b09580a5270e8906dad4b923f320d1de18167 (diff)
egl: fold _eglError() + return EGL_FALSE
The function _eglError() already explicitly returns EGL_FALSE, explicitly to simplify the callers. Make use of it. While EGL_FALSE is numerically identical to false, NULL, EGL_NO_FOO, storage is not the same so we cannot use it for "everything". Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl/drivers/dri2')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c72
-rw-r--r--src/egl/drivers/dri2/platform_android.c6
-rw-r--r--src/egl/drivers/dri2/platform_drm.c6
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c6
-rw-r--r--src/egl/drivers/dri2/platform_x11.c9
5 files changed, 33 insertions, 66 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a022a5d9432..f81bd3512d0 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1969,10 +1969,8 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
* incomplete, EGL_BAD_PARAMETER is generated."
*/
if (attrs->Width <= 0 || attrs->Height <= 0 ||
- !attrs->DMABufFourCC.IsPresent) {
- _eglError(EGL_BAD_PARAMETER, "attribute(s) missing");
- return EGL_FALSE;
- }
+ !attrs->DMABufFourCC.IsPresent)
+ return _eglError(EGL_BAD_PARAMETER, "attribute(s) missing");
/**
* Also:
@@ -1983,10 +1981,8 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
*/
for (unsigned i = 0; i < ARRAY_SIZE(attrs->DMABufPlanePitches); ++i) {
if (attrs->DMABufPlanePitches[i].IsPresent &&
- attrs->DMABufPlanePitches[i].Value <= 0) {
- _eglError(EGL_BAD_ACCESS, "invalid pitch");
- return EGL_FALSE;
- }
+ attrs->DMABufPlanePitches[i].Value <= 0)
+ return _eglError(EGL_BAD_ACCESS, "invalid pitch");
}
/**
@@ -1998,10 +1994,8 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
*/
for (unsigned i = 0; i < DMA_BUF_MAX_PLANES; ++i) {
if (attrs->DMABufPlaneModifiersLo[i].IsPresent !=
- attrs->DMABufPlaneModifiersHi[i].IsPresent) {
- _eglError(EGL_BAD_PARAMETER, "modifier attribute lo or hi missing");
- return EGL_FALSE;
- }
+ attrs->DMABufPlaneModifiersHi[i].IsPresent)
+ return _eglError(EGL_BAD_PARAMETER, "modifier attribute lo or hi missing");
}
/* Although the EGL_EXT_image_dma_buf_import_modifiers spec doesn't
@@ -2013,10 +2007,8 @@ dri2_check_dma_buf_attribs(const _EGLImageAttribs *attrs)
(attrs->DMABufPlaneModifiersLo[0].Value !=
attrs->DMABufPlaneModifiersLo[i].Value) ||
(attrs->DMABufPlaneModifiersHi[0].Value !=
- attrs->DMABufPlaneModifiersHi[i].Value)) {
- _eglError(EGL_BAD_PARAMETER, "modifier attributes not equal");
- return EGL_FALSE;
- }
+ attrs->DMABufPlaneModifiersHi[i].Value))
+ return _eglError(EGL_BAD_PARAMETER, "modifier attributes not equal");
}
}
@@ -2160,10 +2152,8 @@ dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
EGLint max, EGLint *formats, EGLint *count)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (max < 0 || (max > 0 && formats == NULL)) {
- _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
- return EGL_FALSE;
- }
+ if (max < 0 || (max > 0 && formats == NULL))
+ return _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->queryDmaBufFormats == NULL)
@@ -2183,15 +2173,11 @@ dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format,
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (max < 0) {
- _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
- return EGL_FALSE;
- }
+ if (max < 0)
+ return _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
- if (max > 0 && modifiers == NULL) {
- _eglError(EGL_BAD_PARAMETER, "invalid modifiers array");
- return EGL_FALSE;
- }
+ if (max > 0 && modifiers == NULL)
+ return _eglError(EGL_BAD_PARAMETER, "invalid modifiers array");
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->queryDmaBufModifiers == NULL)
@@ -2200,10 +2186,8 @@ dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format,
if (dri2_dpy->image->queryDmaBufModifiers(dri2_dpy->dri_screen, format,
max, modifiers,
(unsigned int *) external_only,
- count) == false) {
- _eglError(EGL_BAD_PARAMETER, "invalid format");
- return EGL_FALSE;
- }
+ count) == false)
+ return _eglError(EGL_BAD_PARAMETER, "invalid format");
return EGL_TRUE;
}
@@ -2406,10 +2390,8 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img,
(void) drv;
if (name && !dri2_dpy->image->queryImage(dri2_img->dri_image,
- __DRI_IMAGE_ATTRIB_NAME, name)) {
- _eglError(EGL_BAD_ALLOC, "dri2_export_drm_image_mesa");
- return EGL_FALSE;
- }
+ __DRI_IMAGE_ATTRIB_NAME, name))
+ return _eglError(EGL_BAD_ALLOC, "dri2_export_drm_image_mesa");
if (handle)
dri2_dpy->image->queryImage(dri2_img->dri_image,
@@ -2966,15 +2948,11 @@ dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
EGLint ret;
- if (sync->Type != EGL_SYNC_REUSABLE_KHR) {
- _eglError(EGL_BAD_MATCH, "eglSignalSyncKHR");
- return EGL_FALSE;
- }
+ if (sync->Type != EGL_SYNC_REUSABLE_KHR)
+ return _eglError(EGL_BAD_MATCH, "eglSignalSyncKHR");
- if (mode != EGL_SIGNALED_KHR && mode != EGL_UNSIGNALED_KHR) {
- _eglError(EGL_BAD_ATTRIBUTE, "eglSignalSyncKHR");
- return EGL_FALSE;
- }
+ if (mode != EGL_SIGNALED_KHR && mode != EGL_UNSIGNALED_KHR)
+ return _eglError(EGL_BAD_ATTRIBUTE, "eglSignalSyncKHR");
dri2_sync->base.SyncStatus = mode;
@@ -2982,10 +2960,8 @@ dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
ret = cnd_broadcast(&dri2_sync->cond);
/* fail to broadcast */
- if (ret) {
- _eglError(EGL_BAD_ACCESS, "eglSignalSyncKHR");
- return EGL_FALSE;
- }
+ if (ret)
+ return _eglError(EGL_BAD_ACCESS, "eglSignalSyncKHR");
}
return EGL_TRUE;
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index aef8a105f86..3be69d87ffa 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -666,10 +666,8 @@ droid_set_damage_region(_EGLDriver *drv,
return EGL_TRUE;
droid_rects = malloc(n_rects * sizeof(android_native_rect_t));
- if (droid_rects == NULL) {
- _eglError(EGL_BAD_ALLOC, "eglSetDamageRegionKHR");
- return EGL_FALSE;
- }
+ if (droid_rects == NULL)
+ return _eglError(EGL_BAD_ALLOC, "eglSetDamageRegionKHR");
for (EGLint num_drects = 0; num_drects < n_rects; num_drects++) {
EGLint i = num_drects * 4;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index c5ae49e9fdd..8e12aed0b32 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -434,10 +434,8 @@ dri2_drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
/* Make sure we have a back buffer in case we're swapping without
* ever rendering. */
- if (get_back_bo(dri2_surf) < 0) {
- _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
- return EGL_FALSE;
- }
+ if (get_back_bo(dri2_surf) < 0)
+ return _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
dri2_surf->current = dri2_surf->back;
dri2_surf->current->age = 1;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index a50b7636437..d56d658c737 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -727,10 +727,8 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
/* Make sure we have a back buffer in case we're swapping without ever
* rendering. */
- if (get_back_bo(dri2_surf) < 0) {
- _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
- return EGL_FALSE;
- }
+ if (get_back_bo(dri2_surf) < 0)
+ return _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
if (draw->SwapInterval > 0) {
dri2_surf->throttle_callback =
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 324128d12ae..9176c8e73f2 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -902,8 +902,7 @@ dri2_x11_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
if (dri2_x11_swap_buffers_msc(drv, disp, draw, 0, 0, 0) == -1) {
/* Swap failed with a window drawable. */
- _eglError(EGL_BAD_NATIVE_WINDOW, __func__);
- return EGL_FALSE;
+ return _eglError(EGL_BAD_NATIVE_WINDOW, __func__);
}
return EGL_TRUE;
}
@@ -1116,10 +1115,8 @@ dri2_x11_get_sync_values(_EGLDisplay *display, _EGLSurface *surface,
cookie = xcb_dri2_get_msc(dri2_dpy->conn, dri2_surf->drawable);
reply = xcb_dri2_get_msc_reply(dri2_dpy->conn, cookie, NULL);
- if (!reply) {
- _eglError(EGL_BAD_ACCESS, __func__);
- return EGL_FALSE;
- }
+ if (!reply)
+ return _eglError(EGL_BAD_ACCESS, __func__);
*ust = ((EGLuint64KHR) reply->ust_hi << 32) | reply->ust_lo;
*msc = ((EGLuint64KHR) reply->msc_hi << 32) | reply->msc_lo;