diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-08-08 17:16:09 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-08-08 17:16:09 +0200 |
commit | b6828945dc12cbf447913445fb0e61745e7779f6 (patch) | |
tree | e2aab71226ca20d956ea74b55b2b82e4be0a7215 /astraceroute.c | |
parent | 5cdfe9527fd6dacb2d6080b91be3d844f28b20fb (diff) |
astraceroute: Fix compiler warnings with "-W -Wall -Wextra"
Fix the following compiler warnings that occur when building with "-W
-Wall -Wextra":
astraceroute.c: In function ‘__assemble_data’:
astraceroute.c:255:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c:262:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c: In function ‘check_ipv4’:
astraceroute.c:425:56: warning: unused parameter ‘ttl’ [-Wunused-parameter]
astraceroute.c: In function ‘handle_ipv4’:
astraceroute.c:451:49: warning: unused parameter ‘len’ [-Wunused-parameter]
astraceroute.c: In function ‘check_ipv6’:
astraceroute.c:511:49: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c:491:56: warning: unused parameter ‘ttl’ [-Wunused-parameter]
astraceroute.c: In function ‘handle_ipv6’:
astraceroute.c:517:49: warning: unused parameter ‘len’ [-Wunused-parameter]
astraceroute.c: In function ‘__process_node’:
astraceroute.c:690:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c: In function ‘__process_time’:
astraceroute.c:738:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c:755:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c:765:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c: In function ‘__process_ttl’:
astraceroute.c:846:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
astraceroute.c: In function ‘main’:
astraceroute.c:1060:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'astraceroute.c')
-rw-r--r-- | astraceroute.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/astraceroute.c b/astraceroute.c index 45b4550..b546943 100644 --- a/astraceroute.c +++ b/astraceroute.c @@ -249,13 +249,13 @@ static void __noreturn version(void) static void __assemble_data(uint8_t *packet, size_t len, const char *payload) { - int i; + size_t i; if (payload == NULL) { for (i = 0; i < len; ++i) packet[i] = (uint8_t) rand(); } else { - int lmin = min(len, strlen(payload)); + size_t lmin = min(len, strlen(payload)); for (i = 0; i < lmin; ++i) packet[i] = (uint8_t) payload[i]; @@ -422,8 +422,8 @@ static int assemble_ipv6(uint8_t *packet, size_t len, int ttl, int proto, return ntohl(ip6h->ip6_flow) & 0x000fffff; } -static int check_ipv4(uint8_t *packet, size_t len, int ttl, int id, - const struct sockaddr *ss) +static int check_ipv4(uint8_t *packet, size_t len, int ttl __maybe_unused, + int id, const struct sockaddr *ss) { struct iphdr *iph = (struct iphdr *) packet; struct iphdr *iph_inner; @@ -448,7 +448,8 @@ static int check_ipv4(uint8_t *packet, size_t len, int ttl, int id, return len; } -static void handle_ipv4(uint8_t *packet, size_t len, int dns_resolv, int latitude) +static void handle_ipv4(uint8_t *packet, size_t len __maybe_unused, + int dns_resolv, int latitude) { char hbuff[NI_MAXHOST]; struct iphdr *iph = (struct iphdr *) packet; @@ -488,8 +489,8 @@ static void handle_ipv4(uint8_t *packet, size_t len, int dns_resolv, int latitud printf(" (%f/%f)", geoip4_latitude(sd), geoip4_longitude(sd)); } -static int check_ipv6(uint8_t *packet, size_t len, int ttl, int id, - const struct sockaddr *ss) +static int check_ipv6(uint8_t *packet, size_t len, int ttl __maybe_unused, + int id, const struct sockaddr *ss) { struct ip6_hdr *ip6h = (struct ip6_hdr *) packet; struct ip6_hdr *ip6h_inner; @@ -508,13 +509,14 @@ static int check_ipv6(uint8_t *packet, size_t len, int ttl, int id, return -EINVAL; ip6h_inner = (struct ip6_hdr *) (packet + sizeof(*ip6h) + sizeof(*icmp6h)); - if ((ntohl(ip6h_inner->ip6_flow) & 0x000fffff) != id) + if ((ntohl(ip6h_inner->ip6_flow) & 0x000fffff) != (uint32_t) id) return -EINVAL; return len; } -static void handle_ipv6(uint8_t *packet, size_t len, int dns_resolv, int latitude) +static void handle_ipv6(uint8_t *packet, size_t len __maybe_unused, + int dns_resolv, int latitude) { char hbuff[NI_MAXHOST]; struct ip6_hdr *ip6h = (struct ip6_hdr *) packet; @@ -687,7 +689,7 @@ static int __process_node(struct ctx *ctx, int fd, int fd_cap, int ttl, timersub(&end, &start, diff); ret = recvfrom(fd_cap, pkt_rcv, ctx->rcvlen, 0, NULL, NULL); - if (ret < sizeof(struct ethhdr) + af_ops[ctx->proto].min_len_icmp) + if (ret < (int) (sizeof(struct ethhdr) + af_ops[ctx->proto].min_len_icmp)) return -EIO; return af_ops[ctx->proto].check(pkt_rcv + sizeof(struct ethhdr), @@ -724,7 +726,8 @@ static int __process_time(struct ctx *ctx, int fd, int fd_cap, int ttl, const struct sockaddr_storage *ss, const struct sockaddr_storage *sd) { - int good = 0, i, j = 0, ret = -EIO, idx, ret_good = -EIO; + size_t i, j = 0; + int good = 0, ret = -EIO, idx, ret_good = -EIO; struct timeval probes[9], *tmp, sum, res; uint8_t *trash = xmalloc(ctx->rcvlen); char *cwait[] = { "-", "\\", "|", "/" }; @@ -745,7 +748,7 @@ static int __process_time(struct ctx *ctx, int fd, int fd_cap, int ttl, good++; } - if (good == 0 && ctx->queries == i) + if (good == 0 && ctx->queries == (int) i) break; usleep(50000); @@ -834,7 +837,8 @@ static int __process_ttl(struct ctx *ctx, int fd, int fd_cap, int ttl, const struct sockaddr_storage *ss, const struct sockaddr_storage *sd) { - int ret = -EIO, i; + int ret = -EIO; + size_t i; const int inner_protos[] = { IPPROTO_TCP, IPPROTO_ICMP, |