bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Remove useless if conditionals before calls to 'free'.


From: James Youngman
Subject: [PATCH] Remove useless if conditionals before calls to 'free'.
Date: Fri, 2 Apr 2010 01:48:20 +0100

* lib/nextelem.c (next_element): Remove useless if-before-free.
* lib/buildcmd.c (bc_do_exec): Likewise.
* find/find.c (process_dir): Likewise.

Signed-off-by: James Youngman <address@hidden>
---
 ChangeLog      |    5 +++++
 find/find.c    |    6 ++----
 lib/buildcmd.c |    3 +--
 lib/nextelem.c |    3 +--
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 466eb57..e673061 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@
 
 2010-04-02  James Youngman  <address@hidden>
 
+       Remove useless if conditionals before calls to 'free'.
+       * lib/nextelem.c (next_element): Remove useless if-before-free.
+       * lib/buildcmd.c (bc_do_exec): Likewise.
+       * find/find.c (process_dir): Likewise.
+
        * import-gnulib.sh (usage): Defeat the simple GPL version check
        of maint.mk, since it's trying to identify GPL2 licenses.  Since
        the 'rehack' script converts v2 licenses into v3, we get a false
diff --git a/find/find.c b/find/find.c
index 9a1866c..08d58d0 100644
--- a/find/find.c
+++ b/find/find.c
@@ -1414,8 +1414,7 @@ process_dir (char *pathname, char *name, int pathlen, 
const struct stat *statp,
            {
              while (file_len > cur_path_size)
                cur_path_size += 1024;
-             if (cur_path)
-               free (cur_path);
+             free (cur_path);
              cur_path = xmalloc (cur_path_size);
              strcpy (cur_path, pathname);
              cur_path[pathname_len - 2] = '/';
@@ -1533,8 +1532,7 @@ process_dir (char *pathname, char *name, int pathlen, 
const struct stat *statp,
            }
        }
 
-      if (cur_path)
-       free (cur_path);
+      free (cur_path);
       free_dirinfo (dirinfo);
     }
 
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index c279d22..3accbc0 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -326,8 +326,7 @@ bc_do_exec (struct buildcmd_control *ctl,
     /* (state->cmd_argc - ctl->initial_argc) includes the terminating NULL,
      * which is why we add 1 to done in the test above. */
 
-    if (working_args)
-      free (working_args);
+    free (working_args);
     bc_clear_args (ctl, state);
 }
 
diff --git a/lib/nextelem.c b/lib/nextelem.c
index 7367b08..2d42de0 100644
--- a/lib/nextelem.c
+++ b/lib/nextelem.c
@@ -46,8 +46,7 @@ next_element (const char *new_path, int curdir_ok)
 
   if (new_path)
     {
-      if (path)
-       free (path);
+      free (path);
       end = path = strdup (new_path);
       final_colon = 0;
       return NULL;
-- 
1.5.6.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]