diff options
author | Myoungwoon Roy, Kim <myoungwoon.kim@samsung.com> | 2018-01-30 14:43:11 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2018-01-30 14:43:11 +0900 |
commit | 6bb2b8b4027f53650c6936d50a18b8c953e9ec04 (patch) | |
tree | 77dafb60e812667fc586b5a5ddba0f57daf18bf3 | |
parent | 7f4386670773ef9af4c4008bc261b8d94797af03 (diff) | |
download | efl-6bb2b8b4027f53650c6936d50a18b8c953e9ec04.tar.gz |
ecore_timer: Check for the valid callback func
Summary:
This patch checks whether the callback function is valid or not.
Callback function must be set up for the class.
Test Plan: Execute test suite
Reviewers: cedric, raster, stefan, Jaehyun_Cho
Subscribers: jpeg
Differential Revision: https://phab.enlightenment.org/D5762
-rw-r--r-- | src/lib/ecore/ecore_timer.c | 12 | ||||
-rw-r--r-- | src/tests/ecore/ecore_test_timer.c | 11 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c index c473b3e50d..6ef4ab254c 100644 --- a/src/lib/ecore/ecore_timer.c +++ b/src/lib/ecore/ecore_timer.c @@ -176,7 +176,11 @@ ecore_timer_add(double in, Ecore_Task_Cb func, const void *data) EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); legacy = calloc(1, sizeof (Ecore_Timer_Legacy)); if (!legacy) return NULL; - + if (!func) + { + ERR("Callback function must be set up for the class."); + return NULL; + } legacy->func = func; legacy->data = data; timer = efl_add(MY_CLASS, efl_main_loop_get(), @@ -195,7 +199,11 @@ ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data) EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); legacy = calloc(1, sizeof (Ecore_Timer_Legacy)); if (!legacy) return NULL; - + if (!func) + { + ERR("Callback function must be set up for the class."); + return NULL; + } legacy->func = func; legacy->data = data; timer = efl_add(MY_CLASS, efl_main_loop_get(), diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c index 66c072958e..8895a36cf2 100644 --- a/src/tests/ecore/ecore_test_timer.c +++ b/src/tests/ecore/ecore_test_timer.c @@ -286,6 +286,16 @@ START_TEST(ecore_test_timer_lifecycle) } END_TEST + +START_TEST(ecore_test_timer_valid_callbackfunc) +{ + fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n"); + Ecore_Timer *t = NULL; + fail_if((t = ecore_timer_add(0.5, NULL, NULL)), "ERROR: Invalid callback func!\n"); + ecore_shutdown(); +} +END_TEST + void ecore_test_timer(TCase *tc) { tcase_add_test(tc, ecore_test_timers); @@ -293,4 +303,5 @@ void ecore_test_timer(TCase *tc) tcase_add_test(tc, ecore_test_timer_lifecycle); */ tcase_add_test(tc, ecore_test_timer_inside_call); + tcase_add_test(tc, ecore_test_timer_valid_callbackfunc); } |