summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2010-07-14 02:05:47 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2010-07-14 02:05:47 +0000
commitb2a826a68069aa7666b9851bbc38931af9b39941 (patch)
tree7928d07b1c92d71ced6617ccfaac18eaade46c0b
parentcdaa13122d64b0ea0fc9f6d2b6d5d33c4dbe4a08 (diff)
downloadimlib2-b2a826a68069aa7666b9851bbc38931af9b39941.tar.gz
Remove unneeded code with notnull.cocci script
The notnull.cocci script from Coccinelle finds places where you check if a variable is NULL, but it's known not to be NULL. The check can be safely removed. For example, this code would be caught by notnull: if (!var) return; if (var && var->fld) { ... } It's needless to check again if var is not NULL because if it's in fact NULL, it would have returned on the previous "if". This commit removes all the trivial places where this pattern happens. Another patch will be generated for the more complex cases. SVN revision: 50241
-rw-r--r--src/lib/image.c3
-rw-r--r--src/modules/loaders/loader_pnm.c18
-rw-r--r--src/modules/loaders/loader_tga.c6
3 files changed, 9 insertions, 18 deletions
diff --git a/src/lib/image.c b/src/lib/image.c
index 2cb7a1a..592e9a4 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -676,8 +676,7 @@ __imlib_TrimLoaderList(char **list, int *num)
if (list[i])
free(list[i]);
}
- if (list)
- free(list);
+ free(list);
*num = size;
return ret;
}
diff --git a/src/modules/loaders/loader_pnm.c b/src/modules/loaders/loader_pnm.c
index c77628e..229a270 100644
--- a/src/modules/loaders/loader_pnm.c
+++ b/src/modules/loaders/loader_pnm.c
@@ -279,8 +279,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (idata)
- free(idata);
+ free(idata);
fclose(f);
return 2;
}
@@ -372,8 +371,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (idata)
- free(idata);
+ free(idata);
fclose(f);
return 2;
}
@@ -465,8 +463,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (data)
- free(data);
+ free(data);
fclose(f);
return 2;
}
@@ -533,8 +530,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (data)
- free(data);
+ free(data);
fclose(f);
return 2;
}
@@ -591,8 +587,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (data)
- free(data);
+ free(data);
fclose(f);
return 2;
}
@@ -660,8 +655,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
if (!progress(im, per, 0, pl, im->w, l))
{
- if (data)
- free(data);
+ free(data);
fclose(f);
return 2;
}
diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c
index 2070166..80fb749 100644
--- a/src/modules/loaders/loader_tga.c
+++ b/src/modules/loaders/loader_tga.c
@@ -156,8 +156,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
l = y - pl;
if (!progress(im, per, 0, (y - l), im->w, l))
{
- if (buf)
- free(buf);
+ free(buf);
fclose(f);
return 2;
}
@@ -173,8 +172,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity)
/* write the image data */
fwrite(buf, 1, im->w * im->h * ((im->flags & F_HAS_ALPHA) ? 4 : 3), f);
- if (buf)
- free(buf);
+ free(buf);
fclose(f);
return 1;
}