Convert (hopefully) all comparisons to NULL
authorlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Aug 2010 13:52:25 +0000 (13:52 +0000)
committerlucas <lucas@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 21 Aug 2010 13:52:25 +0000 (13:52 +0000)
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

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/efreet@51487 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/efreet_desktop_command.c
src/lib/efreet_icon.c
src/lib/efreet_ini.c
src/lib/efreet_menu.c
src/tests/compare/efreet_alloc.c
src/tests/ef_data_dirs.c
src/tests/ef_icon_theme.c
src/tests/ef_locale.c
src/tests/ef_mime.c
src/tests/efreet_suite.c
src/tests/main.c

index 9a563c5..461d934 100644 (file)
@@ -489,7 +489,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
          * fields (fFuUdDnN). We only want to run the app once in this case. */
         if (!file_added) break;
     }
-    while ((l = eina_list_next(l)) != NULL);
+    while ((l = eina_list_next(l)));
 
     return execs;
 error:
index 7157f34..4c33523 100644 (file)
@@ -107,7 +107,7 @@ efreet_icon_init(void)
         }
 
         /* setup the default extension list */
-        for (i = 0; default_exts[i] != NULL; i++)
+        for (i = 0; default_exts[i]; i++)
             efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
 
         efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
@@ -659,7 +659,7 @@ efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name,
     double minimal_distance = INT_MAX;
     unsigned int ret_size = 0;
 
-    if (!theme || (theme->paths == NULL) || !icon_name || !size)
+    if (!theme || (!theme->paths) || !icon_name || !size)
         return NULL;
 
     icon = efreet_icon_cache_check(theme, icon_name, size);
@@ -1317,7 +1317,7 @@ efreet_icon_theme_dir_scan(const char *search_dir, const char *theme_name)
         /* only care if this is a directory or the theme name matches the
          * given name */
         snprintf(path, sizeof(path), "%s/%s", search_dir, dir->d_name);
-        if (((theme_name != NULL) && (strcmp(theme_name, dir->d_name)))
+        if (((theme_name) && (strcmp(theme_name, dir->d_name)))
                 || !ecore_file_is_dir(path))
             continue;
 
index ecb9bd4..c20f46d 100644 (file)
@@ -183,7 +183,7 @@ efreet_ini_parse(const char *file)
             goto next_line;
         }
 
-        if (section == NULL)
+        if (!section)
         {
 //            INF("Invalid file (%s) (missing section)", file);
             goto next_line;
index e9c1566..e5168e5 100644 (file)
@@ -490,7 +490,7 @@ efreet_menu_init(void)
      * to handle it */
     efreet_tag_menu = eina_stringshare_add(menu_cbs[0].key);
 
-    for (i = 0; menu_cbs[i].key != NULL; i++)
+    for (i = 0; menu_cbs[i].key; i++)
     {
         eina_hash_del(efreet_menu_handle_cbs,
                         menu_cbs[i].key,
@@ -499,7 +499,7 @@ efreet_menu_init(void)
                         menu_cbs[i].key,
                         menu_cbs[i].cb);
     }
-    for (i = 0; filter_cbs[i].key != NULL; i++)
+    for (i = 0; filter_cbs[i].key; i++)
     {
         eina_hash_del(efreet_menu_filter_cbs,
                         filter_cbs[i].key,
@@ -508,7 +508,7 @@ efreet_menu_init(void)
                         filter_cbs[i].key,
                         filter_cbs[i].cb);
     }
-    for (i = 0; move_cbs[i].key != NULL; i++)
+    for (i = 0; move_cbs[i].key; i++)
     {
         eina_hash_del(efreet_menu_move_cbs,
                         move_cbs[i].key,
@@ -517,7 +517,7 @@ efreet_menu_init(void)
                         move_cbs[i].key,
                         move_cbs[i].cb);
     }
-    for (i = 0; layout_cbs[i].key != NULL; i++)
+    for (i = 0; layout_cbs[i].key; i++)
     {
         eina_hash_del(efreet_menu_layout_cbs,
                         layout_cbs[i].key,
index 98d11ae..a6582e1 100644 (file)
@@ -13,7 +13,7 @@ main(void)
 
     for (k = 0; k < LOOPS; k++)
     {
-        for (i = 0; icons[i] != NULL; i++)
+        for (i = 0; icons[i]; i++)
         {
             path = efreet_icon_path_find(THEME, icons[i], SIZE);
 //            printf("%s: %s\n", icons[i], (path ? path : "NOT FOUND"));
index f5705fd..d6c629b 100644 (file)
@@ -169,7 +169,7 @@ ef_cb_efreet_data_dirs(void)
     char *def_vals[] = {PACKAGE_DATA_DIR, "/usr/share", "/usr/local/share", NULL};
 
     dirs[0] = '\0';
-    for (i = 0; vals[i] != NULL; i++)
+    for (i = 0; vals[i]; i++)
     {
         if (i > 0) strcat(dirs, ":");
         strcat(dirs, vals[i]);
@@ -183,7 +183,7 @@ ef_cb_efreet_data_dirs(void)
     tmp = efreet_data_dirs_get();
     EINA_LIST_FOREACH(tmp, l, val)
     {
-        if (vals[i] == NULL)
+        if (!vals[i])
         {
             printf("efreet_data_dirs_get() returned more values then it "
                     "should have given %s as input\n", dirs);
@@ -215,7 +215,7 @@ ef_cb_efreet_data_dirs(void)
 
     EINA_LIST_FOREACH(tmp, l, val)
     {
-        if (def_vals[i] == NULL)
+        if (!def_vals[i])
         {
             printf("efreet_data_dirs_get() returned more values then it "
                     "should have given %s as input\n", dirs);
@@ -246,7 +246,7 @@ ef_cb_efreet_config_dirs(void)
 
     dirs[0] = '\0';
 
-    for (i = 0; vals[i] != NULL; i++)
+    for (i = 0; vals[i]; i++)
     {
         if (i > 0) strcat(dirs, ":");
         strcat(dirs, vals[i]);
@@ -260,7 +260,7 @@ ef_cb_efreet_config_dirs(void)
     tmp = efreet_config_dirs_get();
     EINA_LIST_FOREACH(tmp, l, val)
     {
-        if (vals[i] == NULL)
+        if (!vals[i])
         {
             printf("efreet_config_dirs_get() returned more values then it "
                     "should have given %s as input\n", dirs);
@@ -286,7 +286,7 @@ ef_cb_efreet_config_dirs(void)
     tmp = efreet_config_dirs_get();
     EINA_LIST_FOREACH(tmp, l, val)
     {
-        if (def_vals[i] == NULL)
+        if (!def_vals[i])
         {
             printf("efreet_config_dirs_get() returned more values then it "
                     "should have given %s as input\n", dirs);
index 3b5c701..bb66698 100644 (file)
@@ -478,7 +478,7 @@ ef_cb_efreet_icon_match(void)
        themes = eina_list_remove_list(themes, themes);
 
     double start = ecore_time_get();
-    for (i = 0; system_icons[i] != NULL; i++)
+    for (i = 0; system_icons[i]; i++)
     {
         char *path, *s;
 
@@ -516,7 +516,7 @@ ef_cb_efreet_icon_match(void)
     eina_hash_free(icon_hash);
 
     start = ecore_time_get();
-    for (i = 0; system_icons[i] != NULL; i++)
+    for (i = 0; system_icons[i]; i++)
     {
         char *path, *s;
 
index d71799e..cfc50e2 100644 (file)
@@ -44,7 +44,7 @@ ef_cb_locale(void)
     putenv("LC_MESSAGES=");
     putenv("LANG=");
 
-    for (i = 0; langs[i].lc_message != NULL; i++)
+    for (i = 0; langs[i].lc_message; i++)
     {
         const char *tmp;
 
index 9c49eed..89ace2b 100644 (file)
@@ -30,7 +30,7 @@ ef_mime_cb_get(void)
         return 1;
     }
 
-    for (i = 0; files[i].file != NULL; ++i)
+    for (i = 0; files[i].file; ++i)
     {
         mime = efreet_mime_type_get(files[i].file);
         if (!mime)
index 801a413..7424435 100644 (file)
@@ -30,7 +30,7 @@ _list_tests(void)
 
    itr = etc;
    fputs("Available Test Cases:\n", stderr);
-   for (; itr->test_case != NULL; itr++)
+   for (; itr->test_case; itr++)
      fprintf(stderr, "\t%s\n", itr->test_case);
 }
 
@@ -55,7 +55,7 @@ efreet_suite_build(int argc, const char **argv)
 
    s = suite_create("Efreet");
 
-   for (i = 0; etc[i].test_case != NULL; ++i)
+   for (i = 0; etc[i].test_case; ++i)
      {
        if (!_use_test(argc, argv, etc[i].test_case)) continue;
        tc = tcase_create(etc[i].test_case);
index 3298e6b..147bf8c 100644 (file)
@@ -124,7 +124,7 @@ main(int argc, char ** argv)
             if ((!strcmp(argv[i], "-h")) ||
                 (!strcmp(argv[i], "--help")))
             {
-                for (i = 0; tests[i].name != NULL; i++)
+                for (i = 0; tests[i].name; i++)
                 {
                     printf("%s\n", tests[i].name);
                 }
@@ -135,7 +135,7 @@ main(int argc, char ** argv)
     }
 
     environment_store();
-    for (i = 0; tests[i].name != NULL; i++)
+    for (i = 0; tests[i].name; i++)
     {
         int ret;
         double start;