summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2018-01-16 15:11:44 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2018-01-16 18:37:05 +0900
commitf2b5b00ca204e8a0b8c4ab671f60088da4edfca3 (patch)
treee224bfb1550d93f634d2db0fb08723024dd85423
parentf47f8dcf820100e1e1fb987b832f3cd026d51608 (diff)
eo: Warn on calls to NULL object
This makes eo print a WRN message in case a function is called on NULL. efl_del is an exception to this rule (implemented in a hackish way, I admit). I don't know any language or object model where using a null object doesn't result in an exception or crash, except EO. In any case, calls to null are invalid. The next commits will resolve most warnings for EFL. Ref T6326
-rw-r--r--src/lib/eo/eo.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 0db34fc35c..410f8a78f0 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -40,6 +40,8 @@ EAPI Eina_Lock _efl_class_creation_lock;
40EAPI unsigned int _efl_object_init_generation = 1; 40EAPI unsigned int _efl_object_init_generation = 1;
41int _eo_log_dom = -1; 41int _eo_log_dom = -1;
42Eina_Thread _efl_object_main_thread; 42Eina_Thread _efl_object_main_thread;
43static unsigned int efl_del_api_generation = 0;
44static Efl_Object_Op _efl_del_api_op_id = 0;
43 45
44typedef enum _Eo_Ref_Op { 46typedef enum _Eo_Ref_Op {
45 EO_REF_OP_NONE, 47 EO_REF_OP_NONE,
@@ -101,6 +103,8 @@ static inline void *_efl_data_xref_internal(const char *file, int line, _Eo_Obje
101static inline void _efl_data_xunref_internal(_Eo_Object *obj, void *data, const _Eo_Object *ref_obj); 103static inline void _efl_data_xunref_internal(_Eo_Object *obj, void *data, const _Eo_Object *ref_obj);
102static void _vtable_init(Eo_Vtable *vtable, size_t size); 104static void _vtable_init(Eo_Vtable *vtable, size_t size);
103 105
106static inline Efl_Object_Op _efl_object_api_op_id_get_internal(const void *api_func);
107
104/* Start of Dich */ 108/* Start of Dich */
105 109
106 110
@@ -449,7 +453,7 @@ _efl_object_call_resolve(Eo *eo_id, const char *func_name, Efl_Object_Op_Call_Da
449 Eina_Bool is_obj; 453 Eina_Bool is_obj;
450 Eina_Bool super = EINA_TRUE; 454 Eina_Bool super = EINA_TRUE;
451 455
452 if (EINA_UNLIKELY(!eo_id)) return EINA_FALSE; 456 if (EINA_UNLIKELY(!eo_id)) goto on_null;
453 457
454 call->eo_id = eo_id; 458 call->eo_id = eo_id;
455 459
@@ -624,6 +628,16 @@ obj_super:
624err_klass: 628err_klass:
625 _EO_POINTER_ERR(eo_id, "in %s:%d: func '%s': obj_id=%p is an invalid ref.", file, line, func_name, eo_id); 629 _EO_POINTER_ERR(eo_id, "in %s:%d: func '%s': obj_id=%p is an invalid ref.", file, line, func_name, eo_id);
626 return EINA_FALSE; 630 return EINA_FALSE;
631
632on_null:
633 if (EINA_UNLIKELY(efl_del_api_generation != _efl_object_init_generation))
634 {
635 _efl_del_api_op_id = _efl_object_api_op_id_get_internal(EFL_FUNC_COMMON_OP_FUNC(efl_del));
636 efl_del_api_generation = _efl_object_init_generation;
637 }
638 if (op != _efl_del_api_op_id)
639 WRN("NULL passed to function %s().", func_name);
640 return EINA_FALSE;
627} 641}
628 642
629EAPI void 643EAPI void