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 38c5103bae
commit c426218dfe
6 changed files with 11 additions and 11 deletions

View File

@ -243,7 +243,7 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
if (desktop)
{
Eina_List *l;
efreet_desktop_ref(desktop);
inst->desktop = desktop;
inst->key = eina_stringshare_add(desktop->orig_path);
@ -252,7 +252,7 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
inst->launch_time = ecore_time_get();
inst->expire_timer = ecore_timer_add(e_config->exec.expire_timeout,
_e_exec_cb_expire_timer, inst);
l = eina_hash_find(e_exec_instances, desktop->orig_path);
l = eina_list_append(l, inst);
if (l)
@ -260,16 +260,16 @@ _e_exec_cb_exec(void *data, Efreet_Desktop *desktop, char *exec, int remaining)
else
eina_hash_add(e_exec_instances, desktop->orig_path, l);
e_exec_start_pending = eina_list_append(e_exec_start_pending, desktop);
e_exehist_add(launch->launch_method, desktop->exec);
}
else if (exe)
else
{
E_FREE(inst);
inst = NULL;
ecore_exe_free(exe);
}
if (!remaining)
{
if (launch->launch_method) eina_stringshare_del(launch->launch_method);

View File

@ -1060,7 +1060,7 @@ _font_list_load(E_Config_Dialog_Data *cfdata, const char *cur_font)
const char *f;
f = next->data;
if ((cur_font) && (!strcasecmp(f, cur_font)))
if (!strcasecmp(f, cur_font))
{
e_widget_ilist_selected_set(ob, n);
break;

View File

@ -377,13 +377,13 @@ EAPI void
e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, int x, int y, int w, int h)
{
E_Kbd_Buf_Key *ky;
if (!key) return;
if (!kb->layout) kb->layout = _e_kbd_buf_new();
if (!kb->layout) return;
ky = E_NEW(E_Kbd_Buf_Key, 1);
if (!ky) return;
if (key) ky->key = eina_stringshare_add(key);
ky->key = eina_stringshare_add(key);
if (key_shift) ky->key_shift = eina_stringshare_add(key_shift);
if (key_capslock) ky->key_capslock = eina_stringshare_add(key_capslock);
ky->x = x;

View File

@ -384,7 +384,7 @@ e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift,
if (!kb->layout) return;
ky = E_NEW(E_Kbd_Buf_Key, 1);
if (!ky) return;
if (key) ky->key = eina_stringshare_add(key);
ky->key = eina_stringshare_add(key);
if (key_shift) ky->key_shift = eina_stringshare_add(key_shift);
if (key_capslock) ky->key_capslock = eina_stringshare_add(key_capslock);
ky->x = x;

View File

@ -1911,7 +1911,7 @@ _pager_window_cb_drag_finished(E_Drag *drag, int dropped)
if (!(pw->border->lock_user_stacking)) e_border_raise(pw->border);
}
if (pw && pw->drag.from_pager) pw->drag.from_pager->dragging = 0;
if (pw->drag.from_pager) pw->drag.from_pager->dragging = 0;
pw->drag.from_pager = NULL;
if (act_popup)

View File

@ -431,7 +431,7 @@ _cb_signal_action(void *data, Evas_Object *obj, const char *emission, const char
if (!sca) return;
a = e_action_find(sca->action);
if (!a) return;
if (a) a->func.go(NULL, sca->params);
a->func.go(NULL, sca->params);
}
static void