]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon nitpick cleanups
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 19 Sep 2018 18:50:29 +0000 (20:50 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 12 Oct 2018 15:36:44 +0000 (17:36 +0200)
- 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().

daemon/io.c
daemon/session.c
daemon/worker.c

index c6d269c672a4f81f28ebac403ec8870a895d5f70..f82def9231c9267256295140e7608b7736b20cb1 100644 (file)
@@ -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;
index a5bdff28075a07c8d2bf5390a7eaeb2f3823f2a1..5eccb615586216f2034f12cb56d8302e9849377e 100644 (file)
@@ -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);
 }
 
index ac6e1086f7f9fba2b2c791d2636c1d6b5398af1f..1fd30372f96a28a2c4ee1902d5f5c22cb7b2794d 100644 (file)
@@ -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);
 }