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.


SVN revision: 50241
This commit is contained in:
Lucas De Marchi 2010-07-14 02:05:47 +00:00
parent 3a00e81a7c
commit 2a84379ba9
9 changed files with 18 additions and 22 deletions

View File

@ -1336,8 +1336,7 @@ ecore_x_icccm_command_get(Ecore_X_Window window __UNUSED__,
if (c < 1)
{
if (v)
free(v);
free(v);
return;
}

View File

@ -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);
}

View File

@ -851,7 +851,7 @@ eet_cipher(const void *data, unsigned int size, const char *key, unsigned int le
if (opened) EVP_CIPHER_CTX_cleanup(&ctx);
# endif
/* General error */
if (ret) free(ret);
free(ret);
if (result) *result = NULL;
if (result_length) *result_length = 0;

View File

@ -1334,7 +1334,7 @@ eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size,
if (!_eet_data_image_decode_inside(data, size, 0, 0, iw, ih, d, iw, ih, iw * 4, ialpha, icompress, iquality, ilossy))
{
if (d) free(d);
free(d);
return NULL;
}

View File

@ -639,7 +639,7 @@ eet_flush2(Eet_File *ef)
}
}
sign_error:
if (fp) fclose(fp);
fclose(fp);
return error;
}

View File

@ -1414,7 +1414,7 @@ efreet_desktop_cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __U
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, efreet_desktop_cache_update_free, d);
return;
error:
if (tmp) eet_close(tmp);
eet_close(tmp);
}
static void

View File

@ -671,14 +671,10 @@ evas_cache_engine_image_engine(Evas_Cache_Engine_Image *cache, void *engine_data
on_error:
if (!eim)
{
if (ie)
evas_cache_image_drop(ie);
}
evas_cache_image_drop(ie);
else
{
evas_cache_engine_image_drop(eim);
}
evas_cache_engine_image_drop(eim);
return NULL;
}

View File

@ -3806,8 +3806,8 @@ evas_textblock_cursor_compare(const Evas_Textblock_Cursor *cur1, const Evas_Text
else if (l2 == EINA_INLIST_GET(cur2->node)) return -1; /* cur1 < cur 2 */
else if (!l1) return -1; /* cur1 < cur 2 */
else if (!l2) return 1; /* cur2 < cur 1 */
if (l1) l1 = l1->prev;
if (l2) l2 = l2->next;
l1 = l1->prev;
l2 = l2->next;
}
return 0;
}

View File

@ -631,9 +631,9 @@ evas_image_load_file_xpm(Image_Entry *ie, const char *file, const char *key __UN
break;
}
if (cmap) free(cmap);
if (line) free(line);
if (f) fclose(f);
free(cmap);
free(line);
fclose(f);
xpm_parse_done();
*error = EVAS_LOAD_ERROR_NONE;