Author: dim
Date: Mon Dec 19 18:08:31 2011
New Revision: 228714
URL: http://svn.freebsd.org/changeset/base/228714

Log:
  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 after:    1 week

Modified:
  head/usr.sbin/timed/timed/correct.c
  head/usr.sbin/timed/timed/networkdelta.c
  head/usr.sbin/timed/timed/readmsg.c
  head/usr.sbin/timed/timedc/cmds.c

Modified: head/usr.sbin/timed/timed/correct.c
==============================================================================
--- head/usr.sbin/timed/timed/correct.c Mon Dec 19 17:32:54 2011        
(r228713)
+++ head/usr.sbin/timed/timed/correct.c Mon Dec 19 18:08:31 2011        
(r228714)
@@ -163,7 +163,7 @@ adjclock(corr)
        } else {
                syslog(LOG_WARNING,
                       "clock correction %ld sec too large to adjust",
-                      adj.tv_sec);
+                      (long)adj.tv_sec);
                (void) gettimeofday(&now, 0);
                timevaladd(&now, corr);
                if (settimeofday(&now, 0) < 0)

Modified: head/usr.sbin/timed/timed/networkdelta.c
==============================================================================
--- head/usr.sbin/timed/timed/networkdelta.c    Mon Dec 19 17:32:54 2011        
(r228713)
+++ head/usr.sbin/timed/timed/networkdelta.c    Mon Dec 19 18:08:31 2011        
(r228714)
@@ -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: head/usr.sbin/timed/timed/readmsg.c
==============================================================================
--- head/usr.sbin/timed/timed/readmsg.c Mon Dec 19 17:32:54 2011        
(r228713)
+++ head/usr.sbin/timed/timed/readmsg.c Mon Dec 19 18:08:31 2011        
(r228714)
@@ -182,7 +182,7 @@ again:
 
                if (trace) {
                        fprintf(fd, "readmsg: wait %ld.%6ld at %s\n",
-                               rwait.tv_sec, rwait.tv_usec, date());
+                               (long)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
@@ -214,7 +214,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;
@@ -486,7 +486,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: head/usr.sbin/timed/timedc/cmds.c
==============================================================================
--- head/usr.sbin/timed/timedc/cmds.c   Mon Dec 19 17:32:54 2011        
(r228713)
+++ head/usr.sbin/timed/timedc/cmds.c   Mon Dec 19 18:08:31 2011        
(r228714)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to