From ca1eba10af084bd44d2aa1738b2b55a408ece802 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Wed, 10 Jun 2020 08:32:40 -0400 Subject: [PATCH] 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 --- src/tests/ecore_wl2/ecore_wl2_test_window.c | 5 ++++- src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/tests/ecore_wl2/ecore_wl2_test_window.c b/src/tests/ecore_wl2/ecore_wl2_test_window.c index c094515e93..4b9e734d61 100644 --- a/src/tests/ecore_wl2/ecore_wl2_test_window.c +++ b/src/tests/ecore_wl2/ecore_wl2_test_window.c @@ -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, diff --git a/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h index 27fa4a615e..f235a481bb 100644 --- a/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h +++ b/src/tests/ecore_wl2/ecore_wl2_tests_helper_egl.h @@ -5,7 +5,7 @@ #include #include -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