1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-04 12:52:15 +00:00

Clean up tools in tools/tools/netrate.

- tcpconnect incorrectly uses err() in usage() with errx() semantics [1]
  That produces dirty error message:
  tcpconnect: usage: tcpconnect [ip]: Unknown error: 0
- 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)
MFC after:	1 week
This commit is contained in:
Sergey Kandaurov 2010-10-08 14:31:49 +00:00
parent 0d9deed52c
commit cd94bb1e54
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=213574
2 changed files with 11 additions and 6 deletions

View File

@ -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");

View File

@ -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);
}