{
/* Decode parameters */
uint8_t namespace = 'R';
- char *extra = (char *)strchr(args, ' ');
+ char *extra = strchr(args, ' ');
if (extra != NULL) {
extra[0] = '\0';
namespace = extra[1];
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)
p = strchr(addr, '#');
}
if (p) {
- *port = atoi(p + 1);
+ *port = strtol(p + 1, NULL, 10);
*p = '\0';
}
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);
{
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);
}
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);
}
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);
}
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);
}
}
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);
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);
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) {
* 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);
}