From e8cda1fa304086dd5805df29cf477a70372f6781 Mon Sep 17 00:00:00 2001 From: syb0rg Date: Wed, 23 Apr 2014 19:16:07 -0500 Subject: [PATCH] Remove implicit conversions that lose precision. --- src/common.c | 2 +- src/iodine.c | 2 +- src/iodined.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common.c b/src/common.c index 5f202da..0940ef1 100644 --- a/src/common.c +++ b/src/common.c @@ -196,7 +196,7 @@ open_dns(struct sockaddr_storage *sockaddr, size_t sockaddr_len) setsockopt(fd, IPPROTO_IP, IP_OPT_DONT_FRAG, (const void*) &flag, sizeof(flag)); #endif - if(bind(fd, (struct sockaddr*) sockaddr, sockaddr_len) < 0) + if(bind(fd, (struct sockaddr*) sockaddr, (unsigned) sockaddr_len) < 0) err(1, "bind"); fprintf(stderr, "Opened IPv%d UDP socket\n", sockaddr->ss_family == AF_INET6 ? 6 : 4); diff --git a/src/iodine.c b/src/iodine.c index 519eac3..d64da01 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -148,7 +148,7 @@ main(int argc, char **argv) #endif username = NULL; memset(password, 0, 33); - srand(time(NULL)); + srand((unsigned) time(NULL)); foreground = 0; newroot = NULL; context = NULL; diff --git a/src/iodined.c b/src/iodined.c index 75979d9..7f6ee12 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -123,12 +123,12 @@ static int get_external_ip(struct in_addr *ip) freeaddrinfo(addr); if (res < 0) return 3; - res = write(sock, getstr, strlen(getstr)); + res = (int) write(sock, getstr, strlen(getstr)); if (res != strlen(getstr)) return 4; /* Zero buf before receiving, leave at least one zero at the end */ memset(buf, 0, sizeof(buf)); - res = read(sock, buf, sizeof(buf) - 1); + res = (int) read(sock, buf, sizeof(buf) - 1); if (res < 0) return 5; len = res; @@ -607,7 +607,7 @@ tunnel_tun(int tun_fd, int dns_fd) int userid; int read; - if ((read = read_tun(tun_fd, in, sizeof(in))) <= 0) + if ((read = (int) read_tun(tun_fd, in, sizeof(in))) <= 0) return 0; /* find target ip in packet, in is padded with 4 bytes TUN header */ @@ -625,12 +625,12 @@ tunnel_tun(int tun_fd, int dns_fd) If the queue is full, drop the packet. TCP will hopefully notice and reduce the packet rate. */ if (users[userid].outpacket.len > 0) { - save_to_outpacketq(userid, out, outlen); + save_to_outpacketq(userid, out, (int) outlen); return 0; } #endif - start_new_outpacket(userid, out, outlen); + start_new_outpacket(userid, out, (int) outlen); /* Start sending immediately if query is waiting */ if (users[userid].q_sendrealsoon.id != 0) @@ -638,10 +638,10 @@ tunnel_tun(int tun_fd, int dns_fd) else if (users[userid].q.id != 0) send_chunk_or_dataless(dns_fd, userid, &users[userid].q); - return outlen; + return (int) outlen; } else { /* CONN_RAW_UDP */ - send_raw(dns_fd, out, outlen, userid, RAW_HDR_CMD_DATA, &users[userid].q); - return outlen; + send_raw(dns_fd, out, (int) outlen, userid, RAW_HDR_CMD_DATA, &users[userid].q); + return (int) outlen; } }