From: lucas Date: Wed, 14 Jul 2010 02:05:47 +0000 (+0000) Subject: Remove unneeded code with notnull.cocci script X-Git-Tag: submit/2.0alpha-wayland/20121127.221958~1214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0b46134d83efe9ad6f954708b8209b28c6bbdb0;p=profile%2Fivi%2Fedje.git Remove unneeded code with notnull.cocci script The notnull.cocci script from Coccinelle finds places where you check if a variable is NULL, but it's known not to be NULL. The check can be safely removed. For example, this code would be caught by notnull: if (!var) return; if (var && var->fld) { ... } It's needless to check again if var is not NULL because if it's in fact NULL, it would have returned on the previous "if". This commit removes all the trivial places where this pattern happens. Another patch will be generated for the more complex cases. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@50241 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/edje_edit.c b/src/lib/edje_edit.c index 32054ae..d0e2629 100644 --- a/src/lib/edje_edit.c +++ b/src/lib/edje_edit.c @@ -472,7 +472,7 @@ _edje_part_id_set(Edje *ed, Edje_Real_Part *rp, int new_id) if (!part) return; //printf("CHANGE ID OF PART %s TO %d\n", part->name, new_id); - if (!ed || !part || new_id < -1) return; + if (!ed || new_id < -1) return; if (part->id == new_id) return; @@ -6122,8 +6122,9 @@ _edje_generate_source_of_group(Edje *ed, const char *group, Eina_Strbuf *buf) EINA_LIST_FOREACH(ll, l, data) { - BUF_APPENDF(I3"item: \"%s\" \"%s\";\n", data, - edje_edit_group_data_value_get(obj, data)); + const char *value = edje_edit_group_data_value_get(obj, data); + ret &= !!value; + BUF_APPENDF(I3"item: \"%s\" \"%s\";\n", data, value); } BUF_APPEND(I2"}\n\n"); @@ -6157,7 +6158,7 @@ _edje_generate_source_of_group(Edje *ed, const char *group, Eina_Strbuf *buf) { BUF_APPEND(I2 "programs {\n"); EINA_LIST_FOREACH(ll, l, data) - _edje_generate_source_of_program(obj, data, buf); + ret &= _edje_generate_source_of_program(obj, data, buf); BUF_APPEND(I2 "}\n"); edje_edit_string_list_free(ll); }