From: Marek VavrusÌŒa Date: Fri, 12 Jan 2018 06:15:16 +0000 (-0800) Subject: daemon: fixed minor linter problems X-Git-Tag: v2.0.0~36^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97449691ca166d5bce176ae056b7364a2d2be876;p=thirdparty%2Fknot-resolver.git daemon: fixed minor linter problems --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 9da34be01..9da6f0f56 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -913,7 +913,7 @@ static int cache_prefixed(struct kr_cache *cache, const char *args, knot_db_val_ { /* Decode parameters */ uint8_t namespace = 'R'; - char *extra = (char *)strchr(args, ' '); + char *extra = strchr(args, ' '); if (extra != NULL) { extra[0] = '\0'; namespace = extra[1]; diff --git a/daemon/io.c b/daemon/io.c index d8a6efb9e..64de774c2 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -170,14 +170,14 @@ void udp_recv(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, static int udp_bind_finalize(uv_handle_t *handle) { - check_bufsize((uv_handle_t *)handle); + check_bufsize(handle); /* Handle is already created, just create context. */ struct session *session = session_new(); assert(session); session->outgoing = false; session->handle = handle; handle->data = session; - return io_start_read((uv_handle_t *)handle); + return io_start_read(handle); } int udp_bind(uv_udp_t *handle, struct sockaddr *addr) diff --git a/daemon/main.c b/daemon/main.c index 3f22a28d1..916fcf381 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -295,7 +295,7 @@ static const char *set_addr(char *addr, int *port) p = strchr(addr, '#'); } if (p) { - *port = atoi(p + 1); + *port = strtol(p + 1, NULL, 10); *p = '\0'; } @@ -465,17 +465,17 @@ int main(int argc, char **argv) array_push(tls_set, optarg); break; case 'S': - array_push(fd_set, atoi(optarg)); + array_push(fd_set, strtol(optarg, NULL, 10)); break; case 'T': - array_push(tls_fd_set, atoi(optarg)); + array_push(tls_fd_set, strtol(optarg, NULL, 10)); break; case 'c': config = optarg; break; case 'f': g_interactive = false; - forks = atoi(optarg); + forks = strtol(optarg, NULL, 10); if (forks <= 0) { kr_log_error("[system] error '-f' requires a positive" " number, not '%s'\n", optarg); diff --git a/daemon/network.c b/daemon/network.c index ff8004bae..c9adbd231 100644 --- a/daemon/network.c +++ b/daemon/network.c @@ -140,7 +140,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad { int ret = 0; if (flags & NET_UDP) { - ep->udp = malloc(sizeof(uv_handles_t)); + ep->udp = malloc(sizeof(*ep->udp)); if (!ep->udp) { return kr_error(ENOMEM); } @@ -153,7 +153,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad ep->flags |= NET_UDP; } if (flags & NET_TCP) { - ep->tcp = malloc(sizeof(uv_handles_t)); + ep->tcp = malloc(sizeof(*ep->tcp)); if (!ep->tcp) { return kr_error(ENOMEM); } @@ -185,7 +185,7 @@ static int open_endpoint_fd(struct network *net, struct endpoint *ep, int fd, in if (ep->udp) { return kr_error(EEXIST); } - ep->udp = malloc(sizeof(uv_handles_t));// malloc(sizeof(*ep->udp)); + ep->udp = malloc(sizeof(*ep->udp)); if (!ep->udp) { return kr_error(ENOMEM); } @@ -201,7 +201,7 @@ static int open_endpoint_fd(struct network *net, struct endpoint *ep, int fd, in if (ep->tcp) { return kr_error(EEXIST); } - ep->tcp = malloc(sizeof(uv_handles_t)); + ep->tcp = malloc(sizeof(*ep->tcp)); if (!ep->tcp) { return kr_error(ENOMEM); } diff --git a/daemon/worker.c b/daemon/worker.c index 0569d3b61..34c55d4a5 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -820,8 +820,7 @@ static int qr_task_on_send(struct qr_task *task, uv_handle_t *handle, int status } if (session->waiting.len > 0) { struct qr_task *t = session->waiting.at[0]; - int ret = qr_task_send(t, (uv_handle_t *)handle, - &session->peer.ip, t->pktbuf); + int ret = qr_task_send(t, handle, &session->peer.ip, t->pktbuf); if (ret == kr_ok()) { uv_timer_t *timer = &session->timeout; uv_timer_stop(timer); @@ -1055,7 +1054,7 @@ static void on_connect(uv_connect_t *req, int status) struct session *session = handle->data; union inaddr *peer = &session->peer; - uv_timer_stop((uv_timer_t *)&session->timeout); + uv_timer_stop(&session->timeout); if (status == UV_ECANCELED) { worker_del_tcp_waiting(worker, &peer->ip); @@ -1308,7 +1307,7 @@ static void on_retransmit(uv_timer_t *req) static int timer_start(struct session *session, uv_timer_cb cb, uint64_t timeout, uint64_t repeat) { - uv_timer_t *timer = (uv_timer_t *)&session->timeout; + uv_timer_t *timer = &session->timeout; assert(timer->data == session); int ret = uv_timer_start(timer, cb, timeout, repeat); if (ret != 0) { @@ -1863,7 +1862,7 @@ int worker_end_tcp(struct worker_ctx *worker, uv_handle_t *handle) * borrowed the task from parent session. */ struct session *session = handle->data; if (session->outgoing) { - worker_submit(worker, (uv_handle_t *)handle, NULL, NULL); + worker_submit(worker, handle, NULL, NULL); } else { discard_buffered(session); }