upstream: http://sourceforge.net/tracker/?func=detail&aid=2748675&group_id=183434&atid=905228 status: submitted to SF by anonymous poster on Apr 9 2009 origin: anonymous on SourceForge comment: various minor fixes - ID: 2748675 The attached patch fixes a truckload of compiler warnings and fflushes the output stream after each line. The new function `lf_and_flush' was introduced to accomplish this. `recvfrom' now gets a real socklen_t if its existance is detected via autoconf. Submitted: Nobody/Anonymous ( nobody ) - 2009-04-09 21:26 --- fping-2.4b2_to/configure.in 2001-11-03 16:36:49.000000000 +0100 +++ fping/configure.in 2009-04-09 22:57:32.000000000 +0200 @@ -29,4 +29,7 @@ dnl Checks for header files. AC_CHECK_HEADERS(unistd.h sys/file.h stdlib.h sys/select.h) +AC_CHECK_TYPES([socklen_t], , , [#include + #include ]) + AC_OUTPUT(Makefile) --- fping-2.4b2_to/fping.c 2001-07-20 19:10:26.000000000 +0200 +++ fping/fping.c 2009-04-09 23:10:08.000000000 +0200 @@ -114,6 +114,10 @@ #include "options.h" +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + /*** externals ***/ extern char *optarg; @@ -314,6 +318,7 @@ void add_addr(); char *na_cat(); char *cpystr(); +void lf_and_flush(); void crash_and_burn(); void errno_crash_and_burn(); char *get_host_by_address(); @@ -338,6 +343,7 @@ void add_addr( char *name, char *host, struct in_addr ipaddr ); char *na_cat( char *name, struct in_addr ipaddr ); char *cpystr( char *string ); +void lf_and_flush( FILE *stream ); void crash_and_burn( char *message ); void errno_crash_and_burn( char *message ); char *get_host_by_address( struct in_addr in ); @@ -411,7 +417,7 @@ if( ( uid = getuid() ) ) { - seteuid( getuid() ); + seteuid( uid ); }/* IF */ @@ -610,7 +616,7 @@ if( ( ping_data_size > MAX_PING_DATA ) || ( ping_data_size < MIN_PING_DATA ) ) { - fprintf( stderr, "%s: data size %u not valid, must be between %u and %u\n", + fprintf( stderr, "%s: data size %u not valid, must be between %lu and %u\n", prog, ping_data_size, MIN_PING_DATA, MAX_PING_DATA ); usage(); @@ -783,7 +789,6 @@ int iBitpos; int iMask = 1; int failed = 0; - unsigned long uTemp; /* two possible forms are allowed here */ @@ -1085,6 +1090,7 @@ }/* WHILE */ finish(); + return 0; } /* main() */ @@ -1130,7 +1136,7 @@ if( verbose_flag ) printf( " is unreachable" ); - printf( "\n" ); + lf_and_flush( stdout ); }/* IF */ }/* IF */ @@ -1175,7 +1181,7 @@ void print_per_system_stats( void ) #endif /* _NO_PROTO */ { - int i, j, k, avg; + int i, j, avg; HOST_ENTRY *h; char *buf; int bufsize; @@ -1210,7 +1216,7 @@ }/* FOR */ - fprintf( stderr, "\n" ); + lf_and_flush( stderr ); }/* IF */ else @@ -1253,7 +1259,7 @@ else fprintf( stderr, " -" ); - fprintf( stderr, "\n" ); + lf_and_flush( stderr ); }/* FOR */ }/* IF */ @@ -1284,11 +1290,10 @@ void print_per_system_splits( void ) #endif /* _NO_PROTO */ { - int i, j, k, avg; + int i, avg; HOST_ENTRY *h; char *buf; int bufsize; - int resp; struct tm *curr_tm; bufsize = max_hostname_len + 1; @@ -1463,9 +1468,9 @@ { printf( "%s", h->host ); if( verbose_flag ) - printf( " error while sending ping: %s\n", strerror( errno ) ); + printf( " error while sending ping: %s", strerror( errno ) ); - printf( "\n" ); + lf_and_flush( stdout ); }/* IF */ @@ -1631,7 +1636,7 @@ if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr ) fprintf( stderr, " [<- %s]", inet_ntoa( response_addr.sin_addr ) ); - fprintf( stderr, "\n" ); + lf_and_flush( stderr ); }/* IF */ }/* IF */ @@ -1664,7 +1669,7 @@ if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr ) printf( " [<- %s]", inet_ntoa( response_addr.sin_addr ) ); - printf( "\n" ); + lf_and_flush( stdout ); }/* IF */ }/* IF */ @@ -1692,7 +1697,7 @@ if( response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr ) printf( " [<- %s]", inet_ntoa( response_addr.sin_addr ) ); - printf( "\n" ); + lf_and_flush( stdout ); }/* IF */ @@ -1725,7 +1730,6 @@ #endif /* _NO_PROTO */ { struct icmp *sent_icmp; - struct ip *sent_ip; u_char *c; HOST_ENTRY *h; @@ -1758,7 +1762,7 @@ if( inet_addr( h->host ) == -1 ) fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) ); - fprintf( stderr, "\n" ); + lf_and_flush( stderr ); }/* IF */ @@ -1781,7 +1785,7 @@ if( inet_addr( h->host ) == -1 ) fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) ); - fprintf( stderr, "\n" ); + lf_and_flush( stderr ); }/* IF */ @@ -2241,6 +2245,29 @@ } /* cpystr() */ +/************************************************************ + + Function: lf_and_flush + +************************************************************* + + Inputs: FILE *stream + + Description: + +************************************************************/ + +#ifdef _NO_PROTO +void lf_and_flush( stream ) +FILE *stream; +#else +void lf_and_flush( FILE *stream ) +#endif /* _NO_PROTO */ +{ + putc( '\n', stream ); + fflush( stream ); +} /* lf_and_flush() */ + /************************************************************ @@ -2405,7 +2432,7 @@ void u_sleep( int u_sec ) #endif /* _NO_PROTO */ { - int nfound, slen, n; + int nfound; struct timeval to; fd_set readset, writeset; @@ -2418,8 +2445,6 @@ if( nfound < 0 ) errno_crash_and_burn( "select" ); - return; - } /* u_sleep() */ @@ -2448,7 +2473,8 @@ int recvfrom_wto( int s, char *buf, int len, struct sockaddr *saddr, int timo ) #endif /* _NO_PROTO */ { - int nfound, slen, n; + int nfound, n; + socklen_t slen; struct timeval to; fd_set readset, writeset;