From: lucas Date: Sat, 21 Aug 2010 13:52:25 +0000 (+0000) Subject: Convert (hopefully) all comparisons to NULL X-Git-Tag: 2.0_alpha~163^2~336 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16cec7c130d58624b466902c47fac85a3fc3091e;p=framework%2Fuifw%2Fedje.git Convert (hopefully) all comparisons to NULL Apply badzero.cocci, badnull.coci and badnull2.cocci This should convert all cases where there's a comparison to NULL to simpler forms. This patch applies the following transformations: code before patch ||code after patch =============================================================== return a == NULL; return !a; return a != NULL; return !!a; func(a == NULL); func(!a); func(a != NULL); func(!!a); b = a == NULL; b = !a; b = a != NULL; b = !!a; b = a == NULL ? c : d; b = !a ? c : d; b = a != NULL ? c : d; b = a ? c : d; other cases: a == NULL !a a != NULL a git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@51487 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index 79749a7..b309a6e 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -1734,7 +1734,7 @@ ob_collections_group(void) Edje_Part_Collection *pc; Code *cd; - if (current_de != NULL && current_de->entry == NULL) + if (current_de && !current_de->entry) { ERR("%p: Error. A collection without a name was detected, that's not allowed.", progname); exit(-1); diff --git a/src/bin/edje_cc_parse.c b/src/bin/edje_cc_parse.c index effe5f3..1c63b5f 100644 --- a/src/bin/edje_cc_parse.c +++ b/src/bin/edje_cc_parse.c @@ -445,7 +445,7 @@ parse(char *data, off_t size) p = data; end = data + size; line = 1; - while ((token = next_token(p, end, &p, &delim)) != NULL) + while ((token = next_token(p, end, &p, &delim))) { /* if we are in param mode, the only delimiter * we'll accept is the semicolon diff --git a/src/bin/edje_convert.c b/src/bin/edje_convert.c index 7e9a73e..5b05da9 100644 --- a/src/bin/edje_convert.c +++ b/src/bin/edje_convert.c @@ -269,8 +269,8 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, _edje_collection_program_add(&edc->programs.nocmp, &edc->programs.nocmp_count, pg); - else if (pg->signal && strpbrk(pg->signal, "*?[\\") == NULL - && pg->source && strpbrk(pg->source, "*?[\\") == NULL) + else if (pg->signal && !strpbrk(pg->signal, "*?[\\") + && pg->source && !strpbrk(pg->source, "*?[\\")) _edje_collection_program_add(&edc->programs.strcmp, &edc->programs.strcmp_count, pg); diff --git a/src/bin/edje_convert_main.c b/src/bin/edje_convert_main.c index 5ab5ef9..b241d77 100644 --- a/src/bin/edje_convert_main.c +++ b/src/bin/edje_convert_main.c @@ -57,7 +57,7 @@ _edje_alias_int(const char *target, Eet_File *ef, const char *base, const char * snprintf(buf, sizeof (buf), "%s/", base); strcat(buf, "%i"); - for (i = 0; i < count && match != NULL; ++i) + for (i = 0; i < count && match; ++i) { char name[1024]; int id; @@ -87,7 +87,7 @@ _edje_alias_string(const char *target, Eet_File *ef, const char *base, const cha snprintf(buf, sizeof (buf), "%s/", base); strcat(buf, "%s"); - for (i = 0; i < count && match != NULL; ++i) + for (i = 0; i < count && match; ++i) { char name[1024]; char id[1024]; diff --git a/src/bin/edje_player.c b/src/bin/edje_player.c index bc65d7f..2c8d54b 100644 --- a/src/bin/edje_player.c +++ b/src/bin/edje_player.c @@ -226,7 +226,7 @@ _slave_mode(void *data, Ecore_Fd_Handler *fd_handler) } } - for (itr = _slave_mode_commands; itr->cmd != NULL; itr++) + for (itr = _slave_mode_commands; itr->cmd; itr++) { if (strcmp(itr->cmd, buf) == 0) { diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 2cc3f8c..b339edb 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -125,7 +125,7 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, doubl epdi = (Edje_Part_Description_Image*) epd2; /* There is an animation if both description are different or if description is an image with tweens */ - if (epd2 != NULL && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count))) + if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count))) { if (!ep->param2) { diff --git a/src/lib/edje_convert.c b/src/lib/edje_convert.c index 58dccc2..6b183fd 100644 --- a/src/lib/edje_convert.c +++ b/src/lib/edje_convert.c @@ -321,8 +321,8 @@ _edje_collection_convert(Edje_File *file, Old_Edje_Part_Collection *oedc) _edje_collection_program_add(&edc->programs.nocmp, &edc->programs.nocmp_count, pg); - else if (pg->signal && strpbrk(pg->signal, "*?[\\") == NULL - && pg->source && strpbrk(pg->source, "*?[\\") == NULL) + else if (pg->signal && !strpbrk(pg->signal, "*?[\\") + && pg->source && !strpbrk(pg->source, "*?[\\")) _edje_collection_program_add(&edc->programs.strcmp, &edc->programs.strcmp_count, pg); diff --git a/src/lib/edje_embryo.c b/src/lib/edje_embryo.c index 96e9cb8..bcaa25a 100644 --- a/src/lib/edje_embryo.c +++ b/src/lib/edje_embryo.c @@ -1152,7 +1152,7 @@ _edje_embryo_fn_get_color_class(Embryo_Program *ep, Embryo_Cell *params) GETSTR(class, params[1]); if (!class) return 0; c_class = _edje_color_class_find(ed, class); - if (c_class == NULL) return 0; + if (!c_class) return 0; SETINT(c_class->r, params[2]); SETINT(c_class->g, params[3]); SETINT(c_class->b, params[4]); @@ -1208,7 +1208,7 @@ _edje_embryo_fn_get_text_class(Embryo_Program *ep, Embryo_Cell *params) GETSTR(class, params[1]); if (!class) return 0; t_class = _edje_text_class_find(ed, class); - if (t_class == NULL) return 0; + if (!t_class) return 0; SETSTR((char *)t_class->font, params[2]); SETFLOAT(t_class->size, params[3]); return 0; diff --git a/src/lib/edje_entry.c b/src/lib/edje_entry.c index 16ae0ec..438ee5f 100644 --- a/src/lib/edje_entry.c +++ b/src/lib/edje_entry.c @@ -130,7 +130,7 @@ _edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v _edje_emit(ed, "focus,in", ""); #ifdef HAVE_ECORE_IMF rp = ed->focused_part; - if (rp == NULL) return; + if (!rp) return; en = rp->entry_data; if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || diff --git a/src/lib/edje_external.c b/src/lib/edje_external.c index bf60d24..b25e21e 100644 --- a/src/lib/edje_external.c +++ b/src/lib/edje_external.c @@ -239,7 +239,7 @@ edje_object_part_external_param_type_get(const Evas_Object *obj, const char *par type->module_name); return EDJE_EXTERNAL_PARAM_TYPE_MAX; } - for (info = type->parameters_info; info->name != NULL; info++) + for (info = type->parameters_info; info->name; info++) if (strcmp(info->name, param) == 0) return info->type; diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c index 4d2acfd..f07578b 100644 --- a/src/lib/edje_load.c +++ b/src/lib/edje_load.c @@ -139,7 +139,7 @@ edje_file_collection_list(const char *file) if ((!file) || (!*file)) return NULL; edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); - if (edf != NULL) + if (edf) { Eina_Iterator *i; const char *key; @@ -186,7 +186,7 @@ edje_file_group_exists(const char *file, const char *glob) if ((!file) || (!*file)) return EINA_FALSE; edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); - if (edf != NULL) + if (edf) { Edje_Patterns *patterns; @@ -246,7 +246,7 @@ edje_file_data_get(const char *file, const char *key) if (key) { edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); - if (edf != NULL) + if (edf) { str = (char*) edje_string_get(eina_hash_find(edf->data, key)); @@ -883,7 +883,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g void _edje_file_add(Edje *ed) { - if (_edje_edd_edje_file == NULL) return; + if (!_edje_edd_edje_file) return; ed->file = _edje_cache_file_coll_open(ed->path, ed->group, &(ed->load_error), &(ed->collection)); diff --git a/src/lib/edje_lua.c b/src/lib/edje_lua.c index b01d0ad..c29e839 100644 --- a/src/lib/edje_lua.c +++ b/src/lib/edje_lua.c @@ -385,7 +385,7 @@ _edje_lua_new_class(lua_State *L, const Edje_Lua_Reg ** class) { int n = 0; _edje_lua_new_metatable(L, class); - while (class && (class[n] != NULL)) + while (class && (class[n])) { luaL_register(L, NULL, class[n]->mt); lua_pushstring(L, "hands off, it's none of your business!"); @@ -5075,7 +5075,7 @@ _edje_lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) void _edje_lua_init() { - if (Ledje != NULL) return; + if (Ledje) return; /* * create main Lua state with the custom memory allocation function */ @@ -5161,7 +5161,7 @@ _edje_lua_init() void _edje_lua_shutdown() { - if (Ledje == NULL) return; + if (!Ledje) return; lua_close(Ledje); Ledje = NULL; } diff --git a/src/lib/edje_match.c b/src/lib/edje_match.c index 85aa3b1..b9ff606 100644 --- a/src/lib/edje_match.c +++ b/src/lib/edje_match.c @@ -673,8 +673,8 @@ edje_match_program_hash_build(Edje_Program * const *programs, for (i = 0; i < count; ++i) { - if (programs[i]->signal && strpbrk(programs[i]->signal, "*?[\\") == NULL - && programs[i]->source && strpbrk(programs[i]->source, "*?[\\") == NULL) + if (programs[i]->signal && !strpbrk(programs[i]->signal, "*?[\\") + && programs[i]->source && !strpbrk(programs[i]->source, "*?[\\")) { Edje_Signal_Source_Char *item; @@ -714,8 +714,8 @@ edje_match_callback_hash_build(const Eina_List *callbacks, EINA_LIST_FOREACH(callbacks, l, callback) { - if (callback->signal && strpbrk(callback->signal, "*?[\\") == NULL - && callback->source && strpbrk(callback->source, "*?[\\") == NULL) + if (callback->signal && !strpbrk(callback->signal, "*?[\\") + && callback->source && !strpbrk(callback->source, "*?[\\")) { Edje_Signal_Source_Char *item; diff --git a/src/lib/edje_message_queue.c b/src/lib/edje_message_queue.c index 25b0dcb..3ffb137 100644 --- a/src/lib/edje_message_queue.c +++ b/src/lib/edje_message_queue.c @@ -691,7 +691,7 @@ _edje_message_queue_process(void) { int i; - if (msgq == NULL) return; + if (!msgq) return; /* allow the message queue to feed itself up to 8 times before forcing */ /* us to go back to normal processing and let a 0 timeout deal with it */ diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 15eda54..d962bd4 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -1749,7 +1749,7 @@ edje_program_is_strrncmp(const char *str) { if (*str != '*' && *str != '?') return EINA_FALSE; - if (strpbrk(str + 1, "*?[\\") != NULL) + if (strpbrk(str + 1, "*?[\\")) return EINA_FALSE; return EINA_TRUE; } diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c index fdaaf23..53092d4 100644 --- a/src/lib/edje_program.c +++ b/src/lib/edje_program.c @@ -844,7 +844,7 @@ _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, #ifdef LUA2 _edje_lua2_script_init(ed); #else - if (ed->L == NULL) /* private state does not yet exist, create it */ + if (!ed->L) /* private state does not yet exist, create it */ { ed->L = _edje_lua_new_thread(ed, _edje_lua_state_get()); } @@ -1032,7 +1032,7 @@ _edje_emit(Edje *ed, const char *sig, const char *src) /* The part contain a [index], retrieve it */ idx = strchr(sig, EDJE_PART_PATH_SEPARATOR_INDEXL); - if (idx == NULL || sep < idx) newsig = part + (sep - sig); + if (!idx || sep < idx) newsig = part + (sep - sig); else newsig = part + (idx - sig); *newsig = '\0'; @@ -1391,7 +1391,7 @@ _edje_external_param_info_get(const Evas_Object *obj, const char *name) type = evas_object_data_get(obj, "Edje_External_Type"); if (!type) return NULL; - for (info = type->parameters_info; info->name != NULL; info++) + for (info = type->parameters_info; info->name; info++) if (!strcmp(info->name, name)) return info; return NULL; @@ -1974,7 +1974,7 @@ _edje_param_validate(const Edje_External_Param *param, const Edje_External_Param { const char **itr = info->info.c.choices; if (!itr) return EINA_FALSE; - for (; *itr != NULL; itr++) + for (; *itr; itr++) if (!strcmp(*itr, param->s)) return EINA_TRUE; return EINA_FALSE; diff --git a/src/lib/edje_text.c b/src/lib/edje_text.c index 23dd35f..2fdb0c5 100644 --- a/src/lib/edje_text.c +++ b/src/lib/edje_text.c @@ -394,7 +394,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, if (ep->text.cache.in_str) eina_stringshare_del(ep->text.cache.in_str); ep->text.cache.in_str = eina_stringshare_add(text); ep->text.cache.in_size = size; - if (chosen_desc->text.fit_x && (ep->text.cache.in_str != NULL && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) { if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); else evas_object_text_font_source_set(ep->object, NULL); @@ -437,7 +437,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, } } } - if (chosen_desc->text.fit_y && (ep->text.cache.in_str != NULL && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) { /* if we fit in the x axis, too, size already has a somewhat * meaningful value, so don't overwrite it with the starting diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index 04c556c..7e49f2a 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -2342,7 +2342,7 @@ _edje_box_layout_builtin_find(const char *name) return NULL; } - for (; (base->name != NULL) && (base->name[0] == name[0]); base++) + for (; (base->name) && (base->name[0] == name[0]); base++) if (strcmp(base->name, name) == 0) return base->cb; @@ -4311,13 +4311,13 @@ _edje_real_part_recursive_get_helper(Edje *ed, char **path) if (alias) { rp = _edje_real_part_recursive_get(ed, alias); - if (path[1] == NULL) return rp; + if (!path[1]) return rp; if (!rp) return NULL; } else { rp = _edje_real_part_get(ed, path[0]); - if (path[1] == NULL) return rp; + if (!path[1]) return rp; if (!rp) return NULL; } @@ -4841,8 +4841,8 @@ _edje_program_remove(Edje_Part_Collection *edc, Edje_Program *p) array = &edc->programs.nocmp; count = &edc->programs.nocmp_count; } - else if (p->signal && strpbrk(p->signal, "*?[\\") == NULL - && p->source && strpbrk(p->source, "*?[\\") == NULL) + else if (p->signal && !strpbrk(p->signal, "*?[\\") + && p->source && !strpbrk(p->source, "*?[\\")) { array = &edc->programs.strcmp; count = &edc->programs.strcmp_count; @@ -4885,8 +4885,8 @@ _edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p) array = &edc->programs.nocmp; count = &edc->programs.nocmp_count; } - else if (p->signal && strpbrk(p->signal, "*?[\\") == NULL - && p->source && strpbrk(p->source, "*?[\\") == NULL) + else if (p->signal && !strpbrk(p->signal, "*?[\\") + && p->source && !strpbrk(p->source, "*?[\\")) { array = &edc->programs.strcmp; count = &edc->programs.strcmp_count;