daemon nitpick cleanups

- Some (potentially) unused vars were left behind.
- The two on_* functions are identical except for the uv types passed,
  and those are surely the same in the part we use, but it's not worth
  to deduplicate when these functions are only two and so simple.
- lint:c was complaining about the uv_tcp_t malloc().
parent 1832456d
......@@ -98,7 +98,7 @@ void udp_recv(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf,
}
ssize_t consumed = session_wirebuf_consume(s, (const uint8_t *)buf->base,
nread);
assert(consumed == nread);
assert(consumed == nread); (void)consumed;
session_wirebuf_process(s);
session_wirebuf_discard(s);
mp_flush(worker->pkt_pool.ctx);
......@@ -234,7 +234,7 @@ static void _tcp_accept(uv_stream_t *master, int status, bool tls)
}
struct worker_ctx *worker = (struct worker_ctx *)master->loop->data;
uv_stream_t *client = malloc(sizeof(uv_tcp_t));
uv_tcp_t *client = malloc(sizeof(uv_tcp_t));
if (!client) {
return;
}
......@@ -255,7 +255,7 @@ static void _tcp_accept(uv_stream_t *master, int status, bool tls)
struct session *session = client->data;
assert(session_flags(session)->outgoing == false);
if (uv_accept(master, client) != 0) {
if (uv_accept(master, (uv_stream_t *)client) != 0) {
/* close session, close underlying uv handles and
* deallocate (or return to memory pool) memory. */
session_close(session);
......@@ -270,7 +270,7 @@ static void _tcp_accept(uv_stream_t *master, int status, bool tls)
struct sockaddr *peer = session_get_peer(s);
int peer_len = sizeof(union inaddr);
int ret = uv_tcp_getpeername((uv_tcp_t *)client, peer, &peer_len);
int ret = uv_tcp_getpeername(client, peer, &peer_len);
if (ret || peer->sa_family == AF_UNSPEC) {
session_close(s);
return;
......
......@@ -36,7 +36,7 @@ struct session {
static void on_session_close(uv_handle_t *handle)
{
struct session *session = handle->data;
assert(session->handle == handle);
assert(session->handle == handle); (void)session;
io_free(handle);
}
......
......@@ -625,20 +625,15 @@ static int qr_task_on_send(struct qr_task *task, uv_handle_t *handle, int status
static void on_send(uv_udp_send_t *req, int status)
{
uv_handle_t *handle = (uv_handle_t *)(req->handle);
uv_loop_t *loop = handle->loop;
struct qr_task *task = req->data;
qr_task_on_send(task, handle, status);
qr_task_on_send(task, (uv_handle_t *)(req->handle), status);
qr_task_unref(task);
free(req);
}
// TODO: unify these two
static void on_task_write(uv_write_t *req, int status)
{
uv_handle_t *handle = (uv_handle_t *)(req->handle);
uv_loop_t *loop = handle->loop;
struct qr_task *task = req->data;
qr_task_on_send(task, handle, status);
qr_task_on_send(task, (uv_handle_t *)(req->handle), status);
qr_task_unref(task);
free(req);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment