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.
This commit is contained in:
		| @@ -81,8 +81,9 @@ ntp_server_handle(struct ntp_server *ntp) | |||||||
| 	unsigned char buf[32]; | 	unsigned char buf[32]; | ||||||
| 	struct sockaddr addr; | 	struct sockaddr addr; | ||||||
| 	int iter; | 	int iter; | ||||||
| 	unsigned int addr_len = sizeof(addr); | 	socklen_t addr_len = sizeof(addr); | ||||||
| 	int num_bytes = recvfrom(ntp->fd, buf, sizeof(buf), 0, &addr, &addr_len); | 	ssize_t num_bytes = recvfrom(ntp->fd, (void *)buf, sizeof(buf), 0, | ||||||
|  | 				     &addr, &addr_len); | ||||||
| 	if (num_bytes == 0) { | 	if (num_bytes == 0) { | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| @@ -95,7 +96,8 @@ ntp_server_handle(struct ntp_server *ntp) | |||||||
| 	} | 	} | ||||||
| 	fill_time_buffer(buf + 24); | 	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); | 	return num_bytes == sizeof(buf); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann