Commit d49a2ccb authored by Max Kellermann's avatar Max Kellermann

ntp_server: fix socket types

Cast recvfrom(), sendto() buffers to "void*" to avoid "char*" / "unsigned char*" confusion. Use ssize_t for the return value, and socklen_t for the socket address size.
parent 4a75acb4
......@@ -81,8 +81,9 @@ ntp_server_handle(struct ntp_server *ntp)
unsigned char buf[32];
struct sockaddr addr;
int iter;
unsigned int addr_len = sizeof(addr);
int num_bytes = recvfrom(ntp->fd, buf, sizeof(buf), 0, &addr, &addr_len);
socklen_t addr_len = sizeof(addr);
ssize_t num_bytes = recvfrom(ntp->fd, (void *)buf, sizeof(buf), 0,
&addr, &addr_len);
if (num_bytes == 0) {
return false;
}
......@@ -95,7 +96,8 @@ ntp_server_handle(struct ntp_server *ntp)
}
fill_time_buffer(buf + 24);
num_bytes = sendto(ntp->fd, buf, num_bytes, 0, &addr, addr_len);
num_bytes = sendto(ntp->fd, (void *)buf, num_bytes, 0,
&addr, addr_len);
return num_bytes == sizeof(buf);
}
......
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