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 cd9ac98213
commit 50f87c6bcb
2 changed files with 5 additions and 5 deletions

View File

@ -202,7 +202,7 @@ dcpgettext_expr (const char *domain,
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
if (msg_ctxt_id)
#endif
{
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
@ -248,7 +248,7 @@ dcnpgettext_expr (const char *domain,
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
if (msg_ctxt_id)
#endif
{
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);

View File

@ -1304,8 +1304,8 @@ _bt_close(void *data, Evas_Object *obj, void *event_info)
static Eina_Bool
_run_dialog(Evas_Object *parent, enum dialog_type type, const char *message, const char *default_entry_value, char **entry_value)
{
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (default_entry_value != NULL), EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (entry_value != NULL), EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (!!default_entry_value), EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (!!entry_value), EINA_FALSE);
struct _dialog_data *dialog_data = calloc(1, sizeof(*dialog_data));
Eina_Bool response = EINA_FALSE;
@ -1464,7 +1464,7 @@ static void
_view_smart_window_close(Ewk_View_Smart_Data *esd)
{
View_Smart_Data *sd = (View_Smart_Data *)esd;
EINA_SAFETY_ON_TRUE_RETURN(sd->idler_close_window != NULL);
EINA_SAFETY_ON_TRUE_RETURN(!!sd->idler_close_window);
sd->idler_close_window = ecore_idler_add(_window_close_delayed, sd);
}