From 5e67a80753c4cc0a33dfaba008c098e07acfadfa Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 26 Aug 2016 12:01:52 -0700 Subject: [PATCH] eo: remove useless duplicated check. --- src/lib/eo/eo_ptr_indirection.h | 70 +++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/src/lib/eo/eo_ptr_indirection.h b/src/lib/eo/eo_ptr_indirection.h index d7f6dd3..8cad652 100644 --- a/src/lib/eo/eo_ptr_indirection.h +++ b/src/lib/eo/eo_ptr_indirection.h @@ -13,42 +13,29 @@ void _eo_pointer_error(const char *msg); #define _EO_POINTER_ERR(fmt, ptr) \ do { char buf[256]; sprintf(buf, fmt, ptr); _eo_pointer_error(buf); } while (0) -#define EO_OBJ_POINTER(obj_id, obj) \ - _Eo_Object *obj = NULL; \ - do { \ - if (!obj_id) break; \ - obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ - if (!obj) { \ - _EO_POINTER_ERR("Obj (%p) is an invalid ref.", obj_id); \ - } \ - } while (0) - -#define EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, ret) \ - _Eo_Object *obj; \ - do { \ - if (!obj_id) return ret; \ - obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ - if (!obj) { \ - _EO_POINTER_ERR("Obj (%p) is an invalid ref.", obj_id); \ - return ret; \ - } \ - } while (0) - -#define EO_OBJ_POINTER_RETURN(obj_id, obj) \ - _Eo_Object *obj; \ - do { \ - if (!obj_id) return; \ - obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ - if (!obj) { \ - _EO_POINTER_ERR("Obj (%p) is an invalid ref.", obj_id); \ - return; \ - } \ - } while (0) +#define EO_OBJ_POINTER(obj_id, obj) \ + _Eo_Object *obj = NULL; \ + do { \ + obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ + } while (0) + +#define EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, ret) \ + _Eo_Object *obj; \ + do { \ + obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ + if (!obj) return (ret); \ + } while (0) + +#define EO_OBJ_POINTER_RETURN(obj_id, obj) \ + _Eo_Object *obj; \ + do { \ + obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ + if (!obj) return; \ + } while (0) #define EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, ret) \ _Efl_Class *klass; \ do { \ - if (!klass_id) return ret; \ klass = _eo_class_pointer_get(klass_id); \ if (!klass) { \ _EO_POINTER_ERR("Class (%p) is an invalid ref.", klass_id); \ @@ -59,7 +46,6 @@ void _eo_pointer_error(const char *msg); #define EO_CLASS_POINTER_RETURN(klass_id, klass) \ _Efl_Class *klass; \ do { \ - if (!klass_id) return; \ klass = _eo_class_pointer_get(klass_id); \ if (!klass) { \ _EO_POINTER_ERR("Class (%p) is an invalid ref.", klass_id); \ @@ -69,15 +55,15 @@ void _eo_pointer_error(const char *msg); #else -#define EO_OBJ_POINTER(obj_id, obj) \ - _Eo_Object *obj = NULL; \ - do { \ - if (!obj_id) break; \ - obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ - if (!EINA_MAGIC_CHECK((Eo_Header *) obj, EO_EINA_MAGIC)) { \ - EINA_MAGIC_FAIL((Eo_Header *) obj, EO_EINA_MAGIC); \ - } \ - } while (0) +#define EO_OBJ_POINTER(obj_id, obj) \ + _Eo_Object *obj = NULL; \ + do { \ + obj = _eo_obj_pointer_get((Eo_Id)obj_id); \ + if (obj && \ + !EINA_MAGIC_CHECK((Eo_Header *) obj, EO_EINA_MAGIC)) { \ + EINA_MAGIC_FAIL((Eo_Header *) obj, EO_EINA_MAGIC); \ + } \ + } while (0) #define EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, ret) \ _Eo_Object *obj; \ -- 2.7.4