summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2010-08-21 13:52:25 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2010-08-21 13:52:25 +0000
commit35e8e96a61ae1ea97aa50ddf46a7895fb8785ca7 (patch)
treea1bd43e741e7a0e26f4200db306471b4084b1777
parent5962d9d66cafa54f08c95fc91d13d5531aef7dd6 (diff)
downloadimlib2-35e8e96a61ae1ea97aa50ddf46a7895fb8785ca7.tar.gz
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
-rw-r--r--src/bin/imlib2_bumpmap.c4
-rw-r--r--src/bin/imlib2_colorspace.c4
-rw-r--r--src/bin/imlib2_conv.c2
-rw-r--r--src/bin/imlib2_grab.c4
-rw-r--r--src/bin/imlib2_poly.c4
-rw-r--r--src/bin/imlib2_show.c6
-rw-r--r--src/bin/imlib2_test.c4
-rw-r--r--src/bin/imlib2_view.c2
-rw-r--r--src/lib/dynamic_filters.c4
-rw-r--r--src/lib/file.c6
-rw-r--r--src/lib/grab.c4
-rw-r--r--src/lib/script.c14
-rw-r--r--src/modules/filters/filter_test.c4
-rw-r--r--src/modules/loaders/loader_id3.c4
-rw-r--r--src/modules/loaders/loader_png.c2
-rw-r--r--src/modules/loaders/loader_tiff.c2
16 files changed, 35 insertions, 35 deletions
diff --git a/src/bin/imlib2_bumpmap.c b/src/bin/imlib2_bumpmap.c
index 2f8ff55..c1ab30d 100644
--- a/src/bin/imlib2_bumpmap.c
+++ b/src/bin/imlib2_bumpmap.c
@@ -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;
diff --git a/src/bin/imlib2_colorspace.c b/src/bin/imlib2_colorspace.c
index 9c13889..bd9e5e0 100644
--- a/src/bin/imlib2_colorspace.c
+++ b/src/bin/imlib2_colorspace.c
@@ -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;
diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index e4789f9..1b05b1f 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -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);
diff --git a/src/bin/imlib2_grab.c b/src/bin/imlib2_grab.c
index d4eff2e..58ee6ba 100644
--- a/src/bin/imlib2_grab.c
+++ b/src/bin/imlib2_grab.c
@@ -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;
diff --git a/src/bin/imlib2_poly.c b/src/bin/imlib2_poly.c
index 7373e01..cb53548 100644
--- a/src/bin/imlib2_poly.c
+++ b/src/bin/imlib2_poly.c
@@ -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;
diff --git a/src/bin/imlib2_show.c b/src/bin/imlib2_show.c
index 7b84a38..025aa56 100644
--- a/src/bin/imlib2_show.c
+++ b/src/bin/imlib2_show.c
@@ -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]);
}
diff --git a/src/bin/imlib2_test.c b/src/bin/imlib2_test.c
index 9495b03..93d3316 100644
--- a/src/bin/imlib2_test.c
+++ b/src/bin/imlib2_test.c
@@ -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;
diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 2771eaa..7a84211 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -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;
diff --git a/src/lib/dynamic_filters.c b/src/lib/dynamic_filters.c
index 1f99750..92f373d 100644
--- a/src/lib/dynamic_filters.c
+++ b/src/lib/dynamic_filters.c
@@ -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++)
diff --git a/src/lib/file.c b/src/lib/file.c
index 6a485e4..902bcbc 100644
--- a/src/lib/file.c
+++ b/src/lib/file.c
@@ -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;
diff --git a/src/lib/grab.c b/src/lib/grab.c
index 41d0ff4..25a0dd7 100644
--- a/src/lib/grab.c
+++ b/src/lib/grab.c
@@ -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);
}
diff --git a/src/lib/script.c b/src/lib/script.c
index 532c875..7b7e310 100644
--- a/src/lib/script.c
+++ b/src/lib/script.c
@@ -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;
diff --git a/src/modules/filters/filter_test.c b/src/modules/filters/filter_test.c
index 3e8b185..d6006c4 100644
--- a/src/modules/filters/filter_test.c
+++ b/src/modules/filters/filter_test.c
@@ -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);
}
diff --git a/src/modules/loaders/loader_id3.c b/src/modules/loaders/loader_id3.c
index 40113c4..5318748 100644
--- a/src/modules/loaders/loader_id3.c
+++ b/src/modules/loaders/loader_id3.c
@@ -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 {
diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c
index 2941f40..36834ae 100644
--- a/src/modules/loaders/loader_png.c
+++ b/src/modules/loaders/loader_png.c
@@ -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);
diff --git a/src/modules/loaders/loader_tiff.c b/src/modules/loaders/loader_tiff.c
index 20dff43..b6779a9 100644
--- a/src/modules/loaders/loader_tiff.c
+++ b/src/modules/loaders/loader_tiff.c
@@ -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");