commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 16/43: Simplify deallocations.


From: Samuel Thibault
Subject: [hurd] 16/43: Simplify deallocations.
Date: Mon, 11 Sep 2017 07:10:10 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 66553fd7a7bcf7c260b45f2e7ad54e98d33f8080
Author: Justus Winter <address@hidden>
Date:   Sat Aug 5 19:28:38 2017 +0200

    Simplify deallocations.
    
    free (NULL) is a nop, therefore it is not necessary to check that
    first.  Simplify the code accordingly.  This commit is the result of
    the following semantic patch:
    
        @@
        identifier X;
        @@
        -if (X) free (X);
        +free (X);
    
    * console-client/console.c: Simplify accordingly.
    * console-client/driver.c: Likewise.
    * console-client/vga.c: Likewise.
    * ftpfs/dir.c: Likewise.
    * libftpconn/unix.c: Likewise.
    * libps/fmt.c: Likewise.
    * libps/proclist.c: Likewise.
    * libstore/mvol.c: Likewise.
    * nfs/ops.c: Likewise.
    * proc/host.c: Likewise.
    * sutils/fstab.c: Likewise.
---
 console-client/console.c |  3 +--
 console-client/driver.c  |  6 ++----
 console-client/vga.c     | 12 ++++--------
 ftpfs/dir.c              |  3 +--
 libftpconn/unix.c        |  9 +++------
 libps/fmt.c              |  9 +++------
 libps/proclist.c         |  6 ++----
 libstore/mvol.c          |  3 +--
 nfs/ops.c                |  3 +--
 proc/host.c              |  3 +--
 sutils/fstab.c           |  2 +-
 11 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/console-client/console.c b/console-client/console.c
index 5335156..3b31611 100644
--- a/console-client/console.c
+++ b/console-client/console.c
@@ -563,8 +563,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
        char *s;
        char *d;
 
-       if (driver_path)
-         free (driver_path);
+       free (driver_path);
        driver_path = malloc (strlen (arg) + 2);
        if (!driver_path)
          {
diff --git a/console-client/driver.c b/console-client/driver.c
index 7a55bbe..b4a03ab 100644
--- a/console-client/driver.c
+++ b/console-client/driver.c
@@ -117,8 +117,7 @@ error_t driver_add (const char *const name, const char 
*const driver,
 
   while (dir)
     {
-      if (filename)
-       free (filename);
+      free (filename);
       if (asprintf (&filename,
                    "%s/%s%s", dir, driver, CONSOLE_SONAME_SUFFIX) < 0)
        {
@@ -156,8 +155,7 @@ error_t driver_add (const char *const name, const char 
*const driver,
 
   if (!shobj)
     {
-      if (filename)
-       free (filename);
+      free (filename);
       pthread_mutex_unlock (&driver_list_lock);
       return ENOENT;
     }
diff --git a/console-client/vga.c b/console-client/vga.c
index 9d751a7..e954013 100644
--- a/console-client/vga.c
+++ b/console-client/vga.c
@@ -385,14 +385,10 @@ vga_display_fini (void *handle, int force)
   free (disp);
   dynacolor_fini ();
   vga_fini ();
-  if (vga_display_font)
-    free (vga_display_font);
-  if (vga_display_font_italic)
-    free (vga_display_font_italic);
-  if (vga_display_font_bold)
-    free (vga_display_font_bold);
-  if (vga_display_font_bold_italic)
-    free (vga_display_font_bold_italic);
+  free (vga_display_font);
+  free (vga_display_font_italic);
+  free (vga_display_font_bold);
+  free (vga_display_font_bold_italic);
 
   return 0;
 }
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index 44c8550..72b1a46 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -705,8 +705,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
       pthread_mutex_unlock (&dir->node->lock);
     }
 
-  if (rmt_path)
-    free (rmt_path);
+  free (rmt_path);
 
   return err;
 }
diff --git a/libftpconn/unix.c b/libftpconn/unix.c
index 882fee8..2804e7c 100644
--- a/libftpconn/unix.c
+++ b/libftpconn/unix.c
@@ -252,14 +252,11 @@ ftp_conn_unix_start_get_stats (struct ftp_conn *conn,
 
  out:
 
-  if (req)
-    free (req);
+  free (req);
   if (err)
     {
-      if (s)
-       free (s);
-      if (searched_name)
-       free (searched_name);
+      free (s);
+      free (searched_name);
     }
   else
     {
diff --git a/libps/fmt.c b/libps/fmt.c
index cd83885..4641663 100644
--- a/libps/fmt.c
+++ b/libps/fmt.c
@@ -362,12 +362,9 @@ ps_fmt_clone (struct ps_fmt *fmt, struct ps_fmt **copy)
 
   if (!new || !fields || !src)
     {
-      if (new)
-       free (new);
-      if (fields)
-       free (fields);
-      if (src)
-       free (src);
+      free (new);
+      free (fields);
+      free (src);
       return ENOMEM;
     }
 
diff --git a/libps/proclist.c b/libps/proclist.c
index 50aed73..2201cad 100644
--- a/libps/proclist.c
+++ b/libps/proclist.c
@@ -63,10 +63,8 @@ proc_stat_list_clone (struct proc_stat_list *pp, struct 
proc_stat_list **copy)
 
   if (!new || !procs)
     {
-      if (new)
-       free (new);
-      if (procs)
-       free (procs);
+      free (new);
+      free (procs);
       return ENOMEM;
     }
 
diff --git a/libstore/mvol.c b/libstore/mvol.c
index d243cc8..ee1526b 100644
--- a/libstore/mvol.c
+++ b/libstore/mvol.c
@@ -148,8 +148,7 @@ store_mvol_create (struct store *phys,
 
       if (err)
        {
-         if (mv)
-           free (mv);
+         free (mv);
          store_free (*store);
        }
     }
diff --git a/nfs/ops.c b/nfs/ops.c
index afde0be..e0daae3 100644
--- a/nfs/ops.c
+++ b/nfs/ops.c
@@ -251,8 +251,7 @@ netfs_attempt_chmod (struct iouser *cred, struct node *np,
              np->nn->dtrans = SOCK;
              np->nn->stat_updated = 0;
            }
-         if (f)
-           free (f);
+         free (f);
          return 0;
        }
     }
diff --git a/proc/host.c b/proc/host.c
index 2506688..7d76f7c 100644
--- a/proc/host.c
+++ b/proc/host.c
@@ -113,8 +113,7 @@ S_proc_setexecdata (struct proc *p,
        mach_port_deallocate (mach_task_self (), std_port_array[i]);
       free (std_port_array);
     }
-  if (std_int_array)
-    free (std_int_array);
+  free (std_int_array);
 
   std_port_array = std_port_array_new;
   n_std_ports = nports;
diff --git a/sutils/fstab.c b/sutils/fstab.c
index 2e125d8..9748ae9 100644
--- a/sutils/fstab.c
+++ b/sutils/fstab.c
@@ -617,7 +617,7 @@ fstab_add_mntent (struct fstab *const fstab, const struct 
mntent *mntent,
     {
       if (! err)
        _fstab_add (fstab, fs);
-      else if (fs)
+      else
        free (fs);
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

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