forked from e16/e16
1
0
Fork 0

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 baa8f7abf9
commit 118b441611
3 changed files with 3 additions and 4 deletions

View File

@ -278,7 +278,7 @@ BackgroundDelete(Background * bg)
#if 0
Eprintf("%s: %s\n", __func__, bg->name);
#endif
if (!bg || bg->ref_count > 0)
if (bg->ref_count > 0)
return;
/* And delete the actual image files */

View File

@ -89,7 +89,7 @@ Estrdupcat2(char *ss, const char *s1, const char *s2)
if (!ss)
return Estrdup(s2);
len = (ss) ? strlen(ss) : 0;
len = strlen(ss);
l1 = (s1) ? strlen(s1) : 0;
l2 = (s2) ? strlen(s2) : 0;

View File

@ -170,8 +170,7 @@ MWM_GetHints(EWin * ewin, Atom atom_change)
ewin->props.no_border = 1;
done:
if (mwmhints)
XFree(mwmhints);
XFree(mwmhints);
}
void