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 5e1a73b0b3
commit 9572d6f406
1 changed files with 5 additions and 5 deletions

View File

@ -1236,14 +1236,14 @@ _help(void)
" -f use netwm fullscreen request (requires x11 + wm)\n"
"\n"
"Where ENGINE can be one of:\n");
for (i = 0; engines[i].name != NULL; ++i)
for (i = 0; engines[i].name; ++i)
fprintf(stderr, " %s", engines[i].name);
fprintf(stderr,
"\n"
"Where PROFILE can be one of:\n");
for (i = 0; resolutions[i].name != NULL; ++i)
for (i = 0; resolutions[i].name; ++i)
fprintf(stderr, " %s", resolutions[i].name);
fprintf(stderr, "\n");
@ -1260,7 +1260,7 @@ _profile_parse(int argc, char **argv)
if ((!strcmp(argv[i], "-p")) && (i < (argc - 1)))
{
i++;
for (j = 0; resolutions[j].name != NULL; ++j)
for (j = 0; resolutions[j].name; ++j)
if (!strcmp(argv[i], resolutions[j].name))
{
profile = resolutions[j].name;
@ -1269,7 +1269,7 @@ _profile_parse(int argc, char **argv)
break;
}
if (resolutions[j].name == NULL)
if (!resolutions[j].name)
_help();
}
else if ((!strcmp(argv[i], "-c")) && (i < (argc - 1)))
@ -1318,7 +1318,7 @@ _engine_args(int argc, char **argv)
{
++i;
for (j = 0; engines[j].name != NULL; ++j)
for (j = 0; engines[j].name; ++j)
if (!strcmp(argv[i], engines[j].name))
{
engine = engines[j].name;