summaryrefslogtreecommitdiff
path: root/usr.bin/vi/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/vi/common')
-rw-r--r--usr.bin/vi/common/cut.c5
-rw-r--r--usr.bin/vi/common/exf.c34
-rw-r--r--usr.bin/vi/common/key.c5
-rw-r--r--usr.bin/vi/common/log.c8
-rw-r--r--usr.bin/vi/common/main.c14
-rw-r--r--usr.bin/vi/common/options.c8
-rw-r--r--usr.bin/vi/common/screen.c17
-rw-r--r--usr.bin/vi/common/seq.c23
8 files changed, 41 insertions, 73 deletions
diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c
index 78eab40cd11..7ed134693a5 100644
--- a/usr.bin/vi/common/cut.c
+++ b/usr.bin/vi/common/cut.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cut.c,v 1.16 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: cut.c,v 1.17 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -343,7 +343,6 @@ text_lfree(TEXTH *headp)
void
text_free(TEXT *tp)
{
- if (tp->lb != NULL)
- free(tp->lb);
+ free(tp->lb);
free(tp);
}
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index 619a80ff128..b78dd367847 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exf.c,v 1.44 2016/08/01 18:27:35 bentley Exp $ */
+/* $OpenBSD: exf.c,v 1.45 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -76,8 +76,7 @@ file_add(SCR *sp, CHAR_T *name)
TAILQ_FOREACH_SAFE(frp, &gp->frefq, q, tfrp) {
if (frp->name == NULL) {
TAILQ_REMOVE(&gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
continue;
}
@@ -197,8 +196,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
F_SET(frp, FR_TMPFILE);
if ((frp->tname = strdup(tname)) == NULL ||
(frp->name == NULL && (frp->name = strdup(tname)) == NULL)) {
- if (frp->tname != NULL)
- free(frp->tname);
+ free(frp->tname);
msgq(sp, M_SYSERR, NULL);
(void)unlink(tname);
goto err;
@@ -410,10 +408,9 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
return (0);
-err: if (frp->name != NULL) {
- free(frp->name);
- frp->name = NULL;
- }
+err:
+ free(frp->name);
+ frp->name = NULL;
if (frp->tname != NULL) {
(void)unlink(frp->tname);
free(frp->tname);
@@ -422,10 +419,8 @@ err: if (frp->name != NULL) {
oerr: if (F_ISSET(ep, F_RCV_ON))
(void)unlink(ep->rcv_path);
- if (ep->rcv_path != NULL) {
- free(ep->rcv_path);
- ep->rcv_path = NULL;
- }
+ free(ep->rcv_path);
+ ep->rcv_path = NULL;
if (ep->db != NULL)
(void)ep->db->close(ep->db);
free(ep);
@@ -659,8 +654,7 @@ file_end(SCR *sp, EXF *ep, int force)
frp->tname = NULL;
if (F_ISSET(frp, FR_TMPFILE)) {
TAILQ_REMOVE(&sp->gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
}
sp->frp = NULL;
@@ -704,11 +698,8 @@ file_end(SCR *sp, EXF *ep, int force)
(void)close(ep->fcntl_fd);
if (ep->rcv_fd != -1)
(void)close(ep->rcv_fd);
- if (ep->rcv_path != NULL)
- free(ep->rcv_path);
- if (ep->rcv_mpath != NULL)
- free(ep->rcv_mpath);
-
+ free(ep->rcv_path);
+ free(ep->rcv_mpath);
free(ep);
return (0);
}
@@ -1358,8 +1349,7 @@ file_aw(SCR *sp, int flags)
void
set_alt_name(SCR *sp, char *name)
{
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
if (name == NULL)
sp->alt_name = NULL;
else if ((sp->alt_name = strdup(name)) == NULL)
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index 08369cf400c..e3a85e2e7f7 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.18 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: key.c,v 1.19 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -770,8 +770,7 @@ v_event_err(SCR *sp, EVENT *evp)
}
/* Free any allocated memory. */
- if (evp->e_asp != NULL)
- free(evp->e_asp);
+ free(evp->e_asp);
}
/*
diff --git a/usr.bin/vi/common/log.c b/usr.bin/vi/common/log.c
index 83f79d0776c..22bb065d3a6 100644
--- a/usr.bin/vi/common/log.c
+++ b/usr.bin/vi/common/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.11 2017/01/20 00:55:52 krw Exp $ */
+/* $OpenBSD: log.c,v 1.12 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -124,10 +124,8 @@ log_end(SCR *sp, EXF *ep)
(void)(ep->log->close)(ep->log);
ep->log = NULL;
}
- if (ep->l_lp != NULL) {
- free(ep->l_lp);
- ep->l_lp = NULL;
- }
+ free(ep->l_lp);
+ ep->l_lp = NULL;
ep->l_len = 0;
ep->l_cursor.lno = 1; /* XXX Any valid recno. */
ep->l_cursor.cno = 0;
diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c
index f20e4fde002..8b105d2a95d 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.38 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: main.c,v 1.39 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -470,17 +470,14 @@ v_end(GS *gp)
/* Free FREF's. */
while ((frp = TAILQ_FIRST(&gp->frefq))) {
TAILQ_REMOVE(&gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
- if (frp->tname != NULL)
- free(frp->tname);
+ free(frp->name);
+ free(frp->tname);
free(frp);
}
}
/* Free key input queue. */
- if (gp->i_event != NULL)
- free(gp->i_event);
+ free(gp->i_event);
/* Free cut buffers. */
cut_close(gp);
@@ -514,8 +511,7 @@ v_end(GS *gp)
#if defined(DEBUG) || defined(PURIFY)
/* Free any temporary space. */
- if (gp->tmp_bp != NULL)
- free(gp->tmp_bp);
+ free(gp->tmp_bp);
#if defined(DEBUG)
/* Close debugging file descriptor. */
diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c
index a4cd43604b3..15c9e3b5999 100644
--- a/usr.bin/vi/common/options.c
+++ b/usr.bin/vi/common/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.22 2016/08/01 18:27:35 bentley Exp $ */
+/* $OpenBSD: options.c,v 1.23 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -1129,9 +1129,7 @@ opts_free(SCR *sp)
if (optlist[cnt].type != OPT_STR ||
F_ISSET(&optlist[cnt], OPT_GLOBAL))
continue;
- if (O_STR(sp, cnt) != NULL)
- free(O_STR(sp, cnt));
- if (O_D_STR(sp, cnt) != NULL)
- free(O_D_STR(sp, cnt));
+ free(O_STR(sp, cnt));
+ free(O_D_STR(sp, cnt));
}
}
diff --git a/usr.bin/vi/common/screen.c b/usr.bin/vi/common/screen.c
index 701b87c2c25..a9d0a9833e2 100644
--- a/usr.bin/vi/common/screen.c
+++ b/usr.bin/vi/common/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.13 2015/12/07 20:39:19 mmcc Exp $ */
+/* $OpenBSD: screen.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -176,22 +176,17 @@ screen_end(SCR *sp)
text_lfree(&sp->tiq);
/* Free alternate file name. */
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
/* Free up search information. */
- if (sp->re != NULL)
- free(sp->re);
+ free(sp->re);
if (F_ISSET(sp, SC_RE_SEARCH))
regfree(&sp->re_c);
- if (sp->subre != NULL)
- free(sp->subre);
+ free(sp->subre);
if (F_ISSET(sp, SC_RE_SUBST))
regfree(&sp->subre_c);
- if (sp->repl != NULL)
- free(sp->repl);
- if (sp->newl != NULL)
- free(sp->newl);
+ free(sp->repl);
+ free(sp->newl);
/* Free all the options */
opts_free(sp);
diff --git a/usr.bin/vi/common/seq.c b/usr.bin/vi/common/seq.c
index 50cfda28a20..a9048a7e97c 100644
--- a/usr.bin/vi/common/seq.c
+++ b/usr.bin/vi/common/seq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: seq.c,v 1.13 2016/05/27 09:18:11 martijn Exp $ */
+/* $OpenBSD: seq.c,v 1.14 2017/04/18 01:45:35 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -58,8 +58,7 @@ seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen,
sv_errno = errno;
goto mem1;
}
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->output);
qp->olen = olen;
qp->output = p;
return (0);
@@ -95,8 +94,7 @@ seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen,
} else if ((qp->output = v_strdup(sp, output, olen)) == NULL) {
sv_errno = errno;
free(qp->input);
-mem3: if (qp->name != NULL)
- free(qp->name);
+mem3: free(qp->name);
mem2: free(qp);
mem1: errno = sv_errno;
msgq(sp, M_SYSERR, NULL);
@@ -148,11 +146,9 @@ int
seq_mdel(SEQ *qp)
{
LIST_REMOVE(qp, q);
- if (qp->name != NULL)
- free(qp->name);
+ free(qp->name);
free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->output);
free(qp);
return (0);
}
@@ -250,12 +246,9 @@ seq_close(GS *gp)
SEQ *qp;
while ((qp = LIST_FIRST(&gp->seqq)) != NULL) {
- if (qp->name != NULL)
- free(qp->name);
- if (qp->input != NULL)
- free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->name);
+ free(qp->input);
+ free(qp->output);
LIST_REMOVE(qp, q);
free(qp);
}