| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 | Subject: Changes for avoidance warnings in gcc compilation on Linux (Ubuntu 12.04), OpenBSD 5.1 and Oracle solaris 11 with AMD64 architecture when enables "--enable-gcc-warnings" option in configureOrigin: softflowd-0.9.9-1-g91b2a2c <https://github.com/irino/softflowd/commit/softflowd-0.9.9-1-g91b2a2c>Upstream-Author: Hitoshi Irino <hitoshi.irino@gmail.com>Date: Fri Sep 21 14:46:18 2012 +0900--- a/common.h+++ b/common.h@@ -57,6 +57,7 @@ #include <signal.h> #include <stdio.h> #include <string.h>+#include <strings.h> #include <syslog.h> #include <time.h> @@ -166,4 +167,13 @@ } __packed; #endif ++/* following lines are copy from unistd.h in Linux for avoidance warnings in compilation */+#if defined(HAVE_SETRESGID) && !defined(_GNU_SOURCE)+extern int setresgid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);+#endif+#if defined(HAVE_SETRESUID) && !defined(_GNU_SOURCE)+extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid);+#endif+ #endif /* _SFD_COMMON_H */--- a/netflow5.c+++ b/netflow5.c@@ -99,7 +99,7 @@ 			hdr->flow_sequence = htonl(*flows_exported); 			if (option->sample > 0) { 				hdr->sampling_interval =-					htons(0x01 << 14 | option->sample & 0x3FFF);+					htons((0x01 << 14) | (option->sample & 0x3FFF)); 			} 			/* Other fields are left zero */ 			offset = sizeof(*hdr);--- a/softflowctl.c+++ b/softflowctl.c@@ -36,7 +36,9 @@ 	const char *ctlsock_path; 	char buf[8192], *command; 	struct sockaddr_un ctl;+#ifdef SOCK_HAS_LEN  	socklen_t ctllen;+#endif 	int ctlsock, ch; 	FILE *ctlf; 	extern char *optarg;@@ -73,9 +75,9 @@ 	} 	ctl.sun_path[sizeof(ctl.sun_path) - 1] = '\0'; 	ctl.sun_family = AF_UNIX;+#ifdef SOCK_HAS_LEN  	ctllen = offsetof(struct sockaddr_un, sun_path) +             strlen(ctlsock_path) + 1;-#ifdef SOCK_HAS_LEN  	ctl.sun_len = ctllen; #endif 	if ((ctlsock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {--- a/softflowd.c+++ b/softflowd.c@@ -255,15 +255,15 @@ static const char * format_flow(struct FLOW *flow) {-	char addr1[64], addr2[64], stime[32], ftime[32];+	char addr1[64], addr2[64], start_time[32], fin_time[32]; 	static char buf[1024];  	inet_ntop(flow->af, &flow->addr[0], addr1, sizeof(addr1)); 	inet_ntop(flow->af, &flow->addr[1], addr2, sizeof(addr2)); -	snprintf(stime, sizeof(ftime), "%s", +	snprintf(start_time, sizeof(start_time), "%s",  	    format_time(flow->flow_start.tv_sec));-	snprintf(ftime, sizeof(ftime), "%s", +	snprintf(fin_time, sizeof(fin_time), "%s",  	    format_time(flow->flow_last.tv_sec));  	snprintf(buf, sizeof(buf),  "seq:%"PRIu64" [%s]:%hu <> [%s]:%hu proto:%u "@@ -275,8 +275,8 @@ 	    (int)flow->protocol,  	    flow->octets[0], flow->packets[0],  	    flow->octets[1], flow->packets[1], -	    stime, (flow->flow_start.tv_usec + 500) / 1000, -	    ftime, (flow->flow_last.tv_usec + 500) / 1000,+	    start_time, (flow->flow_start.tv_usec + 500) / 1000, +	    fin_time, (flow->flow_last.tv_usec + 500) / 1000, 	    flow->tcp_flags[0], flow->tcp_flags[1], 	    flow->ip6_flowlabel[0], flow->ip6_flowlabel[1]); @@ -1163,7 +1163,7 @@ accept_control(int lsock, struct NETFLOW_TARGET *target, struct FLOWTRACK *ft,     pcap_t *pcap, int *exit_request, int *stop_collection_flag) {-	unsigned char buf[64], *p;+	char buf[64], *p; 	FILE *ctlf; 	int fd, ret; @@ -1202,61 +1202,61 @@ 		ret = 0; 	} else if (strcmp(buf, "shutdown") == 0) { 		fprintf(ctlf, "softflowd[%u]: Shutting down gracefully...\n", -		    getpid());+		    (unsigned int)getpid()); 		graceful_shutdown_request = 1; 		ret = 1; 	} else if (strcmp(buf, "exit") == 0) {-		fprintf(ctlf, "softflowd[%u]: Exiting now...\n", getpid());+		fprintf(ctlf, "softflowd[%u]: Exiting now...\n", (unsigned int)getpid()); 		*exit_request = 1; 		ret = 1; 	} else if (strcmp(buf, "expire-all") == 0) { 		netflow9_resend_template();-		fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", getpid(), +		fprintf(ctlf, "softflowd[%u]: Expired %d flows.\n", (unsigned int)getpid(),  		    check_expired(ft, target, CE_EXPIRE_ALL)); 		ret = 0; 	} else if (strcmp(buf, "send-template") == 0) { 		netflow9_resend_template(); 		fprintf(ctlf, "softflowd[%u]: Template will be sent at "-		    "next flow export\n", getpid());+		    "next flow export\n", (unsigned int)getpid()); 		ret = 0; 	} else if (strcmp(buf, "delete-all") == 0) {-		fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", getpid(), +		fprintf(ctlf, "softflowd[%u]: Deleted %d flows.\n", (unsigned int)getpid(),  		    delete_all_flows(ft)); 		ret = 0; 	} else if (strcmp(buf, "statistics") == 0) { 		fprintf(ctlf, "softflowd[%u]: Accumulated statistics "-		    "since %s UTC:\n", getpid(),+		    "since %s UTC:\n", (unsigned int)getpid(), 		    format_time(ft->system_boot_time.tv_sec)); 		statistics(ft, ctlf, pcap); 		ret = 0; 	} else if (strcmp(buf, "debug+") == 0) { 		fprintf(ctlf, "softflowd[%u]: Debug level increased.\n",-		    getpid());+		    (unsigned int)getpid()); 		verbose_flag = 1; 		ret = 0; 	} else if (strcmp(buf, "debug-") == 0) { 		fprintf(ctlf, "softflowd[%u]: Debug level decreased.\n",-		    getpid());+		    (unsigned int)getpid()); 		verbose_flag = 0; 		ret = 0; 	} else if (strcmp(buf, "stop-gather") == 0) { 		fprintf(ctlf, "softflowd[%u]: Data collection stopped.\n",-		    getpid());+		    (unsigned int)getpid()); 		*stop_collection_flag = 1; 		ret = 0; 	} else if (strcmp(buf, "start-gather") == 0) { 		fprintf(ctlf, "softflowd[%u]: Data collection resumed.\n",-		    getpid());+		    (unsigned int)getpid()); 		*stop_collection_flag = 0; 		ret = 0; 	} else if (strcmp(buf, "dump-flows") == 0) { 		fprintf(ctlf, "softflowd[%u]: Dumping flow data:\n",-		    getpid());+		    (unsigned int)getpid()); 		dump_flows(ft, ctlf); 		ret = 0; 	} else if (strcmp(buf, "timeouts") == 0) { 		fprintf(ctlf, "softflowd[%u]: Printing timeouts:\n",-		    getpid());+		    (unsigned int)getpid()); 		print_timeouts(ft, ctlf); 		ret = 0; 	} else {@@ -1868,7 +1868,7 @@ 			    pidfile_path, strerror(errno)); 			exit(1); 		}-		fprintf(pidfile, "%u\n", getpid());+		fprintf(pidfile, "%u\n", (unsigned int)getpid()); 		fclose(pidfile);  		signal(SIGINT, sighand_graceful_shutdown);
 |