svn commit: r229247 - in stable/9/usr.sbin/timed: timed timedc
Dimitry Andric
dim at FreeBSD.org
Sun Jan 1 23:49:12 UTC 2012
Author: dim
Date: Sun Jan 1 23:49:11 2012
New Revision: 229247
URL: http://svn.freebsd.org/changeset/base/229247
Log:
MFC r228714:
In usr.sbin/timed, fix several issues with printf formats:
- Cast time_t's to long, and print them with %ld.
- Print ptrdiff_t's with %td.
- Print ssize_t's and size_t's with %zd and %zu.
- Print int32_t's with %d.
Also, replace some int variables with the more appropriate size_t.
MFC r228719:
Some people pointed out long is 32-bit on some arches, while time_t is
64-bit, so better cast time_t to intmax_t, and use the appropriate
printf format strings.
MFC r228720:
Fix r228719; when you use intmax_t, you need stdint.h.
Pointy hat to: dim
Modified:
stable/9/usr.sbin/timed/timed/correct.c
stable/9/usr.sbin/timed/timed/globals.h
stable/9/usr.sbin/timed/timed/networkdelta.c
stable/9/usr.sbin/timed/timed/readmsg.c
stable/9/usr.sbin/timed/timedc/cmds.c
Directory Properties:
stable/9/usr.sbin/timed/ (props changed)
Modified: stable/9/usr.sbin/timed/timed/correct.c
==============================================================================
--- stable/9/usr.sbin/timed/timed/correct.c Sun Jan 1 23:46:34 2012 (r229246)
+++ stable/9/usr.sbin/timed/timed/correct.c Sun Jan 1 23:49:11 2012 (r229247)
@@ -162,8 +162,8 @@ adjclock(corr)
}
} else {
syslog(LOG_WARNING,
- "clock correction %ld sec too large to adjust",
- adj.tv_sec);
+ "clock correction %jd sec too large to adjust",
+ (intmax_t)adj.tv_sec);
(void) gettimeofday(&now, 0);
timevaladd(&now, corr);
if (settimeofday(&now, 0) < 0)
Modified: stable/9/usr.sbin/timed/timed/globals.h
==============================================================================
--- stable/9/usr.sbin/timed/timed/globals.h Sun Jan 1 23:46:34 2012 (r229246)
+++ stable/9/usr.sbin/timed/timed/globals.h Sun Jan 1 23:49:11 2012 (r229247)
@@ -41,6 +41,7 @@
#include <errno.h>
#include <limits.h>
#include <netdb.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Modified: stable/9/usr.sbin/timed/timed/networkdelta.c
==============================================================================
--- stable/9/usr.sbin/timed/timed/networkdelta.c Sun Jan 1 23:46:34 2012 (r229246)
+++ stable/9/usr.sbin/timed/timed/networkdelta.c Sun Jan 1 23:49:11 2012 (r229247)
@@ -137,7 +137,7 @@ networkdelta()
}
if (trace)
- fprintf(fd, "median of %d values starting at %ld is ",
+ fprintf(fd, "median of %td values starting at %ld is ",
xp-&x[0], med);
return median(med, &eps, &x[0], xp, 1);
}
Modified: stable/9/usr.sbin/timed/timed/readmsg.c
==============================================================================
--- stable/9/usr.sbin/timed/timed/readmsg.c Sun Jan 1 23:46:34 2012 (r229246)
+++ stable/9/usr.sbin/timed/timed/readmsg.c Sun Jan 1 23:49:11 2012 (r229247)
@@ -182,8 +182,8 @@ again:
rwait.tv_usec = 1000000/CLK_TCK;
if (trace) {
- fprintf(fd, "readmsg: wait %ld.%6ld at %s\n",
- rwait.tv_sec, rwait.tv_usec, date());
+ fprintf(fd, "readmsg: wait %jd.%6ld at %s\n",
+ (intmax_t)rwait.tv_sec, rwait.tv_usec, date());
/* Notice a full disk, as we flush trace info.
* It is better to flush periodically than at
* every line because the tracing consists of bursts
@@ -215,7 +215,7 @@ again:
*/
if (n < (ssize_t)(sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
syslog(LOG_NOTICE,
- "short packet (%u/%u bytes) from %s",
+ "short packet (%zd/%zu bytes) from %s",
n, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
inet_ntoa(from.sin_addr));
continue;
@@ -487,7 +487,7 @@ print(msg, addr)
break;
case TSP_ADJTIME:
- fprintf(fd, "%s %d %-6u (%ld,%ld) %-15s %s\n",
+ fprintf(fd, "%s %d %-6u (%d,%d) %-15s %s\n",
tsptype[msg->tsp_type],
msg->tsp_vers,
msg->tsp_seq,
Modified: stable/9/usr.sbin/timed/timedc/cmds.c
==============================================================================
--- stable/9/usr.sbin/timed/timedc/cmds.c Sun Jan 1 23:46:34 2012 (r229246)
+++ stable/9/usr.sbin/timed/timedc/cmds.c Sun Jan 1 23:49:11 2012 (r229247)
@@ -267,7 +267,7 @@ msite(argc, argv)
int argc;
char *argv[];
{
- int cc;
+ ssize_t cc;
fd_set ready;
struct sockaddr_in dest;
int i, length;
@@ -333,7 +333,7 @@ msite(argc, argv)
*/
if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
fprintf(stderr,
- "short packet (%u/%u bytes) from %s\n",
+ "short packet (%zd/%zu bytes) from %s\n",
cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
inet_ntoa(from.sin_addr));
continue;
@@ -428,7 +428,7 @@ tracing(argc, argv)
{
int onflag;
int length;
- int cc;
+ ssize_t cc;
fd_set ready;
struct sockaddr_in dest;
struct sockaddr_in from;
@@ -489,7 +489,7 @@ tracing(argc, argv)
* least long enough to hold a 4.3BSD packet.
*/
if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
- fprintf(stderr, "short packet (%u/%u bytes) from %s\n",
+ fprintf(stderr, "short packet (%zd/%zu bytes) from %s\n",
cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
inet_ntoa(from.sin_addr));
return;
More information about the svn-src-stable-9
mailing list