From 0b08d518f21a618d1a8b556043ec330d1ed72f3c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 9 Jan 2022 12:03:12 +0100 Subject: [PATCH] socket, select: Fix -Wsign-compare warnings Change-Id: Idf6213e66e9bf609e930c6134292458a7d521871 --- src/select.c | 2 +- src/socket.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/select.c b/src/select.c index ddff13297..735ea3eff 100644 --- a/src/select.c +++ b/src/select.c @@ -316,7 +316,7 @@ static unsigned int poll_fill_fds(void) } /* iterate over first n_fd entries of g_poll.poll + dispatch */ -static int poll_disp_fds(int n_fd) +static int poll_disp_fds(unsigned int n_fd) { struct osmo_fd *ufd; unsigned int i; diff --git a/src/socket.c b/src/socket.c index 125106182..449c8258e 100644 --- a/src/socket.c +++ b/src/socket.c @@ -114,7 +114,7 @@ static struct addrinfo *addrinfo_helper(uint16_t family, uint16_t type, uint8_t static int addrinfo_helper_multi(struct addrinfo **addrinfo, uint16_t family, uint16_t type, uint8_t proto, const char **hosts, size_t host_cnt, uint16_t port, bool passive) { - int i, j; + unsigned int i, j; for (i = 0; i < host_cnt; i++) { addrinfo[i] = addrinfo_helper(family, type, proto, hosts[i], port, passive); @@ -210,7 +210,8 @@ static int socket_helper_osa(const struct osmo_sockaddr *addr, uint16_t type, ui static int multiaddr_snprintf(char* buf, size_t buf_len, const char **hosts, size_t host_cnt) { int len = 0, offset = 0, rem = buf_len; - int ret, i; + size_t i; + int ret; char *after; if (buf_len < 3) @@ -665,7 +666,7 @@ static int socket_helper_multiaddr(uint16_t family, uint16_t type, uint8_t proto /* Build array of addresses taking first addrinfo result of the requested family * for each host in addrs_buf. */ static int addrinfo_to_sockaddr(uint16_t family, const struct addrinfo **result, - const char **hosts, int host_cont, + const char **hosts, unsigned int host_cont, uint8_t *addrs_buf, size_t addrs_buf_len) { size_t host_idx, offset = 0; const struct addrinfo *rp; @@ -721,7 +722,7 @@ int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto, { struct addrinfo *res_loc[OSMO_SOCK_MAX_ADDRS], *res_rem[OSMO_SOCK_MAX_ADDRS]; int sfd = -1, rc, on = 1; - int i; + unsigned int i; bool loc_has_v4addr, rem_has_v4addr; bool loc_has_v6addr, rem_has_v6addr; struct sockaddr_in6 addrs_buf[OSMO_SOCK_MAX_ADDRS];