Skip to Content.
Sympa Menu

ndt-dev - Re: [ndt-dev] Submitting a patch

Subject: NDT-DEV email list created

List archive

Re: [ndt-dev] Submitting a patch


Chronological Thread 
  • From: Dominic Hamon <>
  • To: Kavitha Kumar <>
  • Cc:
  • Subject: Re: [ndt-dev] Submitting a patch
  • Date: Tue, 9 Oct 2012 14:44:50 -0700

Hi Kavitha

As requested, I have attached the patch. This fixes a few subtle issues
including out-of-bounds array accesses and invalid pointer/int
conversion and occasions where the wrong type was being passed to
methods.

I've tested it by pointing the client at a running known-good server.

Thanks
- dominic

On Mon, Oct 08, 2012 at 04:46:10PM -0400, Kavitha Kumar wrote:
> Hi Dominic,
>
> Pls send the patches to this list for review. Folks here on ndt-dev can
> review and/or apply them. We can then decide further steps to committing
> the changes.
>
> Do you foresee contributing to NDT in a bigger fashion soon/in future and
> thus like commit access?
>
> thanks,
> Kavitha
>
> ----- Original Message -----
> > From:
> >
> > To:
> >
> > Sent: Monday, October 8, 2012 3:29:16 PM
> > Subject: [ndt-dev] Submitting a patch
> >
> > Hello
> >
> > I have prepared a patch that fixes a couple of issues with trunk.
> > Mostly
> > innocuous changes to clean up C90 warnings but some of the changes
> > fix things
> > like implicit int/pointer conversion.
> >
> > How do I go about submitting the patch for review?
> >
> > Thanks
> > - dominic
> >
diff --git a/configure.ac b/configure.ac
index 8da9cfd..addb73d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,17 +39,17 @@ AC_CONFIG_HEADER([config.h])
 
 TOP_BUILD_DIRS=""
 
-CFLAGS="-pedantic -Wall -O2"
+CFLAGS="-pedantic -Wall -Werror -Wno-unused-result -fno-strict-aliasing -std=gnu99"
 
 # Enabling/disabling asserts and debugging
 AC_MSG_CHECKING(whether to enable debugging)
 AC_ARG_ENABLE(debug, [  --enable-debug=[no/yes] turn on debugging
               [default=no]],, enable_debug=no)
 if test "x$enable_debug" = "xyes"; then
-  CFLAGS="$CFLAGS -g"
+  CFLAGS="$CFLAGS -g -O0"
   AC_MSG_RESULT(yes)
 else
-  CFLAGS="$CFLAGS -DNDEBUG"
+  CFLAGS="$CFLAGS -DNDEBUG -O2"
   AC_MSG_RESULT(no)
 fi
 
diff --git a/src/fakewww.c b/src/fakewww.c
index b3c62d6..a1d1f88 100644
--- a/src/fakewww.c
+++ b/src/fakewww.c
@@ -36,7 +36,7 @@
 #include "logging.h"
 #include "web100-admin.h"
 
-#define PORT            "7123"
+#define LISTEN_PORT            "7123"
 #define AC_TIME_FORMAT  "%d/%b/%Y:%H:%M:%S %z"
 #define ER_TIME_FORMAT  "%a %b %d %H:%M:%S %Y"
 #define ACLOGFILE       "access_log"
@@ -127,7 +127,7 @@ int main(int argc, char** argv) {
 	time_t tt;
 	socklen_t clilen;
 	char* srcname = NULL;
-	char* listenport = PORT;
+	char* listenport = LISTEN_PORT;
 	int conn_options = 0;
 
 	char *ErLogFileName = BASEDIR
diff --git a/src/heuristics.c b/src/heuristics.c
index 12fc5d8..14fef73 100644
--- a/src/heuristics.c
+++ b/src/heuristics.c
@@ -63,15 +63,14 @@ void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data, i
 	int max; // max speed bin counter value
 	int total; // total of the bin counts, used to calculate percentage
 	int ifspeedlocal; // local if-speed indicator
-	FILE * fp; // log file pointer
 
 	for (n = 0; n < spd_index; n++) {
-		sscanf(spds + n,
-				"%d %d %d %d %d %d %d %d %d %d %d %d %f %d %d %d %d %d %d",
+		sscanf(spds[n],
+				"%d %d %d %d %d %d %d %d %d %d %d %d %f %u %u %u %d %d %d",
 				&links[0], &links[1], &links[2], &links[3], &links[4],
 				&links[5], &links[6], &links[7], &links[8], &links[9],
-				&links[10], &links[11], runave + n, &inc_cnt, &dec_cnt,
-				&same_cnt, timeout, dupack, &ifspeedlocal);
+				&links[10], &links[11], &runave[n], inc_cnt, dec_cnt,
+				same_cnt, timeout, dupack, &ifspeedlocal);
 		log_println(log_lvl_heur, " **First ele: spd=%s, runave=%f", spds[n],
 				runave[n]);
 		max = 0;
diff --git a/src/logging.c b/src/logging.c
index 8c3f4c1..a3bffdb 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -28,7 +28,6 @@
 static int _debuglevel = 0;
 static char* _programname = "";
 static char* LogFileName = BASEDIR"/"LOGFILE;
-static char ProtocolLogFileName[FILENAME_SIZE] = BASEDIR"/"PROTOLOGFILE;
 static char* ProtocolLogDirName = BASEDIR"/"LOGDIR;
 static char protocollogfilestore[FILENAME_SIZE];
 static char enableprotologging = 0;
@@ -397,14 +396,16 @@ void log_println(int lvl, const char* format, ...)
  * @return number or characters written to the output buffer
  * */
 
-int quote_delimiters(char *line, int line_size, char *output_buf,
-		int output_buf_size) {
-	static quoted[4][2] = { { '\n', 'n' }, { '"', '"' }, { '\0', '0' }, { '\\',
-			'\\' }, };
+int quote_delimiters(const char *line, int line_size, char *output_buf, int output_buf_size) {
+	static char quoted[4][2] = {
+          { '\n', 'n' },
+          { '"', '"' },
+          { '\0', '0' },
+          { '\\', '\\' },
+        };
 	char quote_char = '\\';
 
 	int i, j, k;
-	int match;
 
 	for (i = j = 0; i < line_size && j < output_buf_size - 1; i++) {
 		// find any matching characters among the quoted
@@ -655,7 +656,7 @@ void protolog_println(char *msgdirection, const int type, void* msg,
 	FILE * fp;
 
 	char msgtypedescarr[MSG_TYPE_DESC_SIZE];
-	char *currenttestname, *currentmsgtype, *currentbodyfmt;
+	char *currenttestname, *currentmsgtype;
 	char isotime[64];
 	char logmessage[4096]; // message after replacing delimiter characters
 	char protologfile[FILENAME_SIZE];
@@ -881,18 +882,12 @@ char *fill_ISOtime(struct tm *result, char *isoTime, int isotimearrsize) {
  * @return current time string
  */
 char *get_currenttime(char *isoTime, int isotimearrsize) {
-	struct timeval now;
-	time_t timenow;
+	time_t rawtime;
 	struct tm *result;
-	int rc;
-
-	struct timeval tv;
-
-	rc = gettimeofday(&now, NULL);
-
-	if(rc==0) {
-		timenow = now.tv_sec;
-		result = gmtime(&now);
+	time_t rc;
+	rc = time(&rawtime);
+	if(rc!=-1) {
+		result = gmtime(&rawtime);
 		return (fill_ISOtime(result, isoTime, isotimearrsize));
 	}
 	return NULL;
@@ -911,7 +906,6 @@ get_ISOtime(char *isoTime, int isotimearrsize) {
 
 	struct tm *result;
 	time_t now;
-	char tmpstr[16];
 
 	setenv("TZ", "UTC", 0);
 	now = get_timestamp();
@@ -1160,9 +1154,8 @@ void create_client_logdir(struct sockaddr *cliaddrarg, socklen_t clilenarg,
 	char namebuf[256];
 	size_t namebuflen = 255;
 	char dir[128];
-	DIR *dp;
 	char isoTime[64];
-	char *socketaddrport;
+	int socketaddrport;
 
 	I2Addr sockAddr = I2AddrBySAddr(get_errhandle(), cliaddrarg, clilenarg, 0,
 			0);
diff --git a/src/mrange.c b/src/mrange.c
index 1951c95..7433aaa 100644
--- a/src/mrange.c
+++ b/src/mrange.c
@@ -34,7 +34,7 @@ static Range* mrange_root;
 int mrange_parse(char* text) {
 	char tmp[300];
 	char* ptr, *sptr;
-	Range* mr_ptr;
+	Range* mr_ptr = NULL;
 
 	assert(text);
 
diff --git a/src/network.c b/src/network.c
index fde1cb1..8e63576 100644
--- a/src/network.c
+++ b/src/network.c
@@ -6,9 +6,10 @@
  * 
  */
 
-#include <unistd.h>
 #include <assert.h>
+#include <netdb.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "network.h"
 #include "logging.h"
@@ -81,8 +82,7 @@ static int OpenSocket(I2Addr addr, char* serv, int options) {
 			if (!I2AddrSetSAddr(addr, ai->ai_addr, ai->ai_addrlen)
 					|| !I2AddrSetProtocol(addr, ai->ai_protocol)
 					|| !I2AddrSetSocktype(addr, ai->ai_socktype)) {
-				log_println(1,
-						"OpenSocket: Unable to set saddr in address record");
+				log_println(1, "OpenSocket: Unable to set saddr in address record");
 				return -1;
 			}
 			// set port if not already done, else return -1
@@ -101,9 +101,7 @@ static int OpenSocket(I2Addr addr, char* serv, int options) {
 			}
 			// save socket file descriptor
 			if (!I2AddrSetFD(addr, fd, True)) {
-				log_println(
-						1,
-						"OpenSocket: Unable to set file descriptor in address record");
+				log_println(1, "OpenSocket: Unable to set file descriptor in address record");
 				return -1;
 			}
 			// end setting values in "addr" structure
@@ -116,10 +114,9 @@ static int OpenSocket(I2Addr addr, char* serv, int options) {
 			/* RAC debug statemement 10/11/06 */
 			onSize = sizeof(on);
 			getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, &onSize);
-			log_println(
-					1,
-					"bind(%d) failed: Address already in use given as the reason, getsockopt() returned %d",
-					fd, on);
+			log_println(1,
+                                    "bind(%d) failed: Address already in use given as the reason, getsockopt() returned %d",
+                                    fd, on);
 			return -2;
 		}
 
@@ -158,8 +155,7 @@ I2Addr CreateListenSocket(I2Addr addr, char* serv, int options, int buf_size) {
 		goto error;
 	}
 
-	if ((!addr)
-			&& !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
+	if ((!addr) && !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
 		log_println(1, "Unable to create I2Addr record by wildcard.");
 		goto error;
 	}
@@ -352,8 +348,7 @@ int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
 				return 0;
 			}
 			// unable to save
-			log_println(1,
-					"I2Addr functions failed after successful connection");
+			log_println(1, "I2Addr functions failed after successful connection");
 			while ((close(*sockfd) < 0) && (errno == EINTR))
 				;
 			return 1;
@@ -381,7 +376,6 @@ int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
 int send_msg(int ctlSocket, int type, void* msg, int len) {
 	unsigned char buff[3];
 	int rc, i;
-	FILE * fp;
 
 	assert(msg);
 	assert(len >= 0);
@@ -446,7 +440,6 @@ int send_msg(int ctlSocket, int type, void* msg, int len) {
 int recv_msg(int ctlSocket, int* type, void* msg, int* len) {
 	unsigned char buff[3];
 	int length;
-	FILE * fp;
 
 	char *msgtemp = (char*) msg;
 
@@ -500,10 +493,9 @@ int writen(int fd, void* buf, int amount) {
 			if (errno == EINTR) // interrupted, retry writing again
 				continue;
 			if (errno != EAGAIN) { // some genuine socket write error
-				log_println(
-						6,
-						"writen() Error! write(%d) failed with err='%s(%d) pic=%d'",
-						fd, strerror(errno), errno, getpid());
+				log_println(6,
+                                            "writen() Error! write(%d) failed with err='%s(%d) pic=%d'",
+                                            fd, strerror(errno), errno, getpid());
 				return -1;
 			}
 		}
@@ -547,9 +539,7 @@ int readn(int fd, void* buf, int amount) {
 		// check if fd+1 socket is ready to be read
 		rc = select(fd + 1, &rfd, NULL, NULL, &sel_tv);
 		if (rc == 0) { /* A timeout occurred, nothing to read from socket after 3 seconds */
-			log_println(
-					6,
-					"readn() routine timeout occurred, return error signal and kill off child");
+			log_println(6, "readn() routine timeout occurred, return error signal and kill off child");
 			return received;
 		}
 		if ((rc == -1) && (errno == EINTR)) /* a signal was processed, ignore it */
diff --git a/src/test_c2s_srv.c b/src/test_c2s_srv.c
index 4c4f853..daf0b47 100644
--- a/src/test_c2s_srv.c
+++ b/src/test_c2s_srv.c
@@ -85,8 +85,8 @@ int test_c2s(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
 	pthread_t workerThreadId;
 
 	// web_100 related variables
-	web100_group* group;
-	web100_connection* conn;
+	web100_group* group = NULL;
+	web100_connection* conn = NULL;
 
 	// snap related variables
 	SnapArgs snapArgs;
@@ -101,7 +101,6 @@ int test_c2s(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
 	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
 	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
 	char namesuffix[256] = "c2s_snaplog";
-	char currenttestdesc[TEST_NAME_DESC_SIZE] = "c2s" ;
 
 	if (testOptions->c2sopt) {
 		setCurrentTest(TEST_C2S);
@@ -269,7 +268,7 @@ int test_c2s(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
 						5,
 						"C2S test Child %d thinks pipe() returned fd0=%d, fd1=%d",
 						testOptions->child0, mon_pipe1[0], mon_pipe1[1]);
-			    log_println(2, "C2S test calling init_pkttrace() with pd=0x%x", (int) &cli_addr);
+			    log_println(2, "C2S test calling init_pkttrace() with pd=%p", &cli_addr);
 				init_pkttrace(src_addr, (struct sockaddr *) &cli_addr, clilen,
 						mon_pipe1, device, &pair, "c2s", options->compress);
 				exit(0); /* Packet trace finished, terminate gracefully */
diff --git a/src/test_mid_clt.c b/src/test_mid_clt.c
index 85a07a0..2234804 100644
--- a/src/test_mid_clt.c
+++ b/src/test_mid_clt.c
@@ -51,7 +51,7 @@ int test_mid_clt(int ctlSocket, char tests, char* host, int conn_options,
 	int msgLen, msgType;
 	int midport = atoi(PORT3);
 	I2Addr sec_addr = NULL;
-	int retcode, one=1, i, inlth;
+	int retcode, i, inlth;
 	int in2Socket;
 	double t, spdin;
 	uint32_t bytes;
diff --git a/src/test_results_clt.c b/src/test_results_clt.c
index 8afe35a..b9a0ccc 100644
--- a/src/test_results_clt.c
+++ b/src/test_results_clt.c
@@ -87,20 +87,16 @@ void print_results_mismatchcheck(int mismatch) {
 		printf("Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
 		break;
 	case DUPLEX_SWITCH_FULL_HOST_HALF_POSS:
-		printf(
-				"Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+		printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
 		break;
 	case DUPLEX_SWITCH_HALF_HOST_FULL:
-		printf(
-				"Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+		printf("Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
 		break;
 	case DUPLEX_SWITCH_HALF_HOST_FULL_POSS:
-		printf(
-				"Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+		printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
 		break;
 	case DUPLEX_SWITCH_HALF_HOST_FULL_WARN:
-		printf(
-				"Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+		printf("Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
 		break;
 	}
 }
@@ -126,7 +122,7 @@ void print_recommend_buffersize(double rwin, double rttsec, double avgrtt,
 	if (((rwin*2)/rttsec) < mylink) {
 		j = (float)((mylink * avgrtt)*1000) / 8;
 		if ((int)j > max_RwinRcvd) {
-			printf("Information: The receive buffer should be %0.0f ", j/1024);
+			printf("Information: The receive buffer should be %0.0f ", j/1024.0f);
 			printf("kbytes to maximize throughput\n");
 		}
 	}
@@ -148,7 +144,7 @@ void check_badcable(int is_bad_cable) {
  * */
 void check_congestion(int is_congested) {
 	if (is_congested == POSSIBLE_CONGESTION) {
-        printf("Information: Other network traffic is congesting the link\n");
+                printf("Information: Other network traffic is congesting the link\n");
 	}
 }
 
@@ -225,8 +221,7 @@ void print_packetloss_statistics(int PktsRetrans, int DupAcksIn, int SACKsRcvd,
 			printf("The connection stalled %d times due to packet loss.\n",
 					Timeouts);
 		if (waitsec > 0)
-			printf(
-					"The connection was idle %0.2f seconds (%0.2f%%) of the time.\n",
+			printf("The connection was idle %0.2f seconds (%0.2f%%) of the time.\n",
 					waitsec, (100 * waitsec / totaltesttime));
 	} else if (DupAcksIn > 0) {
 		printf("No packet loss - ");
@@ -263,16 +258,14 @@ void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, doub
 		printf("This connection is receiver limited %0.2f%% of the time.\n",
 				rwintime * 100);
 		if ((2 * (rwin / rttsec)) < mylinkspeed)
-			printf(
-					"  Increasing the current receive buffer (%0.2f KB) will improve performance\n",
+			printf("  Increasing the current receive buffer (%0.2f KB) will improve performance\n",
 					(float) max_rwinrcvd / KILO_BITS);
 	}
 	if (sendtime > .015) {
 		printf("This connection is sender limited %0.2f%% of the time.\n",
 				sendtime * 100);
 		if ((2 * (swin / rttsec)) < mylinkspeed)
-			printf(
-					"  Increasing the current send buffer (%0.2f KB) will improve performance\n",
+			printf("  Increasing the current send buffer (%0.2f KB) will improve performance\n",
 					(float) sndbuf / KILO_BITS);
 	}
 	if (cwndtime > .005) {
@@ -289,8 +282,7 @@ void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, doub
  */
 void print_packetloss_excess(double spd, double loss) {
 	if ((spd < 4) && (loss > .01)) {
-		printf(
-				"Excessive packet loss is impacting your performance, check the ");
+		printf("Excessive packet loss is impacting your performance, check the ");
 		printf("auto-negotiate function on your local PC and network switch\n");
 	}
 }
@@ -388,16 +380,13 @@ void print_throughputlimits(int max_rwinrcvd, int rcvwinscale, int *sndbuf,
 
 	printf("The theoretical network limit is %0.2f Mbps\n", estimate);
 
-	printf(
-			"The NDT server has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
+	printf("The NDT server has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
 			(float) tempsendbuf / KILO_BITS, (float) s_win / rttsec);
 
-	printf(
-			"Your PC/Workstation has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
+	printf("Your PC/Workstation has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
 			(float) max_rwinrcvd / KILO_BITS, (float) r_win / rttsec);
 
-	printf(
-			"The network based flow control limits the throughput to %0.2f Mbps\n",
+	printf("The network based flow control limits the throughput to %0.2f Mbps\n",
 			(float) c_win / rttsec);
 
 }
@@ -415,12 +404,10 @@ void print_throughputlimits(int max_rwinrcvd, int rcvwinscale, int *sndbuf,
 void print_linkspeed_dataacks(int isC2S_enabled, int c2s_linkspeed_data,
 		int c2s_linkspeed_ack, int s2c_linkspeed_data, int s2c_linkspeed_ack) {
 	if (isC2S_enabled) {
-		printf(
-				"\nClient Data reports link is '%3d', Client Acks report link is '%3d'\n",
+		printf("\nClient Data reports link is '%3d', Client Acks report link is '%3d'\n",
 				c2s_linkspeed_data, c2s_linkspeed_ack);
 	}
-	printf(
-			"Server Data reports link is '%3d', Server Acks report link is '%3d'\n",
+	printf("Server Data reports link is '%3d', Server Acks report link is '%3d'\n",
 			s2c_linkspeed_data, s2c_linkspeed_ack);
 
 }
@@ -473,8 +460,7 @@ void check_MSS_modification(int is_timestampenabled, int *mssvalue) {
 		if (*mssvalue == 1456)
 			printf("Packet size is preserved End-to-End\n");
 		else
-			printf(
-					"Information: Network Middlebox is modifying MSS variable (changed to %d)\n",
+			printf("Information: Network Middlebox is modifying MSS variable (changed to %d)\n",
 					*mssvalue);
 
 }
diff --git a/src/test_s2c_clt.c b/src/test_s2c_clt.c
index cf47cdf..4b224e9 100644
--- a/src/test_s2c_clt.c
+++ b/src/test_s2c_clt.c
@@ -57,8 +57,6 @@ int test_s2c_clt(int ctlSocket, char tests, char* host, int conn_options,
 	// variables used for protocol validation logs
 	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
 	enum TEST_ID testids = S2C;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
 
 	if (tests & TEST_S2C) {
 		setCurrentTest(TEST_S2C);
diff --git a/src/testoptions.c b/src/testoptions.c
index d1294f5..0761c82 100644
--- a/src/testoptions.c
+++ b/src/testoptions.c
@@ -312,8 +312,7 @@ void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* pea
  * @param snaplogenabled boolean indication whether snap logging is enabled
  * @param snapArgs_ptr  pointer to a snapArgs object
  * */
-void stop_snap_worker(int *workerThreadId, char snaplogenabled,
-		SnapArgs* snapArgs_ptr) {
+void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs* snapArgs_ptr) {
 	if (*workerThreadId) {
 		pthread_mutex_lock(&mainmutex);
 		workerLoop = 0;
@@ -362,7 +361,7 @@ void start_packet_trace(int socketfdarg, int socketfdarg2, pid_t *childpid,
 				testindicatorarg, imonarg[0], imonarg[1]);
 
 		init_pkttrace(src_addr, cliaddrarg, clilenarg, imonarg, device,
-				&pairarg, testindicatorarg, iscompressionenabled);
+			      pairarg, testindicatorarg, iscompressionenabled);
 
 		exit(0); // Packet trace finished, terminate gracefully
 	}
diff --git a/src/testoptions.h b/src/testoptions.h
index e434677..6a467cc 100644
--- a/src/testoptions.h
+++ b/src/testoptions.h
@@ -74,8 +74,7 @@ void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* pea
                 char *metafilevariablename, char *metafilename, web100_connection* conn,
                 web100_group* group);
 
-void stop_snap_worker(int *workerThreadId, char snaplogenabled,
-                SnapArgs* snapArgs_ptr);
+void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs* snapArgs_ptr);
 
 void setCwndlimit(web100_connection* connarg, web100_group* grouparg,
 		web100_agent* agentarg, Options* optionsarg);
diff --git a/src/troute.c b/src/troute.c
index 710a1e6..74049c7 100644
--- a/src/troute.c
+++ b/src/troute.c
@@ -398,7 +398,7 @@ int packet_ok(buf, cc, from, seq)
 	 * Subtract 2 timeval structs:  out = out - in.
 	 * Out is assumed to be >= in.
 	 */
-voidtvsub (out, in)
+void tvsub (out, in)
 	register struct timeval *out, *in; {
 	if ((out->tv_usec -= in->tv_usec) < 0) {
 		out->tv_sec--;
@@ -406,4 +406,3 @@ voidtvsub (out, in)
 	}
 	out->tv_sec -= in->tv_sec;
 }
-
diff --git a/src/troute6.c b/src/troute6.c
index 350c6fc..8f9bea8 100644
--- a/src/troute6.c
+++ b/src/troute6.c
@@ -303,19 +303,19 @@ char copyright[] =
 
 struct ipv6hdr {
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-	__u8 priority:4,
+__extension__	__u8 priority:4,
 	version:4;
 #elif defined(__BIG_ENDIAN_BITFIELD)
-	__u8 version:4,
+__extension__	__u8 version:4,
 	priority:4;
 #else
 #error  "Please fix <asm/byteorder.h>"
 #endif
-	__u8 flow_lbl[3];
+__extension__	__u8 flow_lbl[3];
 
-	__u16 payload_len;
-	__u8 nexthdr;
-	__u8 hop_limit;
+__extension__	__u16 payload_len;
+__extension__	__u8 nexthdr;
+__extension__	__u8 hop_limit;
 
 	struct in6_addr saddr;
 	struct in6_addr daddr;
@@ -644,9 +644,10 @@ char * pr_type(unsigned char t)
 		return (ttab1[t]);
 	}
 
-	if (t >= 128 && t <= 131)
+        unsigned char newt = t - 128;
+	if (newt < 5)
 	{
-		return (ttab2[t]);
+		return (ttab2[newt]);
 	}
 
 	return("OUT-OF-RANGE");
diff --git a/src/viewtrace.c b/src/viewtrace.c
index 430943a..113c4d7 100644
--- a/src/viewtrace.c
+++ b/src/viewtrace.c
@@ -23,6 +23,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/errno.h>
+#include <getopt.h>
 
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
diff --git a/src/web100-admin.c b/src/web100-admin.c
index 5688b27..e09f9fb 100644
--- a/src/web100-admin.c
+++ b/src/web100-admin.c
@@ -551,7 +551,7 @@ void gen_html(int c2sspd, int s2cspd, int MinRTT, int PktsRetrans, int Timeouts,
 		return;
 	}
 	lock.l_type = F_WRLCK;
-	i = fcntl((int) fp, F_SETLKW, lock);
+	i = fcntl(fileno(fp), F_SETLKW, lock);
 	log_println(1, "successfully locked '/tmp/view.string' for updating");
 	sprintf(
 			view_string,
@@ -564,7 +564,7 @@ void gen_html(int c2sspd, int s2cspd, int MinRTT, int PktsRetrans, int Timeouts,
 	log_println(1, "sending '%s' to tmp file", view_string);
 	fprintf(fp, "%s\n", view_string);
 	lock.l_type = F_UNLCK;
-	fcntl((int) fp, F_SETLK, lock);
+	fcntl(fileno(fp), F_SETLK, lock);
 	fclose(fp);
 }
 
diff --git a/src/web100-pcap.c b/src/web100-pcap.c
index 06e0936..418d270 100644
--- a/src/web100-pcap.c
+++ b/src/web100-pcap.c
@@ -795,11 +795,9 @@ void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
 	struct sockaddr *src_addr;
 	pcap_if_t *alldevs, *dp;
 	pcap_addr_t *curAddr;
-	DIR *dip;
 	int rc;
 
 	char logdir[256];
-	char logfilesuffix[256] = "ndttrace"; // logfile suffix
 
 	cnt = -1; /* read forever, or until end of file */
 	sig1 = 0;
@@ -963,7 +961,7 @@ void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
 		fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
 	}
 
-	log_println(2, "pcap_open_live() returned pointer 0x%x", (int) pd);
+	log_println(2, "pcap_open_live() returned pointer %p", pd);
 
 	memset(namebuf, 0, 200);
 	I2AddrNodeName(sockAddr, namebuf, &nameBufLen);
@@ -971,7 +969,7 @@ void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
 	sprintf(cmdbuf, "host %s and port %d", namebuf, I2AddrPort(sockAddr));
 
 	log_println(1, "installing pkt filter for '%s'", cmdbuf);
-	log_println(1, "Initial pkt src data = %x", (int) fwd.saddr);
+	log_println(1, "Initial pkt src data = %p", fwd.saddr);
 
 	if (pcap_compile(pd, &fcode, cmdbuf, 0, 0xFFFFFF00) < 0) {
 		fprintf(stderr, "pcap_compile failed %s\n", pcap_geterr(pd));
diff --git a/src/web100-util.c b/src/web100-util.c
index 785097c..47da588 100644
--- a/src/web100-util.c
+++ b/src/web100-util.c
@@ -682,8 +682,8 @@ int web100_logvars(int *Timeouts, int *SumRTT, int *CountRTT, int *PktsRetrans,
  * @return Integer, 0 on success, -1 on failure
  */
 
-int CwndDecrease(web100_agent* agent, char* logname, int *dec_cnt,
-		int *same_cnt, int *inc_cnt) {
+int CwndDecrease(web100_agent* agent, char* logname, u_int32_t *dec_cnt,
+		u_int32_t *same_cnt, u_int32_t *inc_cnt) {
 
 	web100_var* var;
 	char buff[256];
@@ -719,8 +719,7 @@ int CwndDecrease(web100_agent* agent, char* logname, int *dec_cnt,
 		rt = web100_snap_read(var, snap, buff);
 		s2 = atoi(web100_value_to_text(web100_get_var_type(var), buff));
 		if (cnt < 20) {
-			log_println(7, "Reading snaplog 0x%x (%d), var = %s", (int) snap,
-					cnt, (char*) var);
+			log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt, (char*) var);
 			log_println(
 					7,
 					"Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d (%s), dec-cnt=%d",
diff --git a/src/web100clt.c b/src/web100clt.c
index 86d537b..7c0d12b 100644
--- a/src/web100clt.c
+++ b/src/web100clt.c
@@ -1,12 +1,12 @@
 #include "../config.h"
 
+#include <ctype.h>
 #include <errno.h>
-#include <string.h>
 #include <getopt.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include <string.h>
 #include <time.h>
-#include <ctype.h>
+#include <unistd.h>
 
 #include "network.h"
 #include "usage.h"
@@ -828,7 +828,7 @@ int main(int argc, char *argv[]) {
 	for (;;) {
 		msgLen = sizeof(buff);
 		memset(buff, 0, msgLen); // reset buff and msgLen
-		if (retcode = (recv_msg(ctlSocket, &msgType, buff, &msgLen))) {
+		if ((retcode = (recv_msg(ctlSocket, &msgType, buff, &msgLen)))) {
 			if (errno == ECONNRESET)
 				log_println(0,
 						"Connection closed by server, No test performed.");
diff --git a/src/web100srv.c b/src/web100srv.c
index a7518a9..1313c71 100644
--- a/src/web100srv.c
+++ b/src/web100srv.c
@@ -64,10 +64,11 @@
 
 #include <time.h>
 #include <ctype.h>
+#include <getopt.h>
 #include <math.h>
 #define SYSLOG_NAMES
-#include  <syslog.h>
 #include <pthread.h>
+#include <syslog.h>
 #include <sys/times.h>
 
 #include "web100srv.h"
@@ -993,7 +994,8 @@ int run_test(web100_agent* agent, int ctlsockfd, TestOptions* testopt,
 	//int j;        // commented out -> calc_linkspeed
 	int totalcnt;
 	int autotune;
-	int dec_cnt, same_cnt, inc_cnt, timeout, dupack; // values collected from the speed tests
+	u_int32_t dec_cnt, same_cnt, inc_cnt; // values collected from the speed tests
+        int timeout, dupack;
 	//int ifspeed;
 
 	time_t stime;
@@ -1476,7 +1478,7 @@ int run_test(web100_agent* agent, int ctlsockfd, TestOptions* testopt,
  * @param argv string command line arguments
  * */
 int main(int argc, char** argv) {
-	pid_t chld_pid;
+	pid_t chld_pid = -1;
 	int retcode;
 	int tpid, mwaiting = 0;
 	int ctlsockfd = -1;
@@ -1502,7 +1504,6 @@ int main(int argc, char** argv) {
 	char isoTime[64], dir[256];
 	int debug = 0;
 
-	DIR *dp;
 	int j;
 	char *name;
 
@@ -2722,4 +2723,3 @@ int main(int argc, char** argv) {
 char *get_remotehost() {
 	return rmt_host;
 }
-
diff --git a/src/web100srv.h b/src/web100srv.h
index 97ffa1f..5c1ea71 100644
--- a/src/web100srv.h
+++ b/src/web100srv.h
@@ -24,9 +24,8 @@
 #endif
 #include  <stdlib.h>
 #include  <string.h>
-#include  <unistd.h>
 #include  <fcntl.h>
-#include  <getopt.h>
+#include  <unistd.h>
 
 #include  <sys/types.h>
 #include  <sys/socket.h>
@@ -207,7 +206,8 @@ void web100_middlebox(int sock, web100_agent* agent, web100_connection* cn, char
 int web100_setbuff(int sock, web100_agent* agent, web100_connection* cn, int autotune);
 void web100_get_data_recv(int sock, web100_agent* agent, web100_connection* cn, int count_vars);
 int web100_get_data(web100_snapshot* snap, int ctlsock, web100_agent* agent, int count_vars);
-int CwndDecrease(web100_agent* agent, char* logname, int *dec_cnt, int *same_cnt, int *inc_cnt);
+int CwndDecrease(web100_agent* agent, char* logname,
+                 u_int32_t *dec_cnt, u_int32_t *same_cnt, u_int32_t *inc_cnt);
 int web100_logvars(int *Timeouts, int *SumRTT, int *CountRTT,
 		int *PktsRetrans, int *FastRetran, int *DataPktsOut, int *AckPktsOut,
 		int *CurrentMSS, int *DupAcksIn, int *AckPktsIn, int *MaxRwinRcvd,



Archive powered by MHonArc 2.6.16.

Top of Page