]> git.gsnw.org Git - fping.git/commitdiff
another attempt at fixing coverity warning
authorDavid Schweikert <david@schweikert.ch>
Tue, 24 Jan 2017 08:08:39 +0000 (09:08 +0100)
committerDavid Schweikert <david@schweikert.ch>
Tue, 24 Jan 2017 08:08:39 +0000 (09:08 +0100)
src/fping.c

index 051469e3a26c5bcc45d32a0ccc77c88f6d54f774..cf390865f07816585db0769319a39cf988d7f637 100644 (file)
@@ -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++;
     }
 }