From 66553fd7a7bcf7c260b45f2e7ad54e98d33f8080 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Sat, 5 Aug 2017 19:28:38 +0200 Subject: 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. --- libps/fmt.c | 9 +++------ libps/proclist.c | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'libps') 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; } -- cgit v1.2.3