summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authormmcc <mmcc@cvs.openbsd.org>2015-12-07 04:03:28 +0000
committermmcc <mmcc@cvs.openbsd.org>2015-12-07 04:03:28 +0000
commitdaf1998fedc9e84f9564e77db99863efc9bebde3 (patch)
treeb2941bfb141cec90c0b44056db23ddf32f4e4c62 /usr.sbin
parente709342834137631d444347dcf0a304d889da3a6 (diff)
Remove NULL-checks before free(). No functional change.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/relayd/agentx.c5
-rw-r--r--usr.sbin/relayd/config.c20
-rw-r--r--usr.sbin/relayd/relay.c20
-rw-r--r--usr.sbin/relayd/relay_http.c38
-rw-r--r--usr.sbin/relayd/relay_udp.c8
-rw-r--r--usr.sbin/relayd/relayd.c17
6 files changed, 38 insertions, 70 deletions
diff --git a/usr.sbin/relayd/agentx.c b/usr.sbin/relayd/agentx.c
index 59cc5b929eb..467a787f170 100644
--- a/usr.sbin/relayd/agentx.c
+++ b/usr.sbin/relayd/agentx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agentx.c,v 1.12 2015/07/19 01:08:07 blambert Exp $ */
+/* $OpenBSD: agentx.c,v 1.13 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2013,2014 Bret Stephen Lambert <blambert@openbsd.org>
*
@@ -246,8 +246,7 @@ void
snmp_agentx_pdu_free(struct agentx_pdu *pdu)
{
free(pdu->buffer);
- if (pdu->request)
- free(pdu->request);
+ free(pdu->request);
free(pdu);
}
diff --git a/usr.sbin/relayd/config.c b/usr.sbin/relayd/config.c
index 32852cf182b..a6afdc666f1 100644
--- a/usr.sbin/relayd/config.c
+++ b/usr.sbin/relayd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.26 2015/12/02 13:41:27 reyk Exp $ */
+/* $OpenBSD: config.c,v 1.27 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2011 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -178,10 +178,8 @@ config_purge(struct relayd *env, u_int reset)
if (what & CONFIG_PROTOS && env->sc_protos != NULL) {
while ((proto = TAILQ_FIRST(env->sc_protos)) != NULL) {
TAILQ_REMOVE(env->sc_protos, proto, entry);
- if (proto->style != NULL)
- free(proto->style);
- if (proto->tlscapass != NULL)
- free(proto->tlscapass);
+ free(proto->style);
+ free(proto->tlscapass);
free(proto);
}
env->sc_protocount = 0;
@@ -944,12 +942,9 @@ config_getrelay(struct relayd *env, struct imsg *imsg)
return (0);
fail:
- if (rlay->rl_tls_cert)
- free(rlay->rl_tls_cert);
- if (rlay->rl_tls_key)
- free(rlay->rl_tls_key);
- if (rlay->rl_tls_ca)
- free(rlay->rl_tls_ca);
+ free(rlay->rl_tls_cert);
+ free(rlay->rl_tls_key);
+ free(rlay->rl_tls_ca);
close(rlay->rl_s);
free(rlay);
return (-1);
@@ -993,7 +988,6 @@ config_getrelaytable(struct relayd *env, struct imsg *imsg)
return (0);
fail:
- if (rlt != NULL)
- free(rlt);
+ free(rlt);
return (-1);
}
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 255fb2bd5f3..13c253a011d 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.203 2015/12/05 20:58:32 benno Exp $ */
+/* $OpenBSD: relay.c,v 1.204 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1175,8 +1175,7 @@ relay_accept(int fd, short event, void *arg)
err:
if (s != -1) {
close(s);
- if (con != NULL)
- free(con);
+ free(con);
/*
* the session struct was not completly set up, but still
* counted as an inflight session. account for this.
@@ -1676,15 +1675,13 @@ relay_close(struct rsession *con, const char *msg)
con->se_tag != 0 ? tag_id2name(con->se_tag) : "0", ibuf,
obuf, ntohs(con->se_out.port), msg, ptr == NULL ? "" : ",",
ptr == NULL ? "" : ptr);
- if (ptr != NULL)
- free(ptr);
+ free(ptr);
}
if (proto->close != NULL)
(*proto->close)(con);
- if (con->se_priv != NULL)
- free(con->se_priv);
+ free(con->se_priv);
if (con->se_in.bev != NULL)
bufferevent_free(con->se_in.bev);
else if (con->se_in.output != NULL)
@@ -1709,8 +1706,7 @@ relay_close(struct rsession *con, const char *msg)
__func__, relay_inflight);
}
}
- if (con->se_in.buf != NULL)
- free(con->se_in.buf);
+ free(con->se_in.buf);
if (con->se_out.bev != NULL)
bufferevent_free(con->se_out.bev);
@@ -1735,8 +1731,7 @@ relay_close(struct rsession *con, const char *msg)
}
con->se_out.state = STATE_INIT;
- if (con->se_out.buf != NULL)
- free(con->se_out.buf);
+ free(con->se_out.buf);
if (con->se_log != NULL)
evbuffer_free(con->se_log);
@@ -2672,8 +2667,7 @@ relay_load_file(const char *name, off_t *len)
return (buf);
fail:
- if (buf != NULL)
- free(buf);
+ free(buf);
close(fd);
return (NULL);
}
diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c
index 20c3bf2ed7d..301248b32b9 100644
--- a/usr.sbin/relayd/relay_http.c
+++ b/usr.sbin/relayd/relay_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_http.c,v 1.53 2015/09/27 20:21:04 deraadt Exp $ */
+/* $OpenBSD: relay_http.c,v 1.54 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -126,26 +126,16 @@ relay_httpdesc_init(struct ctl_relay_event *cre)
void
relay_httpdesc_free(struct http_descriptor *desc)
{
- if (desc->http_path != NULL) {
- free(desc->http_path);
- desc->http_path = NULL;
- }
- if (desc->http_query != NULL) {
- free(desc->http_query);
- desc->http_query = NULL;
- }
- if (desc->http_version != NULL) {
- free(desc->http_version);
- desc->http_version = NULL;
- }
- if (desc->query_key != NULL) {
- free(desc->query_key);
- desc->query_key = NULL;
- }
- if (desc->query_val != NULL) {
- free(desc->query_val);
- desc->query_val = NULL;
- }
+ free(desc->http_path);
+ desc->http_path = NULL;
+ free(desc->http_query);
+ desc->http_query = NULL;
+ free(desc->http_version);
+ desc->http_version = NULL;
+ free(desc->query_key);
+ desc->query_key = NULL;
+ free(desc->query_val);
+ desc->query_val = NULL;
kv_purge(&desc->http_headers);
desc->http_lastheader = NULL;
}
@@ -610,8 +600,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
case 0:
/* Chunk is terminated by an empty newline */
line = evbuffer_readline(src);
- if (line != NULL)
- free(line);
+ free(line);
if (relay_bufferevent_print(cre->dst, "\r\n") == -1)
goto fail;
cre->toread = TOREAD_HTTP_CHUNK_LENGTH;
@@ -700,8 +689,7 @@ _relay_lookup_url(struct ctl_relay_event *cre, char *host, char *path,
ret = RES_PASS;
fail:
- if (md != NULL)
- free(md);
+ free(md);
free(val);
return (ret);
}
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index e4167eb352c..58894fd2c63 100644
--- a/usr.sbin/relayd/relay_udp.c
+++ b/usr.sbin/relayd/relay_udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_udp.c,v 1.41 2015/12/02 13:41:27 reyk Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.42 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org>
@@ -190,8 +190,7 @@ relay_udp_response(int fd, short sig, void *arg)
return;
relay_close(con, "unknown response");
- if (priv != NULL)
- free(priv);
+ free(priv);
}
void
@@ -289,8 +288,7 @@ relay_udp_server(int fd, short sig, void *arg)
/* Save the received data */
if (evbuffer_add(con->se_out.output, buf, len) == -1) {
relay_close(con, "failed to store buffer");
- if (cnl != NULL)
- free(cnl);
+ free(cnl);
return;
}
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index 97186aeac8f..7b2651d1588 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.149 2015/12/02 13:41:27 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.150 2015/12/07 04:03:27 mmcc Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -457,8 +457,7 @@ parent_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg)
if (IMSG_DATA_SIZE(imsg) > 0)
str = get_string(imsg->data, IMSG_DATA_SIZE(imsg));
parent_reload(env, CONFIG_RELOAD, str);
- if (str != NULL)
- free(str);
+ free(str);
break;
case IMSG_CTL_SHUTDOWN:
parent_shutdown(env);
@@ -572,8 +571,7 @@ purge_table(struct relayd *env, struct tablelist *head, struct table *table)
SSL_free(host->cte.ssl);
free(host);
}
- if (table->sendbuf != NULL)
- free(table->sendbuf);
+ free(table->sendbuf);
if (table->conf.flags & F_TLS)
SSL_CTX_free(table->ssl_ctx);
@@ -702,8 +700,7 @@ kv_set(struct kv *kv, char *fmt, ...)
}
/* Set the new value */
- if (kv->kv_value != NULL)
- free(kv->kv_value);
+ free(kv->kv_value);
kv->kv_value = value;
return (0);
@@ -720,8 +717,7 @@ kv_setkey(struct kv *kv, char *fmt, ...)
return (-1);
va_end(ap);
- if (kv->kv_key != NULL)
- free(kv->kv_key);
+ free(kv->kv_key);
kv->kv_key = key;
return (0);
@@ -933,8 +929,7 @@ rule_add(struct protocol *proto, struct relay_rule *rule, const char *rulefile)
kv = &r->rule_kv[i];
if (kv->kv_type != i)
continue;
- if (kv->kv_key != NULL)
- free(kv->kv_key);
+ free(kv->kv_key);
if ((kv->kv_key = strdup(buf)) == NULL) {
rule_free(r);
free(r);