ecore_main: Check for the valid flag

Summary:
This patch checks for the valid Ecore_Fd_Handler_Flags.
The flags should be checked like previous verion because
There are no default handlings in case of out of Ecore_Fd_Handler enum values in other funcs.

Test Plan: Execute a test case

Reviewers: cedric, raster, jpeg, stefan, Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D5775
This commit is contained in:
Myoungwoon Roy, Kim 2018-01-31 18:04:09 +09:00 committed by Jean-Philippe Andre
parent 98f38ac0f7
commit e9d1a1e988
2 changed files with 28 additions and 1 deletions

View File

@ -1280,7 +1280,7 @@ _ecore_main_fd_handler_add(Eo *obj,
DBG("_ecore_main_fd_handler_add");
Ecore_Fd_Handler *fdh = NULL;
if ((fd < 0) || (!func)) return NULL;
if ((fd < 0) || (flags == 0) || (!func)) return NULL;
fdh = ecore_fd_handler_calloc(1);
if (!fdh) return NULL;

View File

@ -269,6 +269,32 @@ START_TEST(ecore_test_ecore_main_loop_fd_handler)
}
END_TEST
START_TEST(ecore_test_ecore_main_loop_fd_handler_valid_flags)
{
Ecore_Fd_Handler *fd_handler;
int comm[2];
int ret;
ret = ecore_init();
fail_if(ret < 1);
ret = pipe(comm);
fail_if(ret != 0);
fd_handler = ecore_main_fd_handler_add
(comm[0], 0, _fd_handler_cb, NULL, NULL, NULL);
fail_if(fd_handler != NULL);
if (fd_handler)
ecore_main_fd_handler_del(fd_handler);
close(comm[0]);
close(comm[1]);
ecore_shutdown();
}
END_TEST
static void
_eo_read_cb(void *data, const Efl_Event *info EINA_UNUSED)
{
@ -897,6 +923,7 @@ void ecore_test_ecore(TCase *tc)
tcase_add_test(tc, ecore_test_ecore_main_loop_idle_exiter);
tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler);
tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler_valid_flags);
tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler_activate_modify);
tcase_add_test(tc, ecore_test_ecore_main_loop_event);
#if 0