From d6d46fb99eacbdc6a2f79a3cfe976d008e22a696 Mon Sep 17 00:00:00 2001 From: lucas Date: Wed, 14 Jul 2010 02:05:47 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eet@50241 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/eet_cipher.c | 2 +- src/lib/eet_image.c | 2 +- src/lib/eet_lib.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/eet_cipher.c b/src/lib/eet_cipher.c index a4e9880..9266e7f 100644 --- a/src/lib/eet_cipher.c +++ b/src/lib/eet_cipher.c @@ -851,7 +851,7 @@ eet_cipher(const void *data, unsigned int size, const char *key, unsigned int le if (opened) EVP_CIPHER_CTX_cleanup(&ctx); # endif /* General error */ - if (ret) free(ret); + free(ret); if (result) *result = NULL; if (result_length) *result_length = 0; diff --git a/src/lib/eet_image.c b/src/lib/eet_image.c index 0636581..c3be1f1 100644 --- a/src/lib/eet_image.c +++ b/src/lib/eet_image.c @@ -1334,7 +1334,7 @@ eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size, if (!_eet_data_image_decode_inside(data, size, 0, 0, iw, ih, d, iw, ih, iw * 4, ialpha, icompress, iquality, ilossy)) { - if (d) free(d); + free(d); return NULL; } diff --git a/src/lib/eet_lib.c b/src/lib/eet_lib.c index cc87909..651e15e 100644 --- a/src/lib/eet_lib.c +++ b/src/lib/eet_lib.c @@ -639,7 +639,7 @@ eet_flush2(Eet_File *ef) } } sign_error: - if (fp) fclose(fp); + fclose(fp); return error; } -- 2.7.4