Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Oct 2010 14:09:17 +0000 (UTC)
From:      Sergey Kandaurov <pluknet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r214057 - in stable/8/tools/tools/netrate: juggle tcpconnect
Message-ID:  <201010191409.o9JE9HBI016977@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pluknet
Date: Tue Oct 19 14:09:17 2010
New Revision: 214057
URL: http://svn.freebsd.org/changeset/base/214057

Log:
  MFC r213574:
  - tcpconnect incorrectly uses err() in usage() with errx() semantics [1]
  - 64-bit aware fixes in printf() usage [2]
  o   netrate/juggle: time_t has arch-dependent size
  o   netrate/tcpconnect: don't assume %ll has always 64bit.
  
  PR:		146088 [1], 146086 [2] (modified)
  Approved by:	kib (mentor)

Modified:
  stable/8/tools/tools/netrate/juggle/juggle.c
  stable/8/tools/tools/netrate/tcpconnect/tcpconnect.c
Directory Properties:
  stable/8/tools/tools/netrate/   (props changed)
  stable/8/tools/tools/netrate/tcpp/   (props changed)

Modified: stable/8/tools/tools/netrate/juggle/juggle.c
==============================================================================
--- stable/8/tools/tools/netrate/juggle/juggle.c	Tue Oct 19 13:31:43 2010	(r214056)
+++ stable/8/tools/tools/netrate/juggle/juggle.c	Tue Oct 19 14:09:17 2010	(r214057)
@@ -28,6 +28,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/stdint.h>
 #include <sys/time.h>
 #include <sys/utsname.h>
 #include <sys/wait.h>
@@ -557,7 +558,8 @@ main(int argc, char *argv[])
 				if (j != 0)
 					printf(", ");
 				scale_timespec(&juggle_results[j], p);
-				printf("%u.%09lu", juggle_results[j].tv_sec,
+				printf("%jd.%09lu",
+				    (intmax_t)juggle_results[j].tv_sec,
 				    juggle_results[j].tv_nsec);
 			}
 			printf("\n");
@@ -567,7 +569,8 @@ main(int argc, char *argv[])
 				if (j != 0)
 					printf(", ");
 				scale_timespec(&process_results[j], p);
-				printf("%u.%09lu", process_results[j].tv_sec,
+				printf("%jd.%09lu",
+                                    (intmax_t)process_results[j].tv_sec,
 				    process_results[j].tv_nsec);
 			}
 			printf("\n");
@@ -577,7 +580,8 @@ main(int argc, char *argv[])
 				if (j != 0)
 					printf(", ");
 				scale_timespec(&thread_results[j], p);
-				printf("%u.%09lu", thread_results[j].tv_sec,
+				printf("%jd.%09lu",
+				    (intmax_t)thread_results[j].tv_sec,
 				    thread_results[j].tv_nsec);
 			}
 			printf("\n");

Modified: stable/8/tools/tools/netrate/tcpconnect/tcpconnect.c
==============================================================================
--- stable/8/tools/tools/netrate/tcpconnect/tcpconnect.c	Tue Oct 19 13:31:43 2010	(r214056)
+++ stable/8/tools/tools/netrate/tcpconnect/tcpconnect.c	Tue Oct 19 14:09:17 2010	(r214057)
@@ -31,6 +31,7 @@
 #include <sys/ioctl.h>
 #include <sys/select.h>
 #include <sys/socket.h>
+#include <sys/stdint.h>
 
 #include <netinet/in.h>
 
@@ -110,7 +111,7 @@ main(int argc, char *argv[])
 	u_int64_t counter;
 
 	if (argc != 2)
-		err(-1, "usage: tcpconnect [ip]");
+		errx(-1, "usage: tcpconnect [ip]");
 
 	bzero(&sin, sizeof(sin));
 	sin.sin_family = AF_INET;
@@ -128,8 +129,8 @@ main(int argc, char *argv[])
 		if (try_connect(&sin) == 0)
 			counter++;
 	}
-	printf("%llu count\n", counter);
-	printf("%llu connections/second\n", counter / SECONDS);
+	printf("%ju count\n", (uintmax_t)counter);
+	printf("%ju connections/second\n", (uintmax_t)(counter / SECONDS));
 
 	return (0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010191409.o9JE9HBI016977>