summaryrefslogtreecommitdiff
path: root/usr.bin/less
diff options
context:
space:
mode:
authormmcc <mmcc@cvs.openbsd.org>2015-11-09 14:25:33 +0000
committermmcc <mmcc@cvs.openbsd.org>2015-11-09 14:25:33 +0000
commitc019bd6c06fb2b6a70e0dda837ec1346e416e395 (patch)
treecddb03d4effb9309489578418031c44c23592793 /usr.bin/less
parentf14a9ba0ac2b5f84f20415bae9199fd48b0ab259 (diff)
Remove NULL-checks before free(), a needless comment, and a needless
void* cast. ok nicm@
Diffstat (limited to 'usr.bin/less')
-rw-r--r--usr.bin/less/cmdbuf.c19
-rw-r--r--usr.bin/less/command.c3
-rw-r--r--usr.bin/less/line.c6
-rw-r--r--usr.bin/less/option.c3
-rw-r--r--usr.bin/less/search.c8
5 files changed, 13 insertions, 26 deletions
diff --git a/usr.bin/less/cmdbuf.c b/usr.bin/less/cmdbuf.c
index 32b8a233e6b..42815973bf8 100644
--- a/usr.bin/less/cmdbuf.c
+++ b/usr.bin/less/cmdbuf.c
@@ -918,13 +918,8 @@ init_compl(void)
char *word;
char c;
- /*
- * Get rid of any previous tk_text.
- */
- if (tk_text != NULL) {
- free(tk_text);
- tk_text = NULL;
- }
+ free(tk_text);
+ tk_text = NULL;
/*
* Find the original (uncompleted) word in the command buffer.
*/
@@ -939,8 +934,7 @@ init_compl(void)
/*
* Save the original (uncompleted) word
*/
- if (tk_original != NULL)
- free(tk_original);
+ free(tk_original);
tk_original = ecalloc(cp-word+1, sizeof (char));
(void) strncpy(tk_original, word, cp-word);
/*
@@ -954,12 +948,11 @@ init_compl(void)
tk_text = fcomplete(word);
} else {
char *qword = shell_quote(word+1);
- if (qword == NULL) {
+ if (qword == NULL)
tk_text = fcomplete(word+1);
- } else {
+ else
tk_text = fcomplete(qword);
- free(qword);
- }
+ free(qword);
}
*cp = c;
}
diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c
index fd53eb5e16b..25ec46e23c7 100644
--- a/usr.bin/less/command.c
+++ b/usr.bin/less/command.c
@@ -198,8 +198,7 @@ exec_mca(void)
*/
while (*cbuf == '+' || *cbuf == ' ')
cbuf++;
- if (every_first_cmd != NULL)
- free(every_first_cmd);
+ free(every_first_cmd);
if (*cbuf == '\0')
every_first_cmd = NULL;
else
diff --git a/usr.bin/less/line.c b/usr.bin/less/line.c
index e30d985248c..e2104edd8ad 100644
--- a/usr.bin/less/line.c
+++ b/usr.bin/less/line.c
@@ -98,10 +98,8 @@ expand_linebuf(void)
char *new_buf = realloc(linebuf, new_size);
char *new_attr = realloc(attr, new_size);
if (new_buf == NULL || new_attr == NULL) {
- if (new_attr != NULL)
- free(new_attr);
- if (new_buf != NULL)
- free(new_buf);
+ free(new_attr);
+ free(new_buf);
return (1);
}
linebuf = new_buf;
diff --git a/usr.bin/less/option.c b/usr.bin/less/option.c
index 7bae2b0b6c1..b0ea0dbcfe3 100644
--- a/usr.bin/less/option.c
+++ b/usr.bin/less/option.c
@@ -307,8 +307,7 @@ scan_option(char *s)
*/
if (o->ofunc != NULL)
(*o->ofunc)(INIT, str);
- if (str != NULL)
- free(str);
+ free(str);
}
}
diff --git a/usr.bin/less/search.c b/usr.bin/less/search.c
index 2745f5a4491..3675515dc8b 100644
--- a/usr.bin/less/search.c
+++ b/usr.bin/less/search.c
@@ -97,12 +97,10 @@ set_pattern(struct pattern_info *info, char *pattern, int search_type)
else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
return (-1);
/* Pattern compiled successfully; save the text too. */
- if (info->text != NULL)
- free(info->text);
+ free(info->text);
info->text = NULL;
- if (pattern != NULL) {
+ if (pattern != NULL)
info->text = estrdup(pattern);
- }
info->search_type = search_type;
/*
@@ -291,7 +289,7 @@ clr_hlist(struct hilite *anchor)
for (hl = anchor->hl_first; hl != NULL; hl = nexthl) {
nexthl = hl->hl_next;
- free((void*)hl);
+ free(hl);
}
anchor->hl_first = NULL;
prep_startpos = prep_endpos = -1;