tests/ecore_wl2: Fix unchecked return value

Coverity reports eglChooseConfig is called without checking return
value here. This patch fixes the issue by checking the return value
and by also making _init_egl return a bool so that we can fail the
test if eglChooseConfig results in failure.

Fixes Coverity CID1412365
This commit is contained in:
Christopher Michael 2020-06-10 08:32:40 -04:00
parent e48ac73bdc
commit ca1eba10af
2 changed files with 18 additions and 3 deletions

View File

@ -324,6 +324,7 @@ _test_activated_window_activate(void *data EINA_UNUSED, int type EINA_UNUSED, vo
EFL_START_TEST(wl2_window_activated)
{
Test_Data *td;
Eina_Bool ret = EINA_FALSE;
ecore_wl2_init();
@ -345,7 +346,9 @@ EFL_START_TEST(wl2_window_activated)
ecore_wl2_window_show(td->win);
_init_egl(td);
ret = _init_egl(td);
fail_if(ret != EINA_TRUE);
td->handler = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE_COMPLETE,
_test_activated_configure_complete, td);
ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ACTIVATE,

View File

@ -5,7 +5,7 @@
#include <EGL/egl.h>
#include <GLES2/gl2.h>
static void
static Eina_Bool
_init_egl(Test_Data *td)
{
eglBindAPI(EGL_OPENGL_API);
@ -21,18 +21,30 @@ _init_egl(Test_Data *td)
td->egl_display =
eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get(td->display));
eglInitialize(td->egl_display, NULL, NULL);
eglChooseConfig(td->egl_display, attributes, &td->egl_conf, 1, &num_config);
if (!eglChooseConfig(td->egl_display, attributes, &td->egl_conf,
1, &num_config))
{
ERR("Failed to choose egl config");
eglTerminate(td->egl_display);
return EINA_FALSE;
}
td->egl_context =
eglCreateContext(td->egl_display, td->egl_conf, EGL_NO_CONTEXT, NULL);
td->egl_window = wl_egl_window_create(td->surface, td->width, td->height);
td->egl_surface =
eglCreateWindowSurface(td->egl_display,
td->egl_conf, td->egl_window, NULL);
eglMakeCurrent(td->egl_display, td->egl_surface,
td->egl_surface, td->egl_context);
return EINA_TRUE;
}
static void