diff options
author | Justus Winter <justus@gnupg.org> | 2017-08-05 19:28:38 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-08-05 19:34:28 +0200 |
commit | 66553fd7a7bcf7c260b45f2e7ad54e98d33f8080 (patch) | |
tree | 154a543b44a17302b6618cb9c80d7e6b66703216 | |
parent | 835b293d35a209d38047126443d41fa7090daa4c (diff) | |
download | hurd-66553fd7a7bcf7c260b45f2e7ad54e98d33f8080.tar.gz hurd-66553fd7a7bcf7c260b45f2e7ad54e98d33f8080.tar.bz2 hurd-66553fd7a7bcf7c260b45f2e7ad54e98d33f8080.zip |
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.
-rw-r--r-- | console-client/console.c | 3 | ||||
-rw-r--r-- | console-client/driver.c | 6 | ||||
-rw-r--r-- | console-client/vga.c | 12 | ||||
-rw-r--r-- | ftpfs/dir.c | 3 | ||||
-rw-r--r-- | libftpconn/unix.c | 9 | ||||
-rw-r--r-- | libps/fmt.c | 9 | ||||
-rw-r--r-- | libps/proclist.c | 6 | ||||
-rw-r--r-- | libstore/mvol.c | 3 | ||||
-rw-r--r-- | nfs/ops.c | 3 | ||||
-rw-r--r-- | proc/host.c | 3 | ||||
-rw-r--r-- | sutils/fstab.c | 2 |
11 files changed, 20 insertions, 39 deletions
diff --git a/console-client/console.c b/console-client/console.c index 5335156b..3b316115 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 7a55bbe4..b4a03ab8 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 9d751a7f..e954013d 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 44c85509..72b1a46b 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 882fee8f..2804e7c4 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 cd838852..46416632 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 50aed73a..2201cadc 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 d243cc8a..ee1526be 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); } } @@ -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 25066888..7d76f7cb 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 2e125d8d..9748ae9b 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); } |