From: Vladimír Čunát Date: Wed, 19 Sep 2018 18:50:29 +0000 (+0200) Subject: daemon nitpick cleanups X-Git-Tag: v3.1.0~10^2~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96d7d11734aa9196338312e2337d15406c2f119b;p=thirdparty%2Fknot-resolver.git 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(). --- diff --git a/daemon/io.c b/daemon/io.c index c6d269c67..f82def923 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -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; diff --git a/daemon/session.c b/daemon/session.c index a5bdff280..5eccb6155 100644 --- a/daemon/session.c +++ b/daemon/session.c @@ -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); } diff --git a/daemon/worker.c b/daemon/worker.c index ac6e1086f..1fd30372f 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -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); }