From: David Schweikert Date: Tue, 24 Jan 2017 08:08:39 +0000 (+0100) Subject: another attempt at fixing coverity warning X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e827b6719ab3f632b96efb32cc05197b13b4c247;p=fping.git another attempt at fixing coverity warning --- diff --git a/src/fping.c b/src/fping.c index 051469e..cf39086 100644 --- a/src/fping.c +++ b/src/fping.c @@ -967,19 +967,18 @@ void add_range(char *start, char *end) end_long = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr); freeaddrinfo(addr_res); - if(end_long - start_long > MAX_LOOP) { + if(end_long > start_long + MAX_LOOP) { fprintf(stderr, "Error: -g parameter generates too many addresses\n"); exit(1); } /* generate */ - while(start_long <= end_long) { + for(; start_long <= end_long; start_long++) { struct in_addr in_addr_tmp; char buffer[20]; in_addr_tmp.s_addr = htonl(start_long); inet_ntop(AF_INET, &in_addr_tmp, buffer, sizeof(buffer)); add_name(buffer); - start_long++; } }