From a7642eb44fa1028c0a752898bdefb0b9294f12b7 Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 9 Oct 2015 19:36:27 +0000 Subject: [PATCH] remove null check before afree. from Michael McConville --- bin/ksh/c_ksh.c | 11 ++++------- bin/ksh/edit.c | 5 ++--- bin/ksh/emacs.c | 5 ++--- bin/ksh/history.c | 5 ++--- bin/ksh/mail.c | 8 +++----- bin/ksh/trap.c | 5 ++--- bin/ksh/tree.c | 14 +++++--------- 7 files changed, 20 insertions(+), 33 deletions(-) diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c index 3f5fc13d4bd..efc7eadb64d 100644 --- a/bin/ksh/c_ksh.c +++ b/bin/ksh/c_ksh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ksh.c,v 1.42 2015/09/22 21:50:40 millert Exp $ */ +/* $OpenBSD: c_ksh.c,v 1.43 2015/10/09 19:36:27 tedu Exp $ */ /* * built-in Korn commands: c_* @@ -117,8 +117,7 @@ c_cd(char **wp) bi_errorf("%s: bad directory", dir); else bi_errorf("%s - %s", try, strerror(errno)); - if (fdir) - afree(fdir, ATEMP); + afree(fdir, ATEMP); return 1; } @@ -152,8 +151,7 @@ c_cd(char **wp) if (printpath || cdnode) shprintf("%s\n", pwd); - if (fdir) - afree(fdir, ATEMP); + afree(fdir, ATEMP); return 0; } @@ -195,8 +193,7 @@ c_pwd(char **wp) } } shprintf("%s\n", p); - if (freep) - afree(freep, ATEMP); + afree(freep, ATEMP); return 0; } diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c index 02a0b14d0a6..89f229aa99e 100644 --- a/bin/ksh/edit.c +++ b/bin/ksh/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.45 2015/09/26 23:49:37 nicm Exp $ */ +/* $OpenBSD: edit.c,v 1.46 2015/10/09 19:36:27 tedu Exp $ */ /* * Command line editing - common code @@ -672,8 +672,7 @@ x_free_words(int nwords, char **words) int i; for (i = 0; i < nwords; i++) - if (words[i]) - afree(words[i], ATEMP); + afree(words[i], ATEMP); afree(words, ATEMP); } diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c index 542f7c541b0..af067c84553 100644 --- a/bin/ksh/emacs.c +++ b/bin/ksh/emacs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emacs.c,v 1.53 2015/09/18 07:28:24 nicm Exp $ */ +/* $OpenBSD: emacs.c,v 1.54 2015/10/09 19:36:27 tedu Exp $ */ /* * Emacs-like command line editing and history @@ -1148,8 +1148,7 @@ static void x_push(int nchars) { char *cp = str_nsave(xcp, nchars, AEDIT); - if (killstack[killsp]) - afree(killstack[killsp], AEDIT); + afree(killstack[killsp], AEDIT); killstack[killsp] = cp; killsp = (killsp + 1) % KILLSIZE; } diff --git a/bin/ksh/history.c b/bin/ksh/history.c index 0cd976997eb..6207d26369e 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.46 2015/10/08 16:41:26 tedu Exp $ */ +/* $OpenBSD: history.c,v 1.47 2015/10/09 19:36:27 tedu Exp $ */ /* * command history @@ -862,8 +862,7 @@ histinsert(Source *s, int lno, unsigned char *line) if (lno >= s->line-(histptr-history) && lno <= s->line) { hp = &histptr[lno-s->line]; - if (*hp) - afree(*hp, APERM); + afree(*hp, APERM); *hp = str_save((char *)line, APERM); } } diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c index f4c9361ff6c..bfd6f90cf6f 100644 --- a/bin/ksh/mail.c +++ b/bin/ksh/mail.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mail.c,v 1.19 2015/09/17 14:21:33 nicm Exp $ */ +/* $OpenBSD: mail.c,v 1.20 2015/10/09 19:36:27 tedu Exp $ */ /* * Mailbox checking code by Robert J. Gibson, adapted for PD ksh by @@ -89,10 +89,8 @@ mbset(char *p) { struct stat stbuf; - if (mbox.mb_msg) - afree(mbox.mb_msg, APERM); - if (mbox.mb_path) - afree(mbox.mb_path, APERM); + afree(mbox.mb_msg, APERM); + afree(mbox.mb_path, APERM); /* Save a copy to protect from export (which munges the string) */ mbox.mb_path = str_save(p, APERM); mbox.mb_msg = NULL; diff --git a/bin/ksh/trap.c b/bin/ksh/trap.c index a3c94aea73d..0aafa2685d1 100644 --- a/bin/ksh/trap.c +++ b/bin/ksh/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.25 2015/09/18 07:28:24 nicm Exp $ */ +/* $OpenBSD: trap.c,v 1.26 2015/10/09 19:36:27 tedu Exp $ */ /* * signal handling @@ -282,8 +282,7 @@ settrap(Trap *p, char *s) { sig_t f; - if (p->trap) - afree(p->trap, APERM); + afree(p->trap, APERM); p->trap = str_save(s, APERM); /* handles s == 0 */ p->flags |= TF_CHANGED; f = !s ? SIG_DFL : s[0] ? trapsig : SIG_IGN; diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c index dba66d8b25b..bb728de106e 100644 --- a/bin/ksh/tree.c +++ b/bin/ksh/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.24 2015/09/27 05:25:00 guenther Exp $ */ +/* $OpenBSD: tree.c,v 1.25 2015/10/09 19:36:27 tedu Exp $ */ /* * command tree climbing @@ -657,8 +657,7 @@ tfree(struct op *t, Area *ap) if (t == NULL) return; - if (t->str != NULL) - afree(t->str, ap); + afree(t->str, ap); if (t->vars != NULL) { for (w = t->vars; *w != NULL; w++) @@ -688,12 +687,9 @@ iofree(struct ioword **iow, Area *ap) struct ioword *p; for (iop = iow; (p = *iop++) != NULL; ) { - if (p->name != NULL) - afree(p->name, ap); - if (p->delim != NULL) - afree(p->delim, ap); - if (p->heredoc != NULL) - afree(p->heredoc, ap); + afree(p->name, ap); + afree(p->delim, ap); + afree(p->heredoc, ap); afree(p, ap); } afree(iow, ap); -- 2.20.1