From: Daniel Wagner <[email protected]>
recv() and recvfrom() return ssize_t and not int. While we are at,
also update all tests against the return value to use smaller, equal
or greater operators.
---
src/dnsproxy.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 584640a..98fdaac 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2050,14 +2050,14 @@ hangup:
} else if (condition & G_IO_IN) {
struct partial_reply *reply = server->incoming_reply;
- int bytes_recv;
+ ssize_t bytes_recv;
if (!reply) {
unsigned char reply_len_buf[2];
uint16_t reply_len;
bytes_recv = recv(sk, reply_len_buf, 2, MSG_PEEK);
- if (!bytes_recv) {
+ if (bytes_recv == 0) {
goto hangup;
} else if (bytes_recv < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
@@ -2087,7 +2087,7 @@ hangup:
while (reply->received < reply->len) {
bytes_recv = recv(sk, reply->buf + reply->received,
reply->len - reply->received, 0);
- if (!bytes_recv) {
+ if (bytes_recv == 0) {
connman_error("DNS proxy TCP disconnect");
break;
} else if (bytes_recv < 0) {
@@ -2844,7 +2844,8 @@ static gboolean tcp_client_event(GIOChannel *channel,
GIOCondition condition,
socklen_t client_addr4_len = sizeof(client_addr4);
void *client_addr;
socklen_t *client_addr_len;
- int len, client_sk;
+ int client_sk;
+ ssize_t len;
client_sk = g_io_channel_unix_get_fd(channel);
@@ -2907,7 +2908,7 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
struct listener_data *ifdata, int family,
guint *listener_watch)
{
- int sk, client_sk, len;
+ int sk, client_sk;
unsigned int msg_len;
struct tcp_partial_client_data *client;
struct sockaddr_in6 client_addr6;
@@ -2918,6 +2919,7 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
socklen_t *client_addr_len;
struct timeval tv;
fd_set readfds;
+ ssize_t len;
DBG("condition 0x%02x channel %p ifdata %p family %d",
condition, channel, ifdata, family);
@@ -3042,7 +3044,7 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
* that is the reason to -2 below.
*/
if (msg_len != (unsigned int)(len - 2)) {
- DBG("client %d sent %d bytes but expecting %u pending %d",
+ DBG("client %d sent %zd bytes but expecting %u pending %zd",
client_sk, len, msg_len + 2, msg_len + 2 - len);
client->buf_end += len;
@@ -3083,7 +3085,8 @@ static bool udp_listener_event(GIOChannel *channel,
GIOCondition condition,
socklen_t client_addr4_len = sizeof(client_addr4);
void *client_addr;
socklen_t *client_addr_len;
- int sk, err, len;
+ int sk, err;
+ ssize_t len;
if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
connman_error("Error with UDP listener channel");
@@ -3106,7 +3109,7 @@ static bool udp_listener_event(GIOChannel *channel,
GIOCondition condition,
if (len < 2)
return true;
- DBG("Received %d bytes (id 0x%04x)", len, buf[0] | buf[1] << 8);
+ DBG("Received %zd bytes (id 0x%04x)", len, buf[0] | buf[1] << 8);
err = parse_request(buf, len, query, sizeof(query));
if (err < 0 || (g_slist_length(server_list) == 0)) {
--
1.8.4.474.g128a96c
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman