forked from e16/e16
1
0
Fork 0

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




SVN revision: 51487
This commit is contained in:
Lucas De Marchi 2010-08-21 13:52:25 +00:00
parent 637d8fdbca
commit f287759d3e
7 changed files with 13 additions and 14 deletions

View File

@ -577,8 +577,7 @@ BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
if (!draw)
draw = WinGetXwin(win);
hasbg = bg->bg.im != NULL;
hasfg = bg->top.im != NULL;
hasbg = !!bg->bg.im;hasfg = !!bg->top.im;
if (!hasbg && !hasfg)
{

View File

@ -1008,7 +1008,7 @@ ecore_x_netwm_name_get(Ecore_X_Window win, char **name)
s = _ecore_x_window_prop_string_utf8_get(win, ECORE_X_ATOM_NET_WM_NAME);
*name = s;
return s != NULL;
return !!s;
}
void
@ -1027,7 +1027,7 @@ ecore_x_netwm_visible_name_get(Ecore_X_Window win, char **name)
ECORE_X_ATOM_NET_WM_VISIBLE_NAME);
*name = s;
return s != NULL;
return !!s;
}
void
@ -1045,7 +1045,7 @@ ecore_x_netwm_icon_name_get(Ecore_X_Window win, char **name)
s = _ecore_x_window_prop_string_utf8_get(win, ECORE_X_ATOM_NET_WM_ICON_NAME);
*name = s;
return s != NULL;
return !!s;
}
void
@ -1065,7 +1065,7 @@ ecore_x_netwm_visible_icon_name_get(Ecore_X_Window win, char **name)
ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME);
*name = s;
return s != NULL;
return !!s;
}
void
@ -1119,7 +1119,7 @@ ecore_x_netwm_startup_id_get(Ecore_X_Window win, char **id)
s = _ecore_x_window_prop_string_utf8_get(win, ECORE_X_ATOM_NET_STARTUP_ID);
*id = s;
return s != NULL;
return !!s;
}
#endif /* USE_ECORE_X */

View File

@ -505,7 +505,7 @@ MenuCheckShowEwinDesk(EWin * ewin, void *prm)
{
if (!EwinGetTitle(ewin) || ewin->props.skip_winlist)
return 0;
return prm == NULL || EwinGetDesk(ewin) == prm;
return !prm || EwinGetDesk(ewin) == prm;
}
static void

View File

@ -1168,7 +1168,7 @@ MenusShowNamed(const char *name, const char *param)
int
MenusActive(void)
{
return Mode_menus.first != NULL;
return !!Mode_menus.first;
}
static void

View File

@ -706,11 +706,11 @@ _DlgFillSnap(Dialog * d, DItem * table, void *data)
{
sd->match.name = 1;
sd->match.clss = 1;
sd->match.role = ewin->icccm.wm_role != NULL;
sd->match.role = !!ewin->icccm.wm_role;
}
else
{
sd->match.title = EwinGetIcccmName(ewin) != NULL;
sd->match.title = !!EwinGetIcccmName(ewin);
}
}
@ -1601,7 +1601,7 @@ static void
_SnapShow(void *data, void *prm)
{
Snapshot *sn = (Snapshot *) data;
int full = prm != NULL;
int full = !!prm;
char buf[FILEPATH_LEN_MAX];
const char *name;

View File

@ -281,7 +281,7 @@ SoundFree(const char *name)
sclass = SclassFind(name);
SclassDestroy(sclass);
return sclass != NULL;
return !!sclass;
}
static void

View File

@ -339,7 +339,7 @@ _sound_pa_Init(void)
goto quit;
done:
return pa_ctx == NULL;
return !pa_ctx;
quit:
_sound_pa_Exit();
goto done;