diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-01-17 20:34:19 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-01-17 20:34:19 +0000 |
commit | c550c6f7d2211a3db203086791fc02c174b17d3b (patch) | |
tree | 244984a1746983cc35fde801a08510948c09cefb | |
parent | 21d70ac4990f24f15d9036fa33fac99902b91974 (diff) |
Remove unnecessary pointer casts. No binary diff.
OK benno@
-rw-r--r-- | usr.sbin/relayd/check_icmp.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/proc.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 63 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_http.c | 14 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_udp.c | 28 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/snmp.c | 6 |
7 files changed, 61 insertions, 64 deletions
diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c index 0c324e7b8e6..5c987e4bf35 100644 --- a/usr.sbin/relayd/check_icmp.c +++ b/usr.sbin/relayd/check_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_icmp.c,v 1.33 2012/09/19 09:49:24 reyk Exp $ */ +/* $OpenBSD: check_icmp.c,v 1.34 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -161,7 +161,7 @@ icmp_checks_timeout(struct ctl_icmp_event *cie, enum host_error he) void send_icmp(int s, short event, void *arg) { - struct ctl_icmp_event *cie = (struct ctl_icmp_event *)arg; + struct ctl_icmp_event *cie = arg; struct table *table; struct host *host; struct sockaddr *to; @@ -262,7 +262,7 @@ send_icmp(int s, short event, void *arg) void recv_icmp(int s, short event, void *arg) { - struct ctl_icmp_event *cie = (struct ctl_icmp_event *)arg; + struct ctl_icmp_event *cie = arg; u_char packet[ICMP_BUF_SIZE]; socklen_t slen; struct sockaddr_storage ss; diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 6bf51b384c4..60d8e87e0da 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.4 2012/10/04 20:53:30 reyk Exp $ */ +/* $OpenBSD: proc.c,v 1.5 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2010,2011 Reyk Floeter <reyk@openbsd.org> @@ -408,7 +408,7 @@ proc_run(struct privsep *ps, struct privsep_proc *p, void proc_dispatch(int fd, short event, void *arg) { - struct imsgev *iev = (struct imsgev *)arg; + struct imsgev *iev = arg; struct privsep_proc *p = iev->proc; struct privsep *ps = p->p_ps; struct imsgbuf *ibuf; diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index b56d90728a4..cc821a35587 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.160 2012/12/18 15:58:25 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.161 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2006 - 2012 Reyk Floeter <reyk@openbsd.org> @@ -607,8 +607,8 @@ relay_socket_listen(struct sockaddr_storage *ss, in_port_t port, void relay_connected(int fd, short sig, void *arg) { - struct rsession *con = (struct rsession *)arg; - struct relay *rlay = (struct relay *)con->se_relay; + struct rsession *con = arg; + struct relay *rlay = con->se_relay; struct protocol *proto = rlay->rl_proto; evbuffercb outrd = relay_read; evbuffercb outwr = relay_write; @@ -689,7 +689,7 @@ relay_connected(int fd, short sig, void *arg) void relay_input(struct rsession *con) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct protocol *proto = rlay->rl_proto; evbuffercb inrd = relay_read; evbuffercb inwr = relay_write; @@ -739,7 +739,7 @@ relay_input(struct rsession *con) void relay_write(struct bufferevent *bev, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; if (gettimeofday(&con->se_tv_last, NULL) == -1) con->se_done = 1; @@ -768,7 +768,7 @@ relay_dump(struct ctl_relay_event *cre, const void *buf, size_t len) void relay_read(struct bufferevent *bev, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; struct evbuffer *src = EVBUFFER_INPUT(bev); @@ -814,7 +814,7 @@ int relay_splice(struct ctl_relay_event *cre) { struct rsession *con = cre->con; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct protocol *proto = rlay->rl_proto; struct splice sp; @@ -862,7 +862,7 @@ relay_splicelen(struct ctl_relay_event *cre) void relay_error(struct bufferevent *bev, short error, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; struct evbuffer *dst; @@ -925,7 +925,7 @@ relay_error(struct bufferevent *bev, short error, void *arg) void relay_accept(int fd, short event, void *arg) { - struct relay *rlay = (struct relay *)arg; + struct relay *rlay = arg; struct protocol *proto = rlay->rl_proto; struct rsession *con = NULL; struct ctl_natlook *cnl = NULL; @@ -1033,8 +1033,7 @@ relay_accept(int fd, short event, void *arg) con->se_out.port == rlay->rl_conf.port) con->se_out.ss.ss_family = AF_UNSPEC; } else if (rlay->rl_conf.flags & F_NATLOOK) { - if ((cnl = (struct ctl_natlook *) - calloc(1, sizeof(struct ctl_natlook))) == NULL) { + if ((cnl = calloc(1, sizeof(*cnl))) == NULL) { relay_close(con, "failed to allocate nat lookup"); return; } @@ -1103,7 +1102,7 @@ relay_hash_addr(struct sockaddr_storage *ss, u_int32_t p) int relay_from_table(struct rsession *con) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct host *host; struct relay_table *rlt = NULL; struct table *table = NULL; @@ -1200,8 +1199,8 @@ relay_from_table(struct rsession *con) void relay_natlook(int fd, short event, void *arg) { - struct rsession *con = (struct rsession *)arg; - struct relay *rlay = (struct relay *)con->se_relay; + struct rsession *con = arg; + struct relay *rlay = con->se_relay; struct ctl_natlook *cnl = con->se_cnl; if (cnl == NULL) @@ -1226,7 +1225,7 @@ relay_natlook(int fd, short event, void *arg) void relay_session(struct rsession *con) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct ctl_relay_event *in = &con->se_in, *out = &con->se_out; if (bcmp(&rlay->rl_conf.ss, &out->ss, sizeof(out->ss)) == 0 && @@ -1267,7 +1266,7 @@ relay_session(struct rsession *con) void relay_bindanyreq(struct rsession *con, in_port_t port, int proto) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct ctl_bindany bnd; struct timeval tv; @@ -1289,7 +1288,7 @@ relay_bindanyreq(struct rsession *con, in_port_t port, int proto) void relay_bindany(int fd, short event, void *arg) { - struct rsession *con = (struct rsession *)arg; + struct rsession *con = arg; if (con->se_bnds == -1) { relay_close(con, "bindany failed, invalid socket"); @@ -1303,8 +1302,8 @@ void relay_connect_retry(int fd, short sig, void *arg) { struct timeval evtpause = { 1, 0 }; - struct rsession *con = (struct rsession *)arg; - struct relay *rlay = (struct relay *)con->se_relay; + struct rsession *con = arg; + struct relay *rlay = con->se_relay; int bnds = -1; if (relay_inflight < 1) @@ -1383,7 +1382,7 @@ relay_connect_retry(int fd, short sig, void *arg) int relay_connect(struct rsession *con) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct timeval evtpause = { 1, 0 }; int bnds = -1, ret; @@ -1472,7 +1471,7 @@ void relay_close(struct rsession *con, const char *msg) { char ibuf[128], obuf[128], *ptr = NULL; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; SPLAY_REMOVE(session_tree, &rlay->rl_sessions, con); @@ -1826,7 +1825,7 @@ relay_ssl_ctx_create(struct relay *rlay) void relay_ssl_transaction(struct rsession *con, struct ctl_relay_event *cre) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; SSL *ssl; const SSL_METHOD *method; void (*cb)(int, short, void *); @@ -1874,8 +1873,8 @@ relay_ssl_transaction(struct rsession *con, struct ctl_relay_event *cre) void relay_ssl_accept(int fd, short event, void *arg) { - struct rsession *con = (struct rsession *)arg; - struct relay *rlay = (struct relay *)con->se_relay; + struct rsession *con = arg; + struct relay *rlay = con->se_relay; int retry_flag = 0; int ssl_err = 0; int ret; @@ -1932,8 +1931,8 @@ retry: void relay_ssl_connect(int fd, short event, void *arg) { - struct rsession *con = (struct rsession *)arg; - struct relay *rlay = (struct relay *)con->se_relay; + struct rsession *con = arg; + struct relay *rlay = con->se_relay; int retry_flag = 0; int ssl_err = 0; int ret; @@ -2004,9 +2003,9 @@ relay_ssl_readcb(int fd, short event, void *arg) { char rbuf[IBUF_READ_SIZE]; struct bufferevent *bufev = arg; - struct ctl_relay_event *cre = (struct ctl_relay_event *)bufev->cbarg; + struct ctl_relay_event *cre = bufev->cbarg; struct rsession *con = cre->con; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; int ret = 0, ssl_err = 0; short what = EVBUFFER_READ; int howmuch = IBUF_READ_SIZE; @@ -2078,9 +2077,9 @@ void relay_ssl_writecb(int fd, short event, void *arg) { struct bufferevent *bufev = arg; - struct ctl_relay_event *cre = (struct ctl_relay_event *)bufev->cbarg; + struct ctl_relay_event *cre = bufev->cbarg; struct rsession *con = cre->con; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; int ret = 0, ssl_err; short what = EVBUFFER_WRITE; @@ -2272,7 +2271,7 @@ relay_load_file(const char *name, off_t *len) if (fstat(fd, &st) != 0) goto fail; size = st.st_size; - if ((buf = (char *)calloc(1, size + 1)) == NULL) + if ((buf = calloc(1, size + 1)) == NULL) goto fail; if (read(fd, buf, size) != size) goto fail; @@ -2355,7 +2354,7 @@ relay_proto_cmp(struct protonode *a, struct protonode *b) int relay_session_cmp(struct rsession *a, struct rsession *b) { - struct relay *rlay = (struct relay *)b->se_relay; + struct relay *rlay = b->se_relay; struct protocol *proto = rlay->rl_proto; if (proto != NULL && proto->cmp != NULL) diff --git a/usr.sbin/relayd/relay_http.c b/usr.sbin/relayd/relay_http.c index f2abf7d2e8c..4e6b82098ab 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.5 2012/11/27 05:00:28 guenther Exp $ */ +/* $OpenBSD: relay_http.c,v 1.6 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2006 - 2012 Reyk Floeter <reyk@openbsd.org> @@ -67,9 +67,9 @@ void relay_http_request_close(struct ctl_relay_event *); void relay_read_http(struct bufferevent *bev, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct protocol *proto = rlay->rl_proto; struct evbuffer *src = EVBUFFER_INPUT(bev); struct protonode *pn, pk, *proot, *pnv = NULL, pkv; @@ -382,7 +382,7 @@ relay_read_http(struct bufferevent *bev, void *arg) void relay_read_httpcontent(struct bufferevent *bev, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; struct evbuffer *src = EVBUFFER_INPUT(bev); size_t size; @@ -417,7 +417,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg) void relay_read_httpchunks(struct bufferevent *bev, void *arg) { - struct ctl_relay_event *cre = (struct ctl_relay_event *)arg; + struct ctl_relay_event *cre = arg; struct rsession *con = cre->con; struct evbuffer *src = EVBUFFER_INPUT(bev); char *line; @@ -762,7 +762,7 @@ void relay_abort_http(struct rsession *con, u_int code, const char *msg, u_int16_t labelid) { - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; struct bufferevent *bev = con->se_in.bev; const char *httperr = print_httperror(code), *text = ""; char *httpmsg; @@ -847,7 +847,7 @@ char * relay_expand_http(struct ctl_relay_event *cre, char *val, char *buf, size_t len) { struct rsession *con = cre->con; - struct relay *rlay = (struct relay *)con->se_relay; + struct relay *rlay = con->se_relay; char ibuf[128]; (void)strlcpy(buf, val, len); diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c index 522b918e907..75a53cdc56f 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.26 2012/12/18 15:36:43 reyk Exp $ */ +/* $OpenBSD: relay_udp.c,v 1.27 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -172,7 +172,7 @@ relay_udp_socket(struct sockaddr_storage *ss, in_port_t port, void relay_udp_response(int fd, short sig, void *arg) { - struct rsession *con = (struct rsession *)arg; + struct rsession *con = arg; struct relay *rlay = con->se_relay; struct protocol *proto = rlay->rl_proto; void *priv = NULL; @@ -208,7 +208,7 @@ relay_udp_response(int fd, short sig, void *arg) void relay_udp_server(int fd, short sig, void *arg) { - struct relay *rlay = (struct relay *)arg; + struct relay *rlay = arg; struct protocol *proto = rlay->rl_proto; struct rsession *con = NULL; struct ctl_natlook *cnl = NULL; @@ -232,8 +232,7 @@ relay_udp_server(int fd, short sig, void *arg) (priv = (*proto->validate)(NULL, rlay, &ss, buf, len)) == NULL) return; - if ((con = (struct rsession *) - calloc(1, sizeof(struct rsession))) == NULL) { + if ((con = calloc(1, sizeof(*con))) == NULL) { free(priv); return; } @@ -295,8 +294,7 @@ relay_udp_server(int fd, short sig, void *arg) } if (rlay->rl_conf.flags & F_NATLOOK) { - if ((cnl = (struct ctl_natlook *) - calloc(1, sizeof(struct ctl_natlook))) == NULL) { + if ((cnl = calloc(1, sizeof(*cnl))) == NULL) { relay_close(con, "failed to allocate natlookup"); return; } @@ -335,7 +333,7 @@ relay_udp_server(int fd, short sig, void *arg) void relay_udp_timeout(int fd, short sig, void *arg) { - struct rsession *con = (struct rsession *)arg; + struct rsession *con = arg; if (sig != EV_TIMEOUT) fatalx("invalid timeout event"); @@ -441,7 +439,7 @@ relay_dns_validate(struct rsession *con, struct relay *rlay, relay_cmp_af(ss, &con->se_out.ss) == 0) relay_dns_result(con, buf, len); } else { - priv = (struct relay_dns_priv *)con->se_priv; + priv = con->se_priv; if (priv == NULL || key != priv->dp_inkey) { relay_close(con, "invalid response"); return (NULL); @@ -458,8 +456,8 @@ relay_dns_validate(struct rsession *con, struct relay *rlay, int relay_dns_request(struct rsession *con) { - struct relay *rlay = (struct relay *)con->se_relay; - struct relay_dns_priv *priv = (struct relay_dns_priv *)con->se_priv; + struct relay *rlay = con->se_relay; + struct relay_dns_priv *priv = con->se_priv; u_int8_t *buf = EVBUFFER_DATA(con->se_out.output); size_t len = EVBUFFER_LENGTH(con->se_out.output); struct relay_dnshdr *hdr; @@ -515,8 +513,8 @@ relay_dns_request(struct rsession *con) void relay_dns_result(struct rsession *con, u_int8_t *buf, size_t len) { - struct relay *rlay = (struct relay *)con->se_relay; - struct relay_dns_priv *priv = (struct relay_dns_priv *)con->se_priv; + struct relay *rlay = con->se_relay; + struct relay_dns_priv *priv = con->se_priv; struct relay_dnshdr *hdr; socklen_t slen; @@ -545,8 +543,8 @@ relay_dns_result(struct rsession *con, u_int8_t *buf, size_t len) int relay_dns_cmp(struct rsession *a, struct rsession *b) { - struct relay_dns_priv *ap = (struct relay_dns_priv *)a->se_priv; - struct relay_dns_priv *bp = (struct relay_dns_priv *)b->se_priv; + struct relay_dns_priv *ap = a->se_priv; + struct relay_dns_priv *bp = b->se_priv; if (ap == NULL || bp == NULL) fatalx("relay_dns_cmp: invalid session"); diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index 6f5c14d9ae6..19d30d7f904 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.114 2012/12/18 15:41:44 reyk Exp $ */ +/* $OpenBSD: relayd.c,v 1.115 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -950,7 +950,7 @@ protonode_header(enum direction dir, struct protocol *proto, pn = RB_FIND(proto_tree, tree, pk); if (pn != NULL) return (pn); - if ((pn = (struct protonode *)calloc(1, sizeof(*pn))) == NULL) { + if ((pn = calloc(1, sizeof(*pn))) == NULL) { log_warn("%s: calloc", __func__); return (NULL); } diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c index 0be528d8006..c426e14b51e 100644 --- a/usr.sbin/relayd/snmp.c +++ b/usr.sbin/relayd/snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmp.c,v 1.12 2012/02/01 19:24:46 camield Exp $ */ +/* $OpenBSD: snmp.c,v 1.13 2013/01/17 20:34:18 bluhm Exp $ */ /* * Copyright (c) 2008 Reyk Floeter <reyk@openbsd.org> @@ -111,8 +111,8 @@ snmp_getsock(struct relayd *env, struct imsg *imsg) env->sc_snmp = imsg->fd; log_debug("%s: got new snmp socket %d", __func__, imsg->fd); - if (iev_snmp == NULL && (iev_snmp = (struct imsgev *) - calloc(1, sizeof(struct imsgev))) == NULL) + if (iev_snmp == NULL && + (iev_snmp = calloc(1, sizeof(*iev_snmp))) == NULL) fatal("snmp_getsock: calloc"); imsg_init(&iev_snmp->ibuf, env->sc_snmp); |