diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-05-29 15:57:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-05-29 15:57:37 +0000 |
commit | 81aac03c9f7b7ab48ad14f11ef566a34086d1842 (patch) | |
tree | 51529789db97c31f1469d603937e794ddf850c53 /sbin | |
parent | f1252549b821fefcd252fbb69b7ab3d4180a377d (diff) |
do not need non-NULL-check before free(p), other minor refactoring
from Benjamin Baier
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck/fsck.c | 10 | ||||
-rw-r--r-- | sbin/fsck/fsutil.c | 9 |
2 files changed, 9 insertions, 10 deletions
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 2e12254bf89..51bb4b3d41c 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.c,v 1.36 2015/05/29 15:53:46 deraadt Exp $ */ +/* $OpenBSD: fsck.c,v 1.37 2015/05/29 15:57:36 deraadt Exp $ */ /* $NetBSD: fsck.c,v 1.7 1996/10/03 20:06:30 christos Exp $ */ /* @@ -287,8 +287,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg, switch (pid = fork()) { case -1: /* Error. */ warn("fork"); - if (optbuf) - free(optbuf); + free(optbuf); free(argv); return (1); @@ -320,8 +319,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg, /* NOTREACHED */ default: /* Parent. */ - if (optbuf) - free(optbuf); + free(optbuf); free(argv); if (pidp) { @@ -439,7 +437,7 @@ catopt(char *s0, const char *s1, int fr) } else cp = estrdup(s1); - if (s0 && fr) + if (fr) free(s0); return (cp); } diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index e18335d1a95..703872b5f78 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */ +/* $OpenBSD: fsutil.c,v 1.21 2015/05/29 15:57:36 deraadt Exp $ */ /* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */ /* @@ -252,12 +252,13 @@ ereallocarray(void *p, size_t n, size_t s) { void *newp; - if (s == 0) + if (n == 0 || s == 0) { + free(p); err(1, "realloc failed"); + } newp = reallocarray(p, n, s); if (newp == NULL) { - if (p) - free(p); + free(p); err(1, "realloc failed"); } return newp; |