Remove unneeded code with notnull.cocci script
authorlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 14 Jul 2010 02:05:47 +0000 (02:05 +0000)
committerlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 14 Jul 2010 02:05:47 +0000 (02:05 +0000)
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
src/lib/eet_image.c
src/lib/eet_lib.c

index a4e9880..9266e7f 100644 (file)
@@ -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;
 
index 0636581..c3be1f1 100644 (file)
@@ -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;
      }
 
index cc87909..651e15e 100644 (file)
@@ -639,7 +639,7 @@ eet_flush2(Eet_File *ef)
          }
      }
    sign_error:
-   if (fp) fclose(fp);
+   fclose(fp);
    return error;
 }