[PATCH 1/2] losetup, agetty: remove unnecessary if's before free()

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

 



Reference: http://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/useless-if-before-free
Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/losetup.c | 6 ++----
 term-utils/agetty.c | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 5be3288..70d9155 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -184,8 +184,7 @@ static int show_all_loops(struct loopdev_cxt *lc, const char *file,
 		printf_loopdev(lc);
 	}
 	loopcxt_deinit_iterator(lc);
-	if (cn_file)
-		free(cn_file);
+	free(cn_file);
 	return 0;
 }
 
@@ -351,8 +350,7 @@ static int make_table(struct loopdev_cxt *lc,
 	}
 
 	loopcxt_deinit_iterator(lc);
-	if (cn_file)
-		free(cn_file);
+	free(cn_file);
 	return 0;
 }
 
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 113f8e7..b162e9f 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -466,8 +466,7 @@ int main(int argc, char **argv)
 			log_warn(_("%s: can't change process priority: %m"),
 				options.tty);
 	}
-	if (options.osrelease)
-		free(options.osrelease);
+	free(options.osrelease);
 #ifdef DEBUGGING
 	fprintf(dbf, "read %c\n", ch);
 	if (close_stream(dbf) != 0)
@@ -1383,8 +1382,7 @@ static char *read_os_release(struct options *op, const char *varname)
 			}
 			break;
 		}
-		if (ret)
-			free(ret);
+		free(ret);
 		ret = strdup(p);
 		if (!ret)
 			log_err(_("failed to allocate memory: %m"));
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux