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:
parent
5962d9d66c
commit
35e8e96a61
|
@ -44,10 +44,10 @@ main(int argc, char **argv)
|
|||
/**
|
||||
* First tests to determine which rendering task to perform
|
||||
*/
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
|
|
@ -34,10 +34,10 @@ main(int argc, char **argv)
|
|||
/**
|
||||
* First tests to determine which rendering task to perform
|
||||
*/
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
|
|
@ -26,7 +26,7 @@ main(int argc, char **argv)
|
|||
n = strchr(++oldn, '/');
|
||||
if (argc < 3 || !strcmp(argv[1], "-h"))
|
||||
usage(-1);
|
||||
if ((im = imlib_load_image(argv[1])) == NULL)
|
||||
if (!(im = imlib_load_image(argv[1])))
|
||||
{
|
||||
fprintf(stderr, PROG_NAME ": Error loading image: %s\n", argv[1]);
|
||||
exit(-1);
|
||||
|
|
|
@ -101,10 +101,10 @@ main(int argc, char **argv)
|
|||
|
||||
file = argv[0];
|
||||
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
|
|
@ -33,10 +33,10 @@ main(int argc, char **argv)
|
|||
/**
|
||||
* First tests to determine which rendering task to perform
|
||||
*/
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
|
|
@ -265,10 +265,10 @@ main(int argc, char **argv)
|
|||
if (!blendtest)
|
||||
{
|
||||
const char *display_name = getenv("DISPLAY");
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
@ -917,7 +917,7 @@ main(int argc, char **argv)
|
|||
int i;
|
||||
|
||||
f = fn;
|
||||
if (fn != NULL && f->type & 2)
|
||||
if (fn && f->type & 2)
|
||||
for (i = 0; i < f->font_count; i++)
|
||||
printf("xfont%d: %s\n", i, f->font_name[i]);
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ main(int argc, char **argv)
|
|||
const char *display_name = getenv("DISPLAY");
|
||||
|
||||
/* connect to X */
|
||||
if (display_name == NULL)
|
||||
if (!display_name)
|
||||
display_name = ":0";
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Can't open display %s\n", display_name);
|
||||
return 1;
|
||||
|
|
|
@ -137,7 +137,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
disp = XOpenDisplay(NULL);
|
||||
if (disp == NULL)
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Cannot open display\n");
|
||||
return 1;
|
||||
|
|
|
@ -101,7 +101,7 @@ __imlib_dynamic_filters_init()
|
|||
for (i = num_filters - 1; i >= 0; i--)
|
||||
{
|
||||
tptr = NULL;
|
||||
if ((tptr = __imlib_LoadFilter(list[i])) != NULL)
|
||||
if ((tptr = __imlib_LoadFilter(list[i])))
|
||||
{
|
||||
ptr->next = tptr;
|
||||
ptr = ptr->next;
|
||||
|
@ -130,7 +130,7 @@ __imlib_get_dynamic_filter(char *name)
|
|||
int i = 0;
|
||||
|
||||
/* scan the filters */
|
||||
for (f_ptr = filters->next; f_ptr != NULL; f_ptr = f_ptr->next)
|
||||
for (f_ptr = filters->next; f_ptr; f_ptr = f_ptr->next)
|
||||
{
|
||||
/* scan the methods provided */
|
||||
for (i = 0; i < f_ptr->num_filters; i++)
|
||||
|
|
|
@ -258,7 +258,7 @@ __imlib_FileDir(char *dir, int *num)
|
|||
return (NULL);
|
||||
}
|
||||
/* count # of entries in dir (worst case) */
|
||||
for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++);
|
||||
for (dirlen = 0; (dp = readdir(dirp)); dirlen++);
|
||||
if (!dirlen)
|
||||
{
|
||||
closedir(dirp);
|
||||
|
@ -391,9 +391,9 @@ __imlib_FileHomeDir(int uid)
|
|||
return (s);
|
||||
}
|
||||
#else
|
||||
if ((s = getenv("HOME")) != NULL)
|
||||
if ((s = getenv("HOME")))
|
||||
return strdup(s);
|
||||
else if ((s = getenv("TMP")) != NULL)
|
||||
else if ((s = getenv("TMP")))
|
||||
return strdup(s);
|
||||
#endif
|
||||
return NULL;
|
||||
|
|
|
@ -668,7 +668,7 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
|
|||
if (x_does_shm)
|
||||
{
|
||||
xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo);
|
||||
is_shm = xim != NULL;
|
||||
is_shm = xim;
|
||||
}
|
||||
if (!xim)
|
||||
xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
|
||||
|
@ -683,7 +683,7 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
|
|||
if ((m) && (domask))
|
||||
{
|
||||
mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w, h, &mshminfo);
|
||||
is_mshm = mxim != NULL;
|
||||
is_mshm = mxim;
|
||||
if (!mxim)
|
||||
mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ IVariable *vars, *current_var, *curtail;
|
|||
static int
|
||||
__imlib_find_string(const char *haystack, const char *needle)
|
||||
{
|
||||
if (strstr(haystack, needle) != NULL)
|
||||
if (strstr(haystack, needle))
|
||||
return (strstr(haystack, needle) - haystack);
|
||||
return 0;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ __imlib_script_tidyup_params(IFunctionParam * param)
|
|||
static void
|
||||
__imlib_script_delete_variable(IVariable * var)
|
||||
{
|
||||
if (var->next != NULL)
|
||||
if (var->next)
|
||||
__imlib_script_delete_variable(var->next);
|
||||
free(var);
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ __imlib_script_tidyup(void)
|
|||
void *
|
||||
__imlib_script_get_next_var(void)
|
||||
{
|
||||
if (current_var != NULL)
|
||||
if (current_var)
|
||||
current_var = current_var->next;
|
||||
if (current_var != NULL)
|
||||
if (current_var)
|
||||
return current_var->ptr;
|
||||
else
|
||||
return NULL;
|
||||
|
@ -174,7 +174,7 @@ __imlib_script_parse_parameters(Imlib_Image im, char *parameters)
|
|||
if (strcmp(value, "[]") == 0)
|
||||
{
|
||||
ptr->data = __imlib_script_get_next_var();
|
||||
if (ptr->data == NULL)
|
||||
if (!ptr->data)
|
||||
{
|
||||
D("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK");
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ __imlib_script_parse_function(Imlib_Image im, char *function)
|
|||
params = __imlib_script_parse_parameters(im, funcparams);
|
||||
/* excute the filter */
|
||||
filter = __imlib_get_dynamic_filter(funcname);
|
||||
if (filter != NULL)
|
||||
if (filter)
|
||||
{
|
||||
#ifdef FDEBUG
|
||||
printf("DEBUG: (--) Executing Filter \"%s\".\n", funcname);
|
||||
|
@ -249,7 +249,7 @@ __imlib_script_parse(Imlib_Image im, char *script, va_list param_list)
|
|||
char *scriptbuf = NULL, *function;
|
||||
|
||||
D("(--) Script Parser Start.");
|
||||
if (script != NULL && script[0] != 0)
|
||||
if (script && script[0] != 0)
|
||||
{
|
||||
vars = malloc(sizeof(IVariable));
|
||||
vars->ptr = NULL;
|
||||
|
|
|
@ -47,7 +47,7 @@ exec(char *filter, void *im, pIFunctionParam params)
|
|||
w = imlib_image_get_width();
|
||||
h = imlib_image_get_height();
|
||||
|
||||
for (ptr = params; ptr != NULL; ptr = ptr->next)
|
||||
for (ptr = params; ptr; ptr = ptr->next)
|
||||
{
|
||||
ASSIGN_DATA8("red", r);
|
||||
ASSIGN_DATA8("blue", b);
|
||||
|
@ -94,7 +94,7 @@ exec(char *filter, void *im, pIFunctionParam params)
|
|||
{
|
||||
int angle = 0;
|
||||
|
||||
for (ptr = params; ptr != NULL; ptr = ptr->next)
|
||||
for (ptr = params; ptr; ptr = ptr->next)
|
||||
{
|
||||
ASSIGN_INT("angle", angle);
|
||||
}
|
||||
|
|
|
@ -95,12 +95,12 @@ static context* context_create (const char* filename)
|
|||
ptr = ptr->next;
|
||||
}
|
||||
/* Paranoid! this can occur only if there are INT_MAX contexts :) */
|
||||
if (UNLIKELY (ptr == NULL)) {
|
||||
if (UNLIKELY (!ptr)) {
|
||||
fprintf (stderr, "Too many open ID3 contexts\n");
|
||||
goto fail_close;
|
||||
}
|
||||
node->id = ptr->id + 1;
|
||||
if (UNLIKELY (last != NULL)) {
|
||||
if (UNLIKELY (!!last)) {
|
||||
node->next = last->next;
|
||||
last->next = node;
|
||||
} else {
|
||||
|
|
|
@ -259,7 +259,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
|
|||
return 0;
|
||||
}
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
if (!info_ptr)
|
||||
{
|
||||
fclose(f);
|
||||
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
|
||||
|
|
|
@ -356,7 +356,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
goto quit2;
|
||||
}
|
||||
|
||||
if (rgba_image.rgba.put.any == NULL)
|
||||
if (!rgba_image.rgba.put.any)
|
||||
{
|
||||
fprintf(stderr, "imlib2-tiffloader: No put function");
|
||||
|
||||
|
|
Loading…
Reference in New Issue