[netperf-dev] netperf2 commit notice r513 - trunk/src
raj at netperf.org
raj at netperf.org
Fri Dec 2 15:22:35 PST 2011
Author: raj
Date: 2011-12-02 15:22:34 -0800 (Fri, 02 Dec 2011)
New Revision: 513
Modified:
trunk/src/nettest_bsd.c
trunk/src/nettest_omni.c
Log:
switch a buffer from the stack to the heap to make valgrind happy and perhaps even fix a bug?
Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c 2011-12-02 19:36:26 UTC (rev 512)
+++ trunk/src/nettest_bsd.c 2011-12-02 23:22:34 UTC (rev 513)
@@ -1664,17 +1664,26 @@
print_top_test_header(char test_name[], struct addrinfo *source, struct addrinfo *destination)
{
-#if defined(AF_INET6)
- char address_buf[INET6_ADDRSTRLEN];
+ char *address_buf;
+
+#ifdef AF_INET6
+ address_buf = malloc(INET6_ADDRSTRLEN);
#else
- char address_buf[16]; /* magic constant */
+ address_buf = malloc(16); /* magic constant */
#endif
- /* we want to have some additional, interesting information in */
- /* the headers. we know some of it here, but not all, so we will */
- /* only print the test title here and will print the results */
- /* titles after the test is finished */
+ if (address_buf == NULL) {
+ fprintf(where,"Unable to allocate address_buf\n");
+ fflush(where);
+ exit(1);
+ }
+
+ /* we want to have some additional, interesting information in the
+ headers. we know some of it here, but not all, so we will only
+ print the test title here and will print the results titles after
+ the test is finished */
fprintf(where,"%s",test_name);
+
address_buf[0] = '\0';
inet_ntop(source->ai_family,get_address_address(source),address_buf,sizeof(address_buf));
fprintf(where,
@@ -1683,6 +1692,7 @@
address_buf,
get_port_number(source),
inet_ftos(source->ai_family));
+
address_buf[0] = '\0';
inet_ntop(destination->ai_family,get_address_address(destination),address_buf,sizeof(address_buf));
fprintf(where,
@@ -1743,7 +1753,8 @@
fprintf(where," : cpu bind");
}
fprintf(where,"\n");
-
+
+ free(address_buf);
}
/* if WANT_MIGRATION is defined, we will use the send_tcp_stream()
Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c 2011-12-02 19:36:26 UTC (rev 512)
+++ trunk/src/nettest_omni.c 2011-12-02 23:22:34 UTC (rev 513)
@@ -4596,6 +4596,7 @@
{
char name_buf[32];
snprintf(name_buf,sizeof(name_buf),"OMNI %s TEST",direction_str);
+ name_buf[31] = '\0';
send_omni_inner(remote_host, 0, name_buf);
}
More information about the netperf-dev
mailing list