summaryrefslogtreecommitdiffstats
path: root/recipes/fping/files/sourceforge-truckload.patch
blob: ef9971ad326637253c8ca77ef4c5a73ddf40db8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
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 <sys/types.h>
+                                 #include <sys/socket.h>])
+
 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;