Remove implicit conversions that lose precision.

This commit is contained in:
syb0rg 2014-04-23 19:16:07 -05:00
parent ce3671a320
commit e8cda1fa30
3 changed files with 10 additions and 10 deletions

View File

@ -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)); setsockopt(fd, IPPROTO_IP, IP_OPT_DONT_FRAG, (const void*) &flag, sizeof(flag));
#endif #endif
if(bind(fd, (struct sockaddr*) sockaddr, sockaddr_len) < 0) if(bind(fd, (struct sockaddr*) sockaddr, (unsigned) sockaddr_len) < 0)
err(1, "bind"); err(1, "bind");
fprintf(stderr, "Opened IPv%d UDP socket\n", sockaddr->ss_family == AF_INET6 ? 6 : 4); fprintf(stderr, "Opened IPv%d UDP socket\n", sockaddr->ss_family == AF_INET6 ? 6 : 4);

View File

@ -148,7 +148,7 @@ main(int argc, char **argv)
#endif #endif
username = NULL; username = NULL;
memset(password, 0, 33); memset(password, 0, 33);
srand(time(NULL)); srand((unsigned) time(NULL));
foreground = 0; foreground = 0;
newroot = NULL; newroot = NULL;
context = NULL; context = NULL;

View File

@ -123,12 +123,12 @@ static int get_external_ip(struct in_addr *ip)
freeaddrinfo(addr); freeaddrinfo(addr);
if (res < 0) return 3; if (res < 0) return 3;
res = write(sock, getstr, strlen(getstr)); res = (int) write(sock, getstr, strlen(getstr));
if (res != strlen(getstr)) return 4; if (res != strlen(getstr)) return 4;
/* Zero buf before receiving, leave at least one zero at the end */ /* Zero buf before receiving, leave at least one zero at the end */
memset(buf, 0, sizeof(buf)); 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; if (res < 0) return 5;
len = res; len = res;
@ -607,7 +607,7 @@ tunnel_tun(int tun_fd, int dns_fd)
int userid; int userid;
int read; 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; return 0;
/* find target ip in packet, in is padded with 4 bytes TUN header */ /* 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 If the queue is full, drop the packet. TCP will hopefully notice
and reduce the packet rate. */ and reduce the packet rate. */
if (users[userid].outpacket.len > 0) { if (users[userid].outpacket.len > 0) {
save_to_outpacketq(userid, out, outlen); save_to_outpacketq(userid, out, (int) outlen);
return 0; return 0;
} }
#endif #endif
start_new_outpacket(userid, out, outlen); start_new_outpacket(userid, out, (int) outlen);
/* Start sending immediately if query is waiting */ /* Start sending immediately if query is waiting */
if (users[userid].q_sendrealsoon.id != 0) 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) else if (users[userid].q.id != 0)
send_chunk_or_dataless(dns_fd, userid, &users[userid].q); send_chunk_or_dataless(dns_fd, userid, &users[userid].q);
return outlen; return (int) outlen;
} else { /* CONN_RAW_UDP */ } else { /* CONN_RAW_UDP */
send_raw(dns_fd, out, outlen, userid, RAW_HDR_CMD_DATA, &users[userid].q); send_raw(dns_fd, out, (int) outlen, userid, RAW_HDR_CMD_DATA, &users[userid].q);
return outlen; return (int) outlen;
} }
} }