AMD64 - AUDIT RUN - Fix format strings, size_t, and other issues
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 21 Aug 2009 10:41:09 +0000 (03:41 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 21 Aug 2009 10:41:09 +0000 (03:41 -0700)
80 files changed:
bin/dd/args.c
bin/dd/misc.c
bin/sh/mksyntax.c
bin/sh/parser.c
contrib/com_err/getarg.c
contrib/libevent/kqueue.c
contrib/ncurses-5.4/ncurses/trace/lib_tracechr.c
contrib/opie/libopie/generator.c
contrib/opie/libopie/lookup.c
contrib/opie/libopie/newseed.c
contrib/opie/libopie/passwd.c
contrib/opie/libopie/randomchallenge.c
contrib/opie/libopie/version.c
contrib/sendmail-8.14/libmilter/listener.c
contrib/smbfs/lib/smb/file.c
contrib/smbfs/lib/smb/kiconv.c
contrib/smbfs/lib/smb/nb_net.c
contrib/smbfs/lib/smb/nls.c
contrib/smbfs/lib/smb/rap.c
contrib/smbfs/lib/smb/rq.c
contrib/tcp_wrappers/options.c
contrib/tcp_wrappers/shell_cmd.c
gnu/lib/libdialog/rc.c
gnu/usr.bin/sort/getopt.c
lib/libc/gen/nlist.c
lib/libc_r/uthread/uthread_sig.c
lib/libcompat/4.3/rexec.c
lib/libncp/ncpl_conn.c
lib/libncp/ncpl_subr.c
lib/libsctp/sctp_sys_calls.c
lib/libthread_xu/thread/thr_private.h
libexec/rtld-elf/debug.c
sbin/camcontrol/camcontrol.c
sbin/camcontrol/util.c
sbin/diskinfo/diskinfo.c
sbin/disklabel64/disklabel64.c
sbin/dumpfs/dumpfs.c
sbin/fdisk/fdisk.c
sbin/fsdb/fsdb.c
sbin/fsirand/fsirand.c
sbin/growfs/growfs.c
sbin/hammer/cmd_blockmap.c
sbin/hammer/cmd_history.c
sbin/hammer/cmd_info.c
sbin/hammer/cmd_mirror.c
sbin/hammer/cmd_pseudofs.c
sbin/hammer/cmd_rebalance.c
sbin/hammer/cmd_reblock.c
sbin/hammer/cmd_show.c
sbin/hammer/cmd_snapshot.c
sbin/hammer/cmd_softprune.c
sbin/hammer/cmd_stats.c
sbin/hammer/cmd_synctid.c
sbin/hammer/cycle.c
sbin/hammer/hammer.c
sbin/jscan/dump_debug.c
sbin/jscan/jfile.c
sbin/jscan/jscan.c
sbin/jscan/jsession.c
sbin/jscan/jstream.c
sbin/jscan/subs.c
sbin/mountctl/mountctl.c
sbin/quotacheck/quotacheck.c
sbin/restore/tape.c
sbin/savecore/savecore.c
sbin/sysctl/sysctl.c
secure/lib/libssh/version.c
sys/netproto/smb/smb_dev.h
usr.bin/cmp/misc.c
usr.bin/cmp/regular.c
usr.bin/cmp/special.c
usr.bin/finger/lprint.c
usr.bin/finger/util.c
usr.bin/gprof/arcs.c
usr.bin/gprof/printgprof.c
usr.bin/limits/limits.c
usr.bin/monitor/monitor.c
usr.bin/tail/misc.c
usr.bin/tail/reverse.c
usr.bin/wc/wc.c

index 2ed9993..980047d 100644 (file)
@@ -159,8 +159,10 @@ jcl(char **argv)
        /*
         * Bail out if the calculation of a file offset would overflow.
         */
-       if (in.offset > QUAD_MAX / in.dbsz || out.offset > QUAD_MAX / out.dbsz)
+       if (in.offset > QUAD_MAX / (ssize_t)in.dbsz ||
+           out.offset > QUAD_MAX / (ssize_t)out.dbsz) {
                errx(1, "seek offsets cannot be larger than %lld", QUAD_MAX);
+       }
 }
 
 static int
@@ -178,7 +180,7 @@ f_bs(char *arg)
 
        res = get_num(arg);
        if (res < 1 || res > SSIZE_MAX)
-               errx(1, "bs must be between 1 and %d", SSIZE_MAX);
+               errx(1, "bs must be between 1 and %zd", SSIZE_MAX);
        in.dbsz = out.dbsz = (size_t)res;
 }
 
@@ -189,7 +191,7 @@ f_cbs(char *arg)
 
        res = get_num(arg);
        if (res < 1 || res > SSIZE_MAX)
-               errx(1, "cbs must be between 1 and %d", SSIZE_MAX);
+               errx(1, "cbs must be between 1 and %zd", SSIZE_MAX);
        cbsz = (size_t)res;
 }
 
@@ -221,7 +223,7 @@ f_ibs(char *arg)
        if (!(ddflags & C_BS)) {
                res = get_num(arg);
                if (res < 1 || res > SSIZE_MAX)
-                       errx(1, "ibs must be between 1 and %d", SSIZE_MAX);
+                       errx(1, "ibs must be between 1 and %zd", SSIZE_MAX);
                in.dbsz = (size_t)res;
        }
 }
@@ -241,7 +243,7 @@ f_obs(char *arg)
        if (!(ddflags & C_BS)) {
                res = get_num(arg);
                if (res < 1 || res > SSIZE_MAX)
-                       errx(1, "obs must be between 1 and %d", SSIZE_MAX);
+                       errx(1, "obs must be between 1 and %zd", SSIZE_MAX);
                out.dbsz = (size_t)res;
        }
 }
index 894e5d8..8a1c363 100644 (file)
@@ -60,22 +60,25 @@ summary(void)
                secs = 1e-6;
        /* Use snprintf(3) so that we don't reenter stdio(3). */
        snprintf(buf, sizeof(buf),
-           "%llu+%llu records in\n%llu+%llu records out\n",
-           st.in_full, st.in_part, st.out_full, st.out_part);
+           "%ju+%ju records in\n%ju+%ju records out\n",
+           (uintmax_t)st.in_full, (uintmax_t)st.in_part,
+           (uintmax_t)st.out_full, (uintmax_t)st.out_part);
        write(STDERR_FILENO, buf, strlen(buf));
        if (st.swab) {
-               snprintf(buf, sizeof(buf), "%llu odd length swab %s\n",
-                    st.swab, (st.swab == 1) ? "block" : "blocks");
+               snprintf(buf, sizeof(buf), "%ju odd length swab %s\n",
+                    (uintmax_t)st.swab,
+                    ((st.swab == 1) ? "block" : "blocks"));
                write(STDERR_FILENO, buf, strlen(buf));
        }
        if (st.trunc) {
-               snprintf(buf, sizeof(buf), "%llu truncated %s\n",
-                    st.trunc, (st.trunc == 1) ? "block" : "blocks");
+               snprintf(buf, sizeof(buf), "%ju truncated %s\n",
+                    (uintmax_t)st.trunc,
+                    ((st.trunc == 1) ? "block" : "blocks"));
                write(STDERR_FILENO, buf, strlen(buf));
        }
        snprintf(buf, sizeof(buf),
-           "%llu bytes transferred in %.6f secs (%.0f bytes/sec)\n",
-           st.bytes, secs, st.bytes / secs);
+           "%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n",
+           (uintmax_t)st.bytes, secs, st.bytes / secs);
        write(STDERR_FILENO, buf, strlen(buf));
 }
 
index 7a4e545..74dab7f 100644 (file)
@@ -385,7 +385,7 @@ digit_convert(void)
                for (p = digit ; *p && *p != i ; p++);
                if (*p == '\0')
                        p = digit;
-               fprintf(cfile, "      %d,\n", p - digit);
+               fprintf(cfile, "      %td,\n", p - digit);
        }
        fputs("};\n", cfile);
 }
index 96d9ff5..10ca2c0 100644 (file)
@@ -38,6 +38,7 @@
  * $DragonFly: src/bin/sh/parser.c,v 1.12 2007/01/18 17:03:18 corecode Exp $
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
index 6972e69..6978176 100644 (file)
@@ -43,6 +43,8 @@ RCSID("$Id: getarg.c,v 1.25 1998/11/22 09:45:05 assar Exp $");
 #include <sys/ttycom.h>
 #include <time.h>
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include "getarg.h"
 
 #define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag)
@@ -175,7 +177,8 @@ arg_printusage (struct getargs *args,
 static void
 add_string(getarg_strings *s, char *value)
 {
-    s->strings = realloc(s->strings, (s->num_strings + 1) * sizeof(*s->strings));
+    s->strings = realloc(s->strings,
+                        (s->num_strings + 1) * sizeof(*s->strings));
     s->strings[s->num_strings] = value;
     s->num_strings++;
 }
index 059d94a..cf0503c 100644 (file)
 /* Some platforms apparently define the udata field of struct kevent as
  * ntptr_t, whereas others define it as void*.  There doesn't seem to be an
  * easy way to tell them apart via autoconf, so we need to use OS macros. */
-#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__darwin__) && !defined(__APPLE__)
-#define PTR_TO_UDATA(x) ((intptr_t)(x))
-#else
-#define PTR_TO_UDATA(x) (x)
-#endif
+#define PTR_TO_UDATA(x) ((void *)(x))
 
 #include "event.h"
 #include "log.h"
index 5ceeed2..05647b8 100644 (file)
@@ -45,7 +45,7 @@ NCURSES_EXPORT(char *)
 _tracechar(int ch)
 {
     static char result[40];
-    char *name;
+    const char *name;
 
     if (ch > KEY_MIN || ch < 0) {
        name = keyname(ch);
index 0f2c95a..1ccedce 100644 (file)
@@ -34,6 +34,7 @@ $DragonFly: src/contrib/opie/libopie/generator.c,v 1.2 2003/06/17 04:24:05 dillo
 */
 
 #include "opie_cfg.h"
+#include <stdio.h>
 #if HAVE_STRING_H
 #include <string.h>
 #endif /* HAVE_STRING_H */
index 3003da7..de6d614 100644 (file)
@@ -13,6 +13,7 @@ you didn't get a copy, you may request one from <license@inner.net>.
 
 #include "opie_cfg.h"
 #include <stdio.h>
+#include <string.h>
 #include "opie.h"
 
 int opielookup FUNCTION((opie, principal), struct opie *opie AND char *principal)
index e91a3b5..8fd171f 100644 (file)
@@ -19,6 +19,7 @@ $DragonFly: src/contrib/opie/libopie/newseed.c,v 1.2 2003/06/17 04:24:05 dillon
 */
 
 #include "opie_cfg.h"
+#include <stdio.h>
 #if HAVE_TIME_H
 #include <time.h>
 #endif /* HAVE_TIME_H */
index 1c3b1ab..0ee0503 100644 (file)
@@ -20,6 +20,7 @@ you didn't get a copy, you may request one from <license@inner.net>.
        Created by cmetz for OPIE 2.22.
 */
 
+#include <string.h>
 #include "opie_cfg.h"
 #include "opie.h"
 
index 7cf18bb..638ae2f 100644 (file)
@@ -26,6 +26,8 @@ License Agreement applies to this software.
         Created at NRL for OPIE 2.2 from opiesubr2.c
 */
 
+#include <stdio.h>
+#include <string.h>
 #include "opie_cfg.h"
 #include "opie.h"
 
index 2364e77..ec41f65 100644 (file)
@@ -17,6 +17,8 @@ License Agreement applies to this software.
        Modified by cmetz for OPIE 2.2. Use FUNCTION declaration et al.
         Created at NRL for OPIE 2.2 from opiesubr.c.
 */
+#include <stdio.h>
+#include <stdlib.h>
 #include "opie_cfg.h"
 #include "opie.h"
 
index 6e68ae5..32c95a0 100644 (file)
@@ -576,7 +576,7 @@ mi_thread_handle_wrapper(arg)
        **  is not used anywhere.
        */
 
-       return (void *) mi_handle_session(arg);
+       return (void *)(intptr_t)mi_handle_session(arg);
 }
 #endif /* _FFR_WORKERS_POOL */
 
index 8b4cff4..ffd2f50 100644 (file)
@@ -32,6 +32,7 @@
  * $Id: file.c,v 1.2 2001/04/16 04:33:01 bp Exp $
  */
 #include <sys/param.h>
+#include <sys/cdefs.h>
 #include <sys/sysctl.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
@@ -71,7 +72,7 @@ smb_write(struct smb_ctx *ctx, smbfh fh, off_t offset, size_t count,
        struct smbioc_rw rwrq;
 
        rwrq.ioc_fh = fh;
-       rwrq.ioc_base = src;
+       rwrq.ioc_base = __DECONST(char *, src);
        rwrq.ioc_cnt = count;
        rwrq.ioc_offset = offset;
        if (ioctl(ctx->ct_fd, SMBIOC_WRITE, &rwrq) == -1)
index e75f664..10cc9ca 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/iconv.h>
 #include <sys/sysctl.h>
 #include <ctype.h>
+#include <string.h>
 #include <errno.h>
 
 #ifdef APPLE
@@ -48,7 +49,7 @@ kiconv_add_xlat_table(const char *to, const char *from, const u_char *table)
 {
        struct iconv_add_in din;
        struct iconv_add_out dout;
-       int olen;
+       size_t olen;
 
        if (strlen(from) > ICONV_CSNMAXLEN || strlen(to) > ICONV_CSNMAXLEN)
                return EINVAL;
index c0a2060..8ac346f 100644 (file)
@@ -198,4 +198,4 @@ nb_hostlookup(struct nb_name *np, const char *server, const char *hint,
                nb_snbfree(snb);
        return error;
 }
-*/
\ No newline at end of file
+*/
index 19c3123..8af1de7 100644 (file)
@@ -41,6 +41,7 @@
 #endif
 #include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <strings.h>
 #include <stdlib.h>
 #include <locale.h>
@@ -125,7 +126,7 @@ char *
 nls_str_toloc(char *dst, const char *src)
 {
        char *p = dst;
-       int inlen, outlen;
+       size_t inlen, outlen;
 
        if (!iconv_loaded)
                return strcpy(dst, src);
@@ -147,7 +148,7 @@ char *
 nls_str_toext(char *dst, const char *src)
 {
        char *p = dst;
-       int inlen, outlen;
+       size_t inlen, outlen;
 
        if (!iconv_loaded)
                return strcpy(dst, src);
@@ -170,7 +171,7 @@ nls_mem_toloc(void *dst, const void *src, int size)
 {
        char *p = dst;
        const char *s = src;
-       int inlen, outlen;
+       size_t inlen, outlen;
 
        if (!iconv_loaded)
                return memcpy(dst, src, size);
@@ -195,7 +196,7 @@ nls_mem_toext(void *dst, const void *src, int size)
 {
        char *p = dst;
        const char *s = src;
-       int inlen, outlen;
+       size_t inlen, outlen;
 
        if (size == 0)
                return NULL;
index 952f666..eb4671c 100644 (file)
@@ -40,6 +40,7 @@
 #include <err.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <string.h>
 #include <strings.h>
 #include <stdlib.h>
 #include <sysexits.h>
@@ -198,7 +199,7 @@ smb_rap_create(int fn, const char *param, const char *data,
 
        rap = malloc(sizeof(*rap));
        if (rap == NULL)
-               return NULL;
+               return ENOMEM;
        bzero(rap, sizeof(*rap));
        p = rap->r_sparam = rap->r_nparam = strdup(param);
        rap->r_sdata = rap->r_ndata = strdup(data);
index ae6bf8d..7268e58 100644 (file)
@@ -39,6 +39,7 @@
 #include <err.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <string.h>
 #include <strings.h>
 #include <stdlib.h>
 #include <sysexits.h>
index 671c8dd..bcb26b4 100644 (file)
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#) options.c 1.17 96/02/11 17:01:31";
 #include <netinet/in.h>
 #include <netdb.h>
 #include <stdio.h>
+#include <unistd.h>
 #define SYSLOG_NAMES
 #include <syslog.h>
 #include <pwd.h>
index 62d31bc..dc46f92 100644 (file)
@@ -18,6 +18,7 @@ static char sccsid[] = "@(#) shell_cmd.c 1.5 94/12/28 17:42:44";
 #include <sys/param.h>
 #include <signal.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <syslog.h>
 #include <string.h>
 
index 700b98f..208a377 100644 (file)
@@ -245,6 +245,7 @@ static int str_to_attr(unsigned char *str, int *fg, int *bg, int *hl)
   strcpy(tempstr, str + 1);
   lastch(tempstr) = '\0';
 
+  *fg = 0;     /* fix compiler warning */
 
   /* get foreground and background */
 
index 8bcf559..aa01b24 100644 (file)
@@ -39,6 +39,7 @@
 #endif
 
 #include <stdio.h>
+#include <string.h>
 
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself.  This code is part of the GNU C
index 21b98e6..08d71bb 100644 (file)
@@ -256,11 +256,13 @@ __elf_fdnlist(int fd, struct nlist *list)
        /* calculate section header table size */
        shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
 
+#ifndef __amd64__
        /* Make sure it's not too big to mmap */
        if (shdr_size > SIZE_T_MAX) {
                errno = EFBIG;
                return (-1);
        }
+#endif
 
        /* mmap section header table */
        base = mmap(NULL, (size_t)shdr_size, PROT_READ, 0, fd,
@@ -285,11 +287,14 @@ __elf_fdnlist(int fd, struct nlist *list)
                }
        }
 
+#ifndef __amd64__
        /* Check for files too large to mmap. */
        if (symstrsize > SIZE_T_MAX) {
                errno = EFBIG;
                goto done;
        }
+#endif
+
        /*
         * Map string table into our address space.  This gives us
         * an easy way to randomly access all the strings, without
index dd18e0d..9596b62 100644 (file)
@@ -283,7 +283,7 @@ thread_sig_invoke_handler(int sig, siginfo_t *info, ucontext_t *ucp)
                    (info == NULL))
                        (*(sigfunc))(sig, info, ucp);
                else
-                       (*(sigfunc))(sig, (siginfo_t *)info->si_code, ucp);
+                       (*(sigfunc))(sig, (siginfo_t *)(intptr_t)info->si_code, ucp);
        }
        /*
         * Only restore the signal mask if it hasn't been changed by the
index 2ce344a..890b7d9 100644 (file)
@@ -136,7 +136,7 @@ token(void)
 }
 
 static int
-ruserpass(char *host, char **aname, char **apass, char **aacct)
+ruserpass(char *host, const char **aname, const char **apass, char **aacct)
 {
        char *hdir, buf[BUFSIZ], *tmp;
        char myname[MAXHOSTNAMELEN], *mydomain;
@@ -189,9 +189,11 @@ next:
 
                case LOGIN:
                        if (token())
-                               if (*aname == 0) {
-                                       *aname = malloc((unsigned) strlen(tokval) + 1);
-                                       (void) strcpy(*aname, tokval);
+                               if (*aname == NULL) {
+                                       char *tmp;
+                                       tmp = malloc(strlen(tokval) + 1);
+                                       strcpy(tmp, tokval);
+                                       *aname = tmp;
                                } else {
                                        if (strcmp(*aname, tokval))
                                                goto next;
@@ -206,8 +208,10 @@ next:
                                goto bad;
                        }
                        if (token() && *apass == 0) {
-                               *apass = malloc((unsigned) strlen(tokval) + 1);
-                               (void) strcpy(*apass, tokval);
+                               char *tmp;
+                               tmp = malloc(strlen(tokval) + 1);
+                               strcpy(tmp, tokval);
+                               *apass = tmp;
                        }
                        break;
                case ACCOUNT:
@@ -312,7 +316,8 @@ rexec_af(char **ahost, int rport, const char *name, const char *pass,
        servbuff[sizeof(servbuff) - 1] = '\0';
 
        memset(&hints, '\0', sizeof(hints));
-       hints.ai_family = af;
+       if (af)
+               hints.ai_family = *af;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_flags = AI_CANONNAME;
        gai = getaddrinfo(*ahost, servbuff, &hints, &res0);
@@ -431,7 +436,7 @@ bad:
 
 
 int
-rexec(char **ahost, int rport, char *name, char *pass, char *cmd, int *fd2p)
+rexec(char **ahost, int rport, const char *name, const char *pass, char *cmd, int *fd2p)
 {
        struct sockaddr_in sin, sin2, from;
        struct hostent *hp;
index 10afdbd..cb10563 100644 (file)
@@ -274,7 +274,8 @@ ncp_li_check(struct ncp_conn_loginfo *li) {
 
 int
 ncp_conn_cnt(void) {
-       int error, cnt = 0, len = sizeof(cnt);
+       int error, cnt = 0;
+       size_t len = sizeof(cnt);
        
        error = sysctlbyname("net.ncp.conn_cnt", &cnt, &len, NULL, 0);
        if (error) cnt = 0;
@@ -382,7 +383,8 @@ ncp_li_arg(struct ncp_conn_loginfo *li, int opt, char *arg) {
 
 void *
 ncp_conn_list(void) {
-       int error, cnt = 0, len;
+       int error, cnt = 0;
+       size_t len;
        void *p;
        
        cnt = ncp_conn_cnt();
index 1550edd..dd34190 100644 (file)
@@ -213,8 +213,9 @@ NWRequest(NWCONN_HANDLE cH, nuint16 fn,
 int
 ncp_initlib(void){
        int error;
-       int len = sizeof(sysentoffset);
-       int kv, kvlen = sizeof(kv);
+       size_t len = sizeof(sysentoffset);
+       int kv;
+       size_t kvlen = sizeof(kv);
        static int ncp_initialized;
 
        if (ncp_initialized)
index 2c70cf9..2b5a94b 100644 (file)
@@ -260,7 +260,7 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
            &asoc, &siz) != 0) {
                return(-1);
        }
-       siz = (unsigned int)asoc;
+       siz = (unsigned int)(uintptr_t)asoc;
        siz += sizeof(struct sctp_getaddresses);
        addrs = calloc((unsigned long)1, (unsigned long)siz);
        if (addrs == NULL) {
index 667d3bb..9eb0f7d 100644 (file)
@@ -339,7 +339,7 @@ struct pthread {
        long                    terminated;
 
        /* Kernel thread id. */
-       long                    tid;
+       lwpid_t                 tid;
 
        /* Internal condition variable cycle number. */
        umtx_t                  cycle;
index b0d102e..dd72d80 100644 (file)
@@ -39,7 +39,7 @@
 static const char rel_header[] =
     " symbol name               r_info r_offset st_value st_size    address    value\n"
     " ------------------------------------------------------------------------------\n";
-static const char rel_format[] =  " %-25s %6x %08x %08x %7d %10p %08x\n";
+static const char rel_format[] =  " %-25s %6lx %08lx %08lx %7ld %10p %08lx\n";
 
 int debug = 0;
 
@@ -114,9 +114,9 @@ dump_Elf_Rel (Obj_Entry *obj, const Elf_Rel *rel0, u_long relsize)
         sym = obj->symtab + ELF_R_SYM(rel->r_info);
         printf(rel_format,
                obj->strtab + sym->st_name,
-               rel->r_info, rel->r_offset,
-               sym->st_value, sym->st_size,
-               dstaddr, *dstaddr);
+               (long)rel->r_info, (long)rel->r_offset,
+               (long)sym->st_value, (long)sym->st_size,
+               dstaddr, (long)*dstaddr);
     }
     return;
 }
@@ -136,9 +136,9 @@ dump_Elf_Rela (Obj_Entry *obj, const Elf_Rela *rela0, u_long relasize)
         sym = obj->symtab + ELF_R_SYM(rela->r_info);
         printf(rel_format,
                obj->strtab + sym->st_name,
-               rela->r_info, rela->r_offset,
-               sym->st_value, sym->st_size,
-               dstaddr, *dstaddr);
+               (long)rela->r_info, (long)rela->r_offset,
+               (long)sym->st_value, (long)sym->st_size,
+               dstaddr, (long)*dstaddr);
     }
     return;
 }
index ee59413..c648abe 100644 (file)
@@ -3154,10 +3154,10 @@ doreport:
                                        percentage = 10000 * val;
 
                                        fprintf(stdout,
-                                               "\rFormatting:  %qd.%02qd %% "
+                                               "\rFormatting:  %jd.%02jd %% "
                                                "(%d/%d) done",
-                                               percentage / (0x10000 * 100),
-                                               (percentage / 0x10000) % 100,
+                                               (intmax_t)percentage / (0x10000 * 100),
+                                               (intmax_t)(percentage / 0x10000) % 100,
                                                val, 0x10000);
                                        fflush(stdout);
                                } else if ((quiet == 0)
index 15632af..34b5063 100644 (file)
@@ -115,7 +115,7 @@ arg_put(void *hook __unused, int letter, void *arg, int count, char *name)
        {
                case 'i':
                case 'b':
-               printf("%d ", (intptr_t)arg);
+               printf("%jd ", (intmax_t)(intptr_t)arg);
                break;
 
                case 'c':
index 7f780c6..c30de37 100644 (file)
@@ -98,10 +98,10 @@ void
 dumppart(const char *path, struct partinfo *dpart)
 {
        printf("%-16s ", path);
-       printf("blksize=%-4d off=%012llx size=%012llx ",
+       printf("blksize=%-4d off=%012jx size=%012jx ",
                dpart->media_blksize,
-               dpart->media_offset,
-               dpart->media_size
+               (intmax_t)dpart->media_offset,
+               (intmax_t)dpart->media_size
        );
        if (dpart->media_size >= 100LL*1024*1024*1024) {
                printf("%7.2f GB", 
@@ -145,7 +145,8 @@ dumppart(const char *path, struct partinfo *dpart)
                         * note: rsvdlabel is inclusive of rsvdplat. i.e.
                         * they are not relative to each other.
                         */
-                       printf(" reserved=%lld", dpart->reserved_blocks);
+                       printf(" reserved=%jd",
+                               (intmax_t)dpart->reserved_blocks);
                }
        }
        printf("\n");
index 68e1017..68abee9 100644 (file)
@@ -670,11 +670,12 @@ display(FILE *f, const struct disklabel64 *lp)
        fprintf(f, "# Informational fields calculated from the above\n");
        fprintf(f, "# All byte equivalent offsets must be aligned\n");
        fprintf(f, "#\n");
-       fprintf(f, "# boot space: %10llu bytes\n", lp->d_pbase - lp->d_bbase);
-       fprintf(f, "# data space: %10llu blocks\t# %6.2f MB (%llu bytes)\n",
-                       (lp->d_pstop - lp->d_pbase) / blksize,
+       fprintf(f, "# boot space: %10ju bytes\n",
+               (intmax_t)(lp->d_pbase - lp->d_bbase));
+       fprintf(f, "# data space: %10ju blocks\t# %6.2f MB (%ju bytes)\n",
+                       (intmax_t)(lp->d_pstop - lp->d_pbase) / blksize,
                        (double)(lp->d_pstop - lp->d_pbase) / 1024.0 / 1024.0,
-                       lp->d_pstop - lp->d_pbase);
+                       (intmax_t)(lp->d_pstop - lp->d_pbase));
        fprintf(f, "#\n");
 
        uuid_to_string(&lp->d_stor_uuid, &str, NULL);
@@ -683,12 +684,12 @@ display(FILE *f, const struct disklabel64 *lp)
 
        fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
                lp->d_packname);
-       fprintf(f, "boot2 data base:      0x%012llx\n", lp->d_bbase);
-       fprintf(f, "partitions data base: 0x%012llx\n", lp->d_pbase);
-       fprintf(f, "partitions data stop: 0x%012llx\n", lp->d_pstop);
-       fprintf(f, "backup label:         0x%012llx\n", lp->d_abase);
-       fprintf(f, "total size:           0x%012llx\t# %6.2f MB\n",
-               lp->d_total_size,
+       fprintf(f, "boot2 data base:      0x%012jx\n", (intmax_t)lp->d_bbase);
+       fprintf(f, "partitions data base: 0x%012jx\n", (intmax_t)lp->d_pbase);
+       fprintf(f, "partitions data stop: 0x%012jx\n", (intmax_t)lp->d_pstop);
+       fprintf(f, "backup label:         0x%012jx\n", (intmax_t)lp->d_abase);
+       fprintf(f, "total size:           0x%012jx\t# %6.2f MB\n",
+               (intmax_t)lp->d_total_size,
                (double)lp->d_total_size / 1024.0 / 1024.0);
        fprintf(f, "alignment: %u\n", lp->d_align);
        fprintf(f, "display block size: %u\t# for partition display only\n",
@@ -710,11 +711,12 @@ display(FILE *f, const struct disklabel64 *lp)
                if (pp->p_bsize % lp->d_align)
                    fprintf(f, "%10s  ", "ILLEGAL");
                else
-                   fprintf(f, "%10llu ", pp->p_bsize / blksize);
+                   fprintf(f, "%10ju ", (intmax_t)pp->p_bsize / blksize);
                if (pp->p_boffset % lp->d_align)
                    fprintf(f, "%10s  ", "ILLEGAL");
                else
-                   fprintf(f, "%10llu  ", (pp->p_boffset - lp->d_pbase) / blksize);
+                   fprintf(f, "%10ju  ",
+                           (intmax_t)(pp->p_boffset - lp->d_pbase) / blksize);
                if (pp->p_fstype < FSMAXTYPES)
                        fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
                else
@@ -1256,7 +1258,8 @@ checklabel(struct disklabel64 *lp)
                return (1);
        }
        if (lp->d_pstop > lp->d_total_size) {
-               printf("%012llx\n%012llx\n", lp->d_pstop, lp->d_total_size);
+               printf("%012jx\n%012jx\n",
+                       (intmax_t)lp->d_pstop, (intmax_t)lp->d_total_size);
                Warning("disklabel control info is beyond the total size");
                return (1);
        }
@@ -1336,9 +1339,9 @@ checklabel(struct disklabel64 *lp)
                                }
                        }
                } else {
-                       fprintf(stderr,
-                           "%lld bytes available to give to '*' and '%%' partitions\n",
-                           free_space);
+                       fprintf(stderr, "%jd bytes available to give to "
+                                       "'*' and '%%' partitions\n",
+                               (intmax_t)free_space);
                        errors++;
                        /* fix?  set all % partitions to size 0? */
                }
@@ -1367,9 +1370,10 @@ checklabel(struct disklabel64 *lp)
                                    seen_default_offset &&
                                    pp->p_fstype != FS_VINUM) {
                                        fprintf(stderr,
-"Offset 0x%012llx for partition %c overlaps previous partition which ends at 0x%012llx\n",
-                                           pp->p_boffset, i + 'a',
-                                           current_offset);
+"Offset 0x%012jx for partition %c overlaps previous partition which ends at 0x%012jx\n",
+                                           (intmax_t)pp->p_boffset,
+                                           i + 'a',
+                                           (intmax_t)current_offset);
                                        fprintf(stderr,
 "Labels with any *'s for offset must be in ascending order by sector\n");
                                        errors++;
@@ -1380,9 +1384,9 @@ checklabel(struct disklabel64 *lp)
                                         * partitions are out-of-order
                                         */
                                        Warning(
-"Offset 0x%012llx for partition %c doesn't match expected value 0x%012llx",
+"Offset 0x%012jx for partition %c doesn't match expected value 0x%012jx",
                                            pp->p_boffset, i + 'a',
-                                           current_offset);
+                                           (intmax_t)current_offset);
                                }
                        }
                        current_offset = pp->p_boffset + pp->p_bsize; 
@@ -1393,8 +1397,8 @@ checklabel(struct disklabel64 *lp)
                part = 'a' + i;
                pp = &lp->d_partitions[i];
                if (pp->p_bsize == 0 && pp->p_boffset != 0)
-                       Warning("partition %c: size 0, but offset 0x%012llx",
-                           part, pp->p_boffset);
+                       Warning("partition %c: size 0, but offset 0x%012jx",
+                               part, (intmax_t)pp->p_boffset);
                if (pp->p_bsize == 0) {
                        pp->p_boffset = 0;
                        continue;
@@ -1404,20 +1408,20 @@ checklabel(struct disklabel64 *lp)
 
                if (pp->p_boffset < lp->d_pbase) {
                        fprintf(stderr,
-                           "partition %c: offset out of bounds (%lld)\n",
-                           part, pp->p_boffset - lp->d_pbase);
+                           "partition %c: offset out of bounds (%jd)\n",
+                           part, (intmax_t)(pp->p_boffset - lp->d_pbase));
                        errors++;
                }
                if (pp->p_boffset > lp->d_pstop) {
                        fprintf(stderr,
-                           "partition %c: offset out of bounds (%lld)\n",
-                           part, pp->p_boffset - lp->d_pbase);
+                           "partition %c: offset out of bounds (%jd)\n",
+                           part, (intmax_t)(pp->p_boffset - lp->d_pbase));
                        errors++;
                }
                if (pp->p_boffset + pp->p_bsize > lp->d_pstop) {
                        fprintf(stderr,
-                           "partition %c: size out of bounds (%lld)\n",
-                           part, pp->p_boffset - lp->d_pbase);
+                           "partition %c: size out of bounds (%jd)\n",
+                           part, (intmax_t)(pp->p_boffset - lp->d_pbase));
                        errors++;
                }
 
@@ -1442,8 +1446,10 @@ checklabel(struct disklabel64 *lp)
                part = 'a' + i;
                pp = &lp->d_partitions[i];
                if (pp->p_bsize || pp->p_boffset)
-                       Warning("unused partition %c: size 0x%012llx offset 0x%012llx",
-                           'a' + i, pp->p_bsize, pp->p_boffset);
+                       Warning("unused partition %c: size 0x%012jx "
+                               "offset 0x%012jx",
+                               'a' + i, (intmax_t)pp->p_bsize,
+                               (intmax_t)pp->p_boffset);
        }
        return (errors);
 }
index cb2d8d3..e8a254c 100644 (file)
@@ -164,8 +164,9 @@ dumpfs(char *name)
        printf("symlinklen %d\ttrackskew %d\tinterleave %d\tcontigsumsize %d\n",
            afs.fs_maxsymlinklen, afs.fs_trackskew, afs.fs_interleave,
            afs.fs_contigsumsize);
-       printf("nindir\t%d\tinopb\t%d\tnspf\t%d\tmaxfilesize\t%qu\n",
-           afs.fs_nindir, afs.fs_inopb, afs.fs_nspf, afs.fs_maxfilesize);
+       printf("nindir\t%d\tinopb\t%d\tnspf\t%d\tmaxfilesize\t%ju\n",
+           afs.fs_nindir, afs.fs_inopb, afs.fs_nspf,
+           (intmax_t)afs.fs_maxfilesize);
        printf("sblkno\t%d\tcblkno\t%d\tiblkno\t%d\tdblkno\t%d\n",
            afs.fs_sblkno, afs.fs_cblkno, afs.fs_iblkno, afs.fs_dblkno);
        printf("sbsize\t%d\tcgsize\t%d\tcgoffset %d\tcgmask\t0x%08x\n",
@@ -259,10 +260,10 @@ dumpcg(char *name, int fd, int c)
                warnx("%s: error reading cg", name);
                return (1);
        }
-       printf("magic\t%x\ttell\t%qx\ttime\t%s",
+       printf("magic\t%x\ttell\t%jx\ttime\t%s",
            afs.fs_postblformat == FS_42POSTBLFMT ?
            ((struct ocg *)&acg)->cg_magic : acg.cg_magic,
-           cur, ctime((time_t *)&acg.cg_time));
+           (intmax_t)cur, ctime((time_t *)&acg.cg_time));
        printf("cgx\t%d\tncyl\t%d\tniblk\t%d\tndblk\t%d\n",
            acg.cg_cgx, acg.cg_ncyl, acg.cg_niblk, acg.cg_ndblk);
        printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
index 84196e6..93454f0 100644 (file)
@@ -501,10 +501,10 @@ print_part(int i)
        part_mb *= secsize;
        part_mb /= (1024 * 1024);
        printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
-       printf("    start %lu, size %lu (%lld Meg), flag %x%s\n",
+       printf("    start %lu, size %lu (%jd Meg), flag %x%s\n",
                (u_long)partp->dp_start,
                (u_long)partp->dp_size,
-               (long long)part_mb,
+               (intmax_t)part_mb,
                partp->dp_flag,
                partp->dp_flag == ACTIVE ? " (active)" : "");
        printf("\tbeg: cyl %d/ head %d/ sector %d;\n\tend: cyl %d/ head %d/ sector %d\n"
index 3d19de0..a106076 100644 (file)
@@ -803,7 +803,7 @@ CMDFUNCSTART(chgroup)
 }
 
 int
-dotime(char *name, struct timespec *rts)
+dotime(char *name, int32_t *rts)
 {
     char *p, *val;
     struct tm t;
@@ -852,8 +852,8 @@ badformat:
        warnx("date/time out of range");
        return 1;
     }
-    rts->tv_sec = sec;
-    rts->tv_nsec = nsec;
+    rts[0] = sec;
+    rts[1] = nsec;
     return 0;
 }
 
index 4129639..a4987eb 100644 (file)
@@ -134,7 +134,8 @@ fsirand(char *device)
        memset(&sbuf, 0, sizeof(sbuf));
        sblock = (struct fs *)&sbuf;
        if (lseek(devfd, SBOFF, SEEK_SET) == -1) {
-               warn("can't seek to superblock (%qd) on %s", SBOFF, device);
+               warn("can't seek to superblock (%jd) on %s",
+                   (intmax_t)SBOFF, device);
                return (1);
        }
        if ((n = read(devfd, (void *)sblock, SBSIZE)) != SBSIZE) {
@@ -167,7 +168,7 @@ fsirand(char *device)
        for (cg = 0; cg < sblock->fs_ncg; cg++) {
                dblk = fsbtodb(sblock, cgsblock(sblock, cg));
                if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-                       warn("can't seek to %qd", (off_t)dblk * bsize);
+                       warn("can't seek to %jd", (intmax_t)dblk * bsize);
                        return (1);
                } else if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) {
                        warn("can't read backup superblock %d on %s: %s",
@@ -211,8 +212,8 @@ fsirand(char *device)
                sblock->fs_id[1] = random();
 
                if (lseek(devfd, SBOFF, SEEK_SET) == -1) {
-                       warn("can't seek to superblock (%qd) on %s", SBOFF,
-                           device);
+                       warn("can't seek to superblock (%jd) on %s",
+                            (intmax_t)SBOFF, device);
                        return (1);
                }
                if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) {
@@ -228,7 +229,8 @@ fsirand(char *device)
                if ((sblock->fs_inodefmt >= FS_44INODEFMT) && !printonly) {
                        dblk = fsbtodb(sblock, cgsblock(sblock, cg));
                        if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-                               warn("can't seek to %qd", (off_t)dblk * bsize);
+                               warn("can't seek to %jd",
+                                    (intmax_t)dblk * bsize);
                                return (1);
                        } else if ((n = write(devfd, (void *)sblock, SBSIZE)) != SBSIZE) {
                                warn("can't read backup superblock %d on %s: %s",
@@ -241,7 +243,7 @@ fsirand(char *device)
                /* Read in inodes, then print or randomize generation nums */
                dblk = fsbtodb(sblock, ino_to_fsba(sblock, inumber));
                if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-                       warn("can't seek to %qd", (off_t)dblk * bsize);
+                       warn("can't seek to %jd", (intmax_t)dblk * bsize);
                        return (1);
                } else if ((n = read(devfd, inodebuf, ibufsize)) != ibufsize) {
                        warnx("can't read inodes: %s",
@@ -251,19 +253,21 @@ fsirand(char *device)
 
                for (n = 0; n < sblock->fs_ipg; n++, inumber++) {
                        if (inumber >= ROOTINO) {
-                               if (printonly)
-                                       printf("ino %lld gen %x\n", inumber,
-                                           inodebuf[n].di_gen);
-                               else
+                               if (printonly) {
+                                       printf("ino %jd gen %x\n",
+                                              (intmax_t)inumber,
+                                              inodebuf[n].di_gen);
+                               } else {
                                        inodebuf[n].di_gen = random();
+                               }
                        }
                }
 
                /* Write out modified inodes */
                if (!printonly) {
                        if (lseek(devfd, (off_t)dblk * bsize, SEEK_SET) < 0) {
-                               warn("can't seek to %qd",
-                                   (off_t)dblk * bsize);
+                               warn("can't seek to %jd",
+                                   (intmax_t)dblk * bsize);
                                return (1);
                        } else if ((n = write(devfd, inodebuf, ibufsize)) !=
                                 ibufsize) {
index c7c0b3b..8582a6b 100644 (file)
@@ -2075,8 +2075,8 @@ main(int argc, char **argv)
        sblock.fs_size = dbtofsb(&osblock, pinfo.media_blocks);
        if (size != 0) {
                if (size > pinfo.media_blocks){
-                       errx(1, "There is not enough space (%llu < %d)",
-                           pinfo.media_blocks, size);
+                       errx(1, "There is not enough space (%ju < %d)",
+                            (intmax_t)pinfo.media_blocks, size);
                }
                sblock.fs_size = dbtofsb(&osblock, size);       
        }
index e525c3d..e483369 100644 (file)
@@ -73,8 +73,10 @@ dump_blockmap(const char *label, int zone)
        rootmap = &root_volume->ondisk->vol0_blockmap[zone];
        assert(rootmap->phys_offset != 0);
 
-       printf("zone %-16s next %016llx alloc %016llx\n",
-               label, rootmap->next_offset, rootmap->alloc_offset);
+       printf("zone %-16s next %016jx alloc %016jx\n",
+               label,
+               (uintmax_t)rootmap->next_offset,
+               (uintmax_t)rootmap->alloc_offset);
 
        for (scan1 = HAMMER_ZONE_ENCODE(zone, 0);
             scan1 < HAMMER_ZONE_ENCODE(zone, HAMMER_OFF_LONG_MASK);
@@ -92,8 +94,11 @@ dump_blockmap(const char *label, int zone)
                    layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL) {
                        continue;
                }
-               printf("%c layer1 %016llx @%016llx blocks-free %lld\n",
-                       xerr, scan1, layer1->phys_offset, layer1->blocks_free);
+               printf("%c layer1 %016jx @%016jx blocks-free %jd\n",
+                       xerr,
+                       (uintmax_t)scan1,
+                       (uintmax_t)layer1->phys_offset,
+                       (intmax_t)layer1->blocks_free);
                if (layer1->phys_offset == HAMMER_BLOCKMAP_FREE)
                        continue;
                for (scan2 = scan1; 
@@ -109,9 +114,9 @@ dump_blockmap(const char *label, int zone)
                        xerr = ' ';
                        if (layer2->entry_crc != crc32(layer2, HAMMER_LAYER2_CRCSIZE))
                                xerr = 'B';
-                       printf("%c       %016llx zone=%d app=%-7d free=%-7d\n",
+                       printf("%c       %016jx zone=%d app=%-7d free=%-7d\n",
                                xerr,
-                               scan2,
+                               (uintmax_t)scan2,
                                layer2->zone,
                                layer2->append_off,
                                layer2->bytes_free);
index e42ccac..304c0b7 100644 (file)
@@ -96,16 +96,16 @@ hammer_do_history(const char *path, off_t off, int len)
        }
        status = ((hist.head.flags & HAMMER_IOC_HISTORY_UNSYNCED) ?
                 "dirty" : "clean");
-       printf("%016llx %s {\n", hist.obj_id, status);
+       printf("%016jx %s {\n", (uintmax_t)hist.obj_id, status);
        for (;;) {
                for (i = 0; i < hist.count; ++i) {
                        char *hist_path = NULL;
 
-                       asprintf(&hist_path, "%s@@0x%016llx",
-                                path, hist.hist_ary[i].tid);
-                       printf("    %016llx %s",
-                              hist.hist_ary[i].tid,
-                               timestr32(hist.hist_ary[i].time32));
+                       asprintf(&hist_path, "%s@@0x%016jx",
+                                path, (uintmax_t)hist.hist_ary[i].tid);
+                       printf("    %016jx %s",
+                              (uintmax_t)hist.hist_ary[i].tid,
+                              timestr32(hist.hist_ary[i].time32));
                        if (off >= 0) {
                                if (VerboseOpt) {
                                        printf(" '");
index bf55bdc..23230ef 100644 (file)
@@ -99,18 +99,24 @@ void show_info(char *path) {
        usedbigblocks = info.bigblocks - info.freebigblocks;
 
        fprintf(stdout, "Big block information\n");
-       fprintf(stdout, "\tTotal\t       %lld\n", info.bigblocks);
-       fprintf(stdout, "\tUsed\t       %lld (%.2lf%%)\n\tReserved       %lld (%.2lf%%)\n\tFree\t       %lld (%.2lf%%)\n",
-                       usedbigblocks, percent(usedbigblocks, info.bigblocks),
-                       info.rsvbigblocks, percent(info.rsvbigblocks, info.bigblocks),
-                       (info.freebigblocks - info.rsvbigblocks),
-                       percent(info.freebigblocks - info.rsvbigblocks, info.bigblocks));
+       fprintf(stdout, "\tTotal\t       %jd\n", (intmax_t)info.bigblocks);
+       fprintf(stdout, "\tUsed\t       %jd (%.2lf%%)\n\tReserved       "
+                                      "%jd (%.2lf%%)\n\tFree\t       "
+                                      "%jd (%.2lf%%)\n",
+                       (intmax_t)usedbigblocks,
+                       percent(usedbigblocks, info.bigblocks),
+                       (intmax_t)info.rsvbigblocks,
+                       percent(info.rsvbigblocks, info.bigblocks),
+                       (intmax_t)(info.freebigblocks - info.rsvbigblocks),
+                       percent(info.freebigblocks - info.rsvbigblocks,
+                               info.bigblocks));
        fprintf(stdout, "Space information\n");
 
        /* Space information */
        bytes = (info.bigblocks << HAMMER_LARGEBLOCK_BITS);
        humanize_number(buf, sizeof(buf)  - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, HN_DECIMAL | HN_NOSPACE | HN_B);
-       fprintf(stdout, "\tTotal size     %6s (%lld bytes)\n", buf, bytes);
+       fprintf(stdout, "\tTotal size     %6s (%jd bytes)\n",
+               buf, (intmax_t)bytes);
 
        bytes = (usedbigblocks << HAMMER_LARGEBLOCK_BITS);
        humanize_number(buf, sizeof(buf)  - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, HN_DECIMAL | HN_NOSPACE | HN_B);
index e3c7960..a17fced 100644 (file)
@@ -203,12 +203,12 @@ again:
 
        if (streaming == 0 || VerboseOpt >= 2) {
                fprintf(stderr,
-                       "Mirror-read: Mirror from %016llx to %016llx\n",
-                       mirror.tid_beg, mirror.tid_end);
+                       "Mirror-read: Mirror from %016jx to %016jx\n",
+                       (uintmax_t)mirror.tid_beg, (uintmax_t)mirror.tid_end);
        }
        if (mirror.key_beg.obj_id != (int64_t)HAMMER_MIN_OBJID) {
-               fprintf(stderr, "Mirror-read: Resuming at object %016llx\n",
-                       mirror.key_beg.obj_id);
+               fprintf(stderr, "Mirror-read: Resuming at object %016jx\n",
+                       (uintmax_t)mirror.key_beg.obj_id);
        }
 
        /*
@@ -260,11 +260,11 @@ again:
                total_bytes += mirror.count;
                if (streaming && VerboseOpt) {
                        fprintf(stderr,
-                               "\robj=%016llx tids=%016llx:%016llx %11lld",
-                               (long long)mirror.key_cur.obj_id,
-                               (long long)mirror.tid_beg,
-                               (long long)mirror.tid_end,
-                               total_bytes);
+                               "\robj=%016jx tids=%016jx:%016jx %11jd",
+                               (uintmax_t)mirror.key_cur.obj_id,
+                               (uintmax_t)mirror.tid_beg,
+                               (uintmax_t)mirror.tid_end,
+                               (intmax_t)total_bytes);
                        fflush(stderr);
                }
                mirror.key_beg = mirror.key_cur;
@@ -276,9 +276,9 @@ again:
                    (unsigned)(time(NULL) - base_t) > (unsigned)TimeoutOpt) {
                        fprintf(stderr,
                                "Mirror-read %s interrupted by timer at"
-                               " %016llx\n",
+                               " %016jx\n",
                                filesystem,
-                               mirror.key_cur.obj_id);
+                               (uintmax_t)mirror.key_cur.obj_id);
                        interrupted = 1;
                        break;
                }
@@ -323,8 +323,9 @@ done:
                        if (CyclePath) {
                                hammer_key_beg_init(&mirror.key_beg);
                                hammer_set_cycle(&mirror.key_beg, sync_tid);
-                               fprintf(stderr, "Cyclefile %s updated to 0x%016llx\n",
-                                       CyclePath, sync_tid);
+                               fprintf(stderr,
+                                       "Cyclefile %s updated to 0x%016jx\n",
+                                       CyclePath, (uintmax_t)sync_tid);
                        }
                }
        } else if (CyclePath) {
@@ -424,11 +425,11 @@ generate_histogram(int fd, const char *filesystem,
                mirror.tid_end = tid_half;
 
                if (VerboseOpt > 1) {
-                       fprintf(stderr, "RangeTest %016llx/%016llx - %016llx (%lld) ",
-                               (long long)tid_beg,
-                               (long long)tid_end,
-                               (long long)tid_half,
-                               (long long)(tid_half - tid_beg));
+                       fprintf(stderr, "RangeTest %016jx/%016jx - %016jx (%jd) ",
+                               (uintmax_t)tid_beg,
+                               (uintmax_t)tid_end,
+                               (uintmax_t)tid_half,
+                               (intmax_t)(tid_half - tid_beg));
                }
                fflush(stderr);
                if (ioctl(fd, HAMMERIOC_MIRROR_READ, &mirror) < 0) {
@@ -708,8 +709,8 @@ again:
                write_mrecord(1, HAMMER_MREC_TYPE_UPDATE,
                              &mrec_tmp, sizeof(mrec_tmp.update));
        } else {
-               printf("Source can update synctid to 0x%016llx\n",
-                      mirror.tid_end);
+               printf("Source can update synctid to 0x%016jx\n",
+                      (uintmax_t)mirror.tid_end);
        }
        relpfs(fd, &pfs);
        goto again;
@@ -753,10 +754,10 @@ hammer_cmd_mirror_dump(void)
                        switch(mrec->head.type & HAMMER_MRECF_TYPE_MASK) {
                        case HAMMER_MREC_TYPE_REC_BADCRC:
                        case HAMMER_MREC_TYPE_REC:
-                               printf("Record obj=%016llx key=%016llx "
+                               printf("Record obj=%016jx key=%016jx "
                                       "rt=%02x ot=%02x",
-                                       mrec->rec.leaf.base.obj_id,
-                                       mrec->rec.leaf.base.key,
+                                       (uintmax_t)mrec->rec.leaf.base.obj_id,
+                                       (uintmax_t)mrec->rec.leaf.base.key,
                                        mrec->rec.leaf.base.rec_type,
                                        mrec->rec.leaf.base.obj_type);
                                if (mrec->head.type ==
@@ -764,31 +765,31 @@ hammer_cmd_mirror_dump(void)
                                        printf(" (BAD CRC)");
                                }
                                printf("\n");
-                               printf("       tids %016llx:%016llx data=%d\n",
-                                       mrec->rec.leaf.base.create_tid,
-                                       mrec->rec.leaf.base.delete_tid,
-                                       mrec->rec.leaf.data_len);
+                               printf("       tids %016jx:%016jx data=%d\n",
+                                   (uintmax_t)mrec->rec.leaf.base.create_tid,
+                                   (uintmax_t)mrec->rec.leaf.base.delete_tid,
+                                   mrec->rec.leaf.data_len);
                                break;
                        case HAMMER_MREC_TYPE_PASS:
-                               printf("Pass   obj=%016llx key=%016llx "
+                               printf("Pass   obj=%016jx key=%016jx "
                                       "rt=%02x ot=%02x\n",
-                                       mrec->rec.leaf.base.obj_id,
-                                       mrec->rec.leaf.base.key,
+                                       (uintmax_t)mrec->rec.leaf.base.obj_id,
+                                       (uintmax_t)mrec->rec.leaf.base.key,
                                        mrec->rec.leaf.base.rec_type,
                                        mrec->rec.leaf.base.obj_type);
-                               printf("       tids %016llx:%016llx data=%d\n",
-                                       mrec->rec.leaf.base.create_tid,
-                                       mrec->rec.leaf.base.delete_tid,
+                               printf("       tids %016jx:%016jx data=%d\n",
+                                   (uintmax_t)mrec->rec.leaf.base.create_tid,
+                                   (uintmax_t)mrec->rec.leaf.base.delete_tid,
                                        mrec->rec.leaf.data_len);
                                break;
                        case HAMMER_MREC_TYPE_SKIP:
-                               printf("Skip   obj=%016llx key=%016llx rt=%02x to\n"
-                                      "       obj=%016llx key=%016llx rt=%02x\n",
-                                      mrec->skip.skip_beg.obj_id,
-                                      mrec->skip.skip_beg.key,
+                               printf("Skip   obj=%016jx key=%016jx rt=%02x to\n"
+                                      "       obj=%016jx key=%016jx rt=%02x\n",
+                                      (uintmax_t)mrec->skip.skip_beg.obj_id,
+                                      (uintmax_t)mrec->skip.skip_beg.key,
                                       mrec->skip.skip_beg.rec_type,
-                                      mrec->skip.skip_end.obj_id,
-                                      mrec->skip.skip_end.key,
+                                      (uintmax_t)mrec->skip.skip_end.obj_id,
+                                      (uintmax_t)mrec->skip.skip_end.key,
                                       mrec->skip.skip_end.rec_type);
                        default:
                                break;
@@ -1070,9 +1071,9 @@ read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup)
                            hammer_crc_test_leaf(&mrec->rec + 1, &mrec->rec.leaf) == 0) {
                                fprintf(stderr,
                                        "read_mrecords: data_crc did not "
-                                       "match data! obj=%016llx key=%016llx\n",
-                                       mrec->rec.leaf.base.obj_id,
-                                       mrec->rec.leaf.base.key);
+                                       "match data! obj=%016jx key=%016jx\n",
+                                       (uintmax_t)mrec->rec.leaf.base.obj_id,
+                                       (uintmax_t)mrec->rec.leaf.base.key);
                                fprintf(stderr,
                                        "continuing, but there are problems\n");
                        }
@@ -1315,8 +1316,8 @@ update_pfs_snapshot(int fd, hammer_tid_t snapshot_tid, int pfs_id)
                if (VerboseOpt >= 2) {
                        fprintf(stderr,
                                "Mirror-write: Completed, updated snapshot "
-                               "to %016llx\n",
-                               snapshot_tid);
+                               "to %016jx\n",
+                               (uintmax_t)snapshot_tid);
                }
        }
 }
index ea91500..a987eff 100644 (file)
@@ -50,7 +50,7 @@ static int timetosecs(char *str);
 int
 getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path)
 {
-       hammer_tid_t dummy_tid;
+       uintmax_t dummy_tid;
        struct stat st;
        char *dirpath;
        char buf[64];
@@ -113,7 +113,7 @@ getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path)
                        fd = open(dirpath, O_RDONLY);
                        goto done;
                }
-               if (sscanf(buf, "@@%llx:%d", &dummy_tid, &pfs->pfs_id) == 2) {
+               if (sscanf(buf, "@@%jx:%d", &dummy_tid, &pfs->pfs_id) == 2) {
                        fd = open(dirpath, O_RDONLY);
                        goto done;
                }
@@ -473,8 +473,8 @@ dump_pfsd(hammer_pseudofs_data_t pfsd)
        u_int32_t status;
        char *str = NULL;
 
-       printf("    sync-beg-tid=0x%016llx\n", pfsd->sync_beg_tid);
-       printf("    sync-end-tid=0x%016llx\n", pfsd->sync_end_tid);
+       printf("    sync-beg-tid=0x%016jx\n", (uintmax_t)pfsd->sync_beg_tid);
+       printf("    sync-end-tid=0x%016jx\n", (uintmax_t)pfsd->sync_end_tid);
        uuid_to_string(&pfsd->shared_uuid, &str, &status);
        printf("    shared-uuid=%s\n", str);
        uuid_to_string(&pfsd->unique_uuid, &str, &status);
index 857b694..5d0f294 100644 (file)
@@ -69,8 +69,8 @@ hammer_cmd_rebalance(char **av, int ac)
                if (perc < 50 || perc > 100)
                        rebalance_usage(1);
        }
-       printf("rebalance start %016llx:%04x\n",
-               rebal.key_beg.obj_id,
+       printf("rebalance start %016jx:%04x\n",
+               (uintmax_t)rebal.key_beg.obj_id,
                rebal.key_beg.localization);
 
        fd = open(filesystem, O_RDONLY);
@@ -81,9 +81,9 @@ hammer_cmd_rebalance(char **av, int ac)
                printf("Rebalance %s failed: %s\n",
                       filesystem, strerror(errno));
        } else if (rebal.head.flags & HAMMER_IOC_HEAD_INTR) {
-               printf("Rebalance %s interrupted by timer at %016llx:%04x\n",
+               printf("Rebalance %s interrupted by timer at %016jx:%04x\n",
                        filesystem,
-                       rebal.key_cur.obj_id,
+                       (uintmax_t)rebal.key_cur.obj_id,
                        rebal.key_cur.localization);
                if (CyclePath) {
                        hammer_set_cycle(&rebal.key_cur, 0);
@@ -96,14 +96,14 @@ hammer_cmd_rebalance(char **av, int ac)
        RunningIoctl = 0;
        close(fd);
        printf("Rebalance:\n"
-              "    %lld btree nodes scanned\n"
-              "    %lld btree nodes deleted\n"
-              "    %lld collision retries\n"
-              "    %lld btree nodes rebalanced\n",
-              rebal.stat_ncount,
-              rebal.stat_deletions,
-              rebal.stat_collisions,
-              rebal.stat_nrebal
+              "    %jd btree nodes scanned\n"
+              "    %jd btree nodes deleted\n"
+              "    %jd collision retries\n"
+              "    %jd btree nodes rebalanced\n",
+              (intmax_t)rebal.stat_ncount,
+              (intmax_t)rebal.stat_deletions,
+              (intmax_t)rebal.stat_collisions,
+              (intmax_t)rebal.stat_nrebal
        );
 }
 
index 75b1a3b..21caa6c 100644 (file)
@@ -94,8 +94,8 @@ hammer_cmd_reblock(char **av, int ac, int flags)
        reblock.free_level = HAMMER_LARGEBLOCK_SIZE - reblock.free_level;
        if (reblock.free_level < 0)
                reblock.free_level = 0;
-       printf("reblock start %016llx:%04x free level %d\n",
-               reblock.key_beg.obj_id,
+       printf("reblock start %016jx:%04x free level %d\n",
+               (uintmax_t)reblock.key_beg.obj_id,
                reblock.key_beg.localization,
                reblock.free_level);
 
@@ -106,9 +106,9 @@ hammer_cmd_reblock(char **av, int ac, int flags)
        if (ioctl(fd, HAMMERIOC_REBLOCK, &reblock) < 0) {
                printf("Reblock %s failed: %s\n", filesystem, strerror(errno));
        } else if (reblock.head.flags & HAMMER_IOC_HEAD_INTR) {
-               printf("Reblock %s interrupted by timer at %016llx:%04x\n",
+               printf("Reblock %s interrupted by timer at %016jx:%04x\n",
                        filesystem,
-                       reblock.key_cur.obj_id,
+                       (uintmax_t)reblock.key_cur.obj_id,
                        reblock.key_cur.localization);
                if (CyclePath) {
                        hammer_set_cycle(&reblock.key_cur, 0);
@@ -121,12 +121,13 @@ hammer_cmd_reblock(char **av, int ac, int flags)
        RunningIoctl = 0;
        close(fd);
        printf("Reblocked:\n"
-              "    %lld/%lld btree nodes\n"
-              "    %lld/%lld data elements\n"
-              "    %lld/%lld data bytes\n",
-              reblock.btree_moves, reblock.btree_count,
-              reblock.data_moves, reblock.data_count,
-              reblock.data_byte_moves, reblock.data_byte_count
+              "    %jd/%jd btree nodes\n"
+              "    %jd/%jd data elements\n"
+              "    %jd/%jd data bytes\n",
+              (intmax_t)reblock.btree_moves, (intmax_t)reblock.btree_count,
+              (intmax_t)reblock.data_moves, (intmax_t)reblock.data_count,
+              (intmax_t)reblock.data_byte_moves,
+              (intmax_t)reblock.data_byte_count
        );
 }
 
index 1e3953e..e7c4959 100644 (file)
@@ -74,15 +74,15 @@ hammer_cmd_show(hammer_off_t node_offset, u_int32_t lo, int64_t obj_id,
                volume = get_volume(RootVolNo);
                node_offset = volume->ondisk->vol0_btree_root;
                if (QuietOpt < 3) {
-                       printf("Volume header\trecords=%lld next_tid=%016llx\n",
-                              volume->ondisk->vol0_stat_records,
-                              volume->ondisk->vol0_next_tid);
-                       printf("\t\tbufoffset=%016llx\n",
-                              volume->ondisk->vol_buf_beg);
+                       printf("Volume header\trecords=%jd next_tid=%016jx\n",
+                              (intmax_t)volume->ondisk->vol0_stat_records,
+                              (uintmax_t)volume->ondisk->vol0_next_tid);
+                       printf("\t\tbufoffset=%016jx\n",
+                              (uintmax_t)volume->ondisk->vol_buf_beg);
                        for (zone = 0; zone < HAMMER_MAX_ZONES; ++zone) {
-                               printf("\t\tzone %d\tnext_offset=%016llx\n",
+                               printf("\t\tzone %d\tnext_offset=%016jx\n",
                                        zone,
-                                       volume->ondisk->vol0_blockmap[zone].next_offset
+                                       (uintmax_t)volume->ondisk->vol0_blockmap[zone].next_offset
                                );
                        }
                }
@@ -91,13 +91,13 @@ hammer_cmd_show(hammer_off_t node_offset, u_int32_t lo, int64_t obj_id,
 
        if (lo == 0 && obj_id == (int64_t)HAMMER_MIN_OBJID) {
                searchp = NULL;
-               printf("show %016llx depth %d\n", node_offset, depth);
+               printf("show %016jx depth %d\n", (uintmax_t)node_offset, depth);
        } else {
                search.lo = lo;
                search.obj_id = obj_id;
                searchp = &search;
-               printf("show %016llx lo %08x obj_id %016llx depth %d\n",
-                       node_offset, lo, (long long)obj_id, depth);
+               printf("show %016jx lo %08x obj_id %016jx depth %d\n",
+                       (uintmax_t)node_offset, lo, (uintmax_t)obj_id, depth);
        }
        print_btree_node(node_offset, searchp, depth,
                        0, left_bound, right_bound);
@@ -127,12 +127,13 @@ print_btree_node(hammer_off_t node_offset, btree_search_t search,
                badc = 'B';
 
        if (spike == 0) {
-               printf("%c   NODE %016llx cnt=%02d p=%016llx "
+               printf("%c   NODE %016jx cnt=%02d p=%016jx "
                       "type=%c depth=%d",
                       badc,
-                      node_offset, node->count, node->parent,
+                      (uintmax_t)node_offset, node->count,
+                      (uintmax_t)node->parent,
                       (node->type ? node->type : '?'), depth);
-               printf(" mirror %016llx", node->mirror_tid);
+               printf(" mirror %016jx", (uintmax_t)node->mirror_tid);
                if (QuietOpt < 3) {
                        printf(" fill=");
                        print_bigblock_fill(node_offset);
@@ -239,22 +240,25 @@ print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
        printf("%s\t%s %2d %c ",
               flagstr, label, i,
               (elm->base.btype ? elm->base.btype : '?'));
-       printf("obj=%016llx key=%016llx lo=%08x rt=%02x ot=%02x\n",
-              elm->base.obj_id,
-              elm->base.key,
+       printf("obj=%016jx key=%016jx lo=%08x rt=%02x ot=%02x\n",
+              (uintmax_t)elm->base.obj_id,
+              (uintmax_t)elm->base.key,
               elm->base.localization,
               elm->base.rec_type,
               elm->base.obj_type);
-       printf("\t       %c tids %016llx:%016llx ",
+       printf("\t       %c tids %016jx:%016jx ",
                (elm->base.delete_tid ? 'd' : ' '),
-              elm->base.create_tid,
-              elm->base.delete_tid);
+              (uintmax_t)elm->base.create_tid,
+              (uintmax_t)elm->base.delete_tid);
 
        switch(type) {
        case HAMMER_BTREE_TYPE_INTERNAL:
-               printf("suboff=%016llx", elm->internal.subtree_offset);
-               if (QuietOpt < 3)
-                       printf(" mirror %016llx", elm->internal.mirror_tid);
+               printf("suboff=%016jx",
+                      (uintmax_t)elm->internal.subtree_offset);
+               if (QuietOpt < 3) {
+                       printf(" mirror %016jx",
+                              (uintmax_t)elm->internal.mirror_tid);
+               }
                if (ext)
                        printf(" %s", ext);
                break;
@@ -267,8 +271,9 @@ print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type,
                                printf("\n%s\t         ", check_data_crc(elm));
                        else
                                printf("\n\t         ");
-                       printf("dataoff=%016llx/%d",
-                               elm->leaf.data_offset, elm->leaf.data_len);
+                       printf("dataoff=%016jx/%d",
+                              (uintmax_t)elm->leaf.data_offset,
+                              elm->leaf.data_len);
                        if (QuietOpt < 3) {
                                printf(" crc=%04x", elm->leaf.data_crc);
                                printf("\n\t         fills=");
@@ -433,26 +438,28 @@ print_record(hammer_btree_elm_t elm)
        switch(elm->leaf.base.rec_type) {
        case HAMMER_RECTYPE_INODE:
                printf("\n%17s", "");
-               printf("size=%lld nlinks=%lld",
-                      data->inode.size, data->inode.nlinks);
+               printf("size=%jd nlinks=%jd",
+                      (intmax_t)data->inode.size,
+                      (intmax_t)data->inode.nlinks);
                if (QuietOpt < 1) {
                        printf(" mode=%05o uflags=%08x\n",
                                data->inode.mode,
                                data->inode.uflags);
                        printf("%17s", "");
-                       printf("ctime=%016llx pobjid=%016llx obj_type=%d\n",
-                               data->inode.ctime, data->inode.parent_obj_id,
+                       printf("ctime=%016jx pobjid=%016jx obj_type=%d\n",
+                               (uintmax_t)data->inode.ctime,
+                               (uintmax_t)data->inode.parent_obj_id,
                                data->inode.obj_type);
                        printf("%17s", "");
-                       printf("mtime=%016llx", data->inode.mtime);
+                       printf("mtime=%016jx", (uintmax_t)data->inode.mtime);
                        printf(" caps=%02x", data->inode.cap_flags);
                }
                break;
        case HAMMER_RECTYPE_DIRENTRY:
                printf("\n%17s", "");
                data_len -= HAMMER_ENTRY_NAME_OFF;
-               printf("dir-entry ino=%016llx lo=%08x name=\"%*.*s\"",
-                      data->entry.obj_id,
+               printf("dir-entry ino=%016jx lo=%08x name=\"%*.*s\"",
+                      (uintmax_t)data->entry.obj_id,
                       data->entry.localization,
                       data_len, data_len, data->entry.name);
                break;
index 1fe38cc..f43b13a 100644 (file)
@@ -136,7 +136,7 @@ hammer_cmd_snapshot(char **av, int ac)
                err(2, "Synctid %s failed", filesystem);
        close(fd);
 
-       asprintf(&from, "%s/@@0x%016llx", filesystem, synctid.tid); 
+       asprintf(&from, "%s/@@0x%016jx", filesystem, (uintmax_t)synctid.tid);
        if (from == NULL)
                err(2, "Couldn't generate string");
        
index 1ed8f8c..91a16f2 100644 (file)
@@ -171,12 +171,12 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
                        continue;
                }
 
-               printf("Prune %s: objspace %016llx:%04x %016llx:%04x "
+               printf("Prune %s: objspace %016jx:%04x %016jx:%04x "
                       "pfs_id %d\n",
                       scan->filesystem,
-                      scan->prune.key_beg.obj_id,
+                      (uintmax_t)scan->prune.key_beg.obj_id,
                       scan->prune.key_beg.localization,
-                      scan->prune.key_end.obj_id,
+                      (uintmax_t)scan->prune.key_end.obj_id,
                       scan->prune.key_end.localization,
                       pfs.pfs_id);
                printf("Prune %s: prune_min is %dd/%02d:%02d:%02d\n",
@@ -193,9 +193,9 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
                        rcode = 2;
                } else if (scan->prune.head.flags & HAMMER_IOC_HEAD_INTR) {
                        printf("Prune %s interrupted by timer at "
-                              "%016llx %04x\n",
+                              "%016jx %04x\n",
                               scan->filesystem,
-                              scan->prune.key_cur.obj_id,
+                              (uintmax_t)scan->prune.key_cur.obj_id,
                               scan->prune.key_cur.localization);
                        if (CyclePath)
                                hammer_set_cycle(&scan->prune.key_cur, 0);
@@ -205,12 +205,12 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
                                hammer_reset_cycle();
                        printf("Prune %s succeeded\n", scan->filesystem);
                }
-               printf("Pruned %lld/%lld records (%lld directory entries) "
-                      "and %lld bytes\n",
-                       scan->prune.stat_rawrecords,
-                       scan->prune.stat_scanrecords,
-                       scan->prune.stat_dirrecords,
-                       scan->prune.stat_bytes
+               printf("Pruned %jd/%jd records (%jd directory entries) "
+                      "and %jd bytes\n",
+                       (uintmax_t)scan->prune.stat_rawrecords,
+                       (uintmax_t)scan->prune.stat_scanrecords,
+                       (uintmax_t)scan->prune.stat_dirrecords,
+                       (uintmax_t)scan->prune.stat_bytes
                );
                RunningIoctl = 0;
                close(fd);
@@ -484,7 +484,8 @@ hammer_softprune_finalize(struct softprune *scan)
        for (i = 0; i < scan->prune.nelms; ++i) {
                elm = &scan->prune.elms[i];
                elm->mod_tid = elm->end_tid - elm->beg_tid;
-               printf("TID %016llx - %016llx\n", elm->beg_tid, elm->end_tid);
+               printf("TID %016jx - %016jx\n",
+                      (uintmax_t)elm->beg_tid, (uintmax_t)elm->end_tid);
        }
 }
 
index d84f825..60f7184 100644 (file)
@@ -92,13 +92,13 @@ hammer_cmd_bstats(char **av, int ac)
                if (count) {
                        if ((count & 15) == 1)
                                printf("  elements iterations    lookups    inserts    deletes     splits\n");
-                       printf("%10lld %10lld %10lld %10lld %10lld %10lld\n",
-                               stats[0] - copy[0],
-                               stats[1] - copy[1],
-                               stats[2] - copy[2],
-                               stats[3] - copy[3],
-                               stats[4] - copy[4],
-                               stats[5] - copy[5]);
+                       printf("%10jd %10jd %10jd %10jd %10jd %10jd\n",
+                               (intmax_t)(stats[0] - copy[0]),
+                               (intmax_t)(stats[1] - copy[1]),
+                               (intmax_t)(stats[2] - copy[2]),
+                               (intmax_t)(stats[3] - copy[3]),
+                               (intmax_t)(stats[4] - copy[4]),
+                               (intmax_t)(stats[5] - copy[5]));
                }
                nanosleep(&delay, NULL);
                bcopy(stats, copy, sizeof(stats));
@@ -164,14 +164,15 @@ hammer_cmd_iostats(char **av, int ac)
                if (count) {
                        if ((count & 15) == 1)
                                printf("   file-rd   file-wr  dev-read dev-write inode_ops ino_flush  commits\n");
-                       printf("%9lld %9lld %9lld %9lld %9lld %8lld %8lld\n",
-                               stats[0] - copy[0],
-                               stats[1] - copy[1],
-                               stats[2] - copy[2],
-                               stats[3] - copy[3],
-                               stats[4] + stats[5] - copy[4] - copy[5],
-                               stats[6] - copy[6],
-                               stats[7] - copy[7]);
+                       printf("%9jd %9jd %9jd %9jd %9jd %8jd %8jd\n",
+                               (intmax_t)(stats[0] - copy[0]),
+                               (intmax_t)(stats[1] - copy[1]),
+                               (intmax_t)(stats[2] - copy[2]),
+                               (intmax_t)(stats[3] - copy[3]),
+                               (intmax_t)(stats[4] + stats[5] -
+                                          copy[4] - copy[5]),
+                               (intmax_t)(stats[6] - copy[6]),
+                               (intmax_t)(stats[7] - copy[7]));
                }
                nanosleep(&delay, NULL);
                bcopy(stats, copy, sizeof(stats));
index 2da8aa0..50f2d4d 100644 (file)
@@ -66,7 +66,7 @@ hammer_cmd_synctid(char **av, int ac)
        if (ioctl(fd, HAMMERIOC_SYNCTID, &synctid) < 0) {
                fprintf(stderr, "Synctid %s failed: %s\n", filesystem, strerror(errno));
        } else {
-               printf("0x%016llx\n", synctid.tid);
+               printf("0x%016jx\n", (uintmax_t)synctid.tid);
        }
        close(fd);
 }
index 6e5c2f1..9d17644 100644 (file)
@@ -49,7 +49,7 @@ hammer_get_cycle(hammer_base_elm_t base, hammer_tid_t *extra)
                        close(fd);
                        return;
                }
-               if (st.st_size < sizeof(*base)) {
+               if (st.st_size < (off_t)sizeof(*base)) {
                        fprintf(stderr, "cycle-file %s: clearing old version\n",
                                CyclePath);
                        close(fd);
index b3ddbb6..000bb99 100644 (file)
@@ -229,7 +229,7 @@ main(int ac, char **av)
                }
                if (key == 0)
                        key |= 0x100000000LL;
-               printf("0x%016llx\n", key);
+               printf("0x%016jx\n", (uintmax_t)key);
                exit(0);
        }
        if (strcmp(av[0], "namekey1") == 0) {
@@ -240,7 +240,7 @@ main(int ac, char **av)
                key = (int64_t)(crc32(av[1], strlen(av[1])) & 0x7FFFFFFF) << 32;
                if (key == 0)
                        key |= 0x100000000LL;
-               printf("0x%016llx\n", key);
+               printf("0x%016jx\n", (uintmax_t)key);
                exit(0);
        }
        if (strcmp(av[0], "namekey32") == 0) {
@@ -378,12 +378,12 @@ main(int ac, char **av)
 
        if (strcmp(av[0], "show") == 0) {
                u_int32_t lo = 0;
-               int64_t obj_id = (int64_t)HAMMER_MIN_OBJID;
+               intmax_t obj_id = (int64_t)HAMMER_MIN_OBJID;
 
                hammer_parsedevs(blkdevs);
                if (ac > 1)
-                       sscanf(av[1], "%08x:%llx", &lo, &obj_id);
-               hammer_cmd_show(-1, lo, obj_id, 0, NULL, NULL);
+                       sscanf(av[1], "%08x:%jx", &lo, &obj_id);
+               hammer_cmd_show(-1, lo, (int64_t)obj_id, 0, NULL, NULL);
                exit(0);
        }
        if (strcmp(av[0], "blockmap") == 0) {
index 6a2576f..8180465 100644 (file)
@@ -63,8 +63,9 @@ dump_debug_stream(struct jstream *js)
        jsread(js, 0, &head, sizeof(head));
 
        sid = head.streamid & JREC_STREAMID_MASK;
-       printf("STREAM %04x %016llx {\n", (int)(u_int16_t)head.streamid,
-               head.transid);
+       printf("STREAM %04x %016jx {\n",
+              (int)(u_int16_t)head.streamid,
+              (uintmax_t)head.transid);
        if (sid >= JREC_STREAMID_JMIN && sid < JREC_STREAMID_JMAX) {
            off_t off = sizeof(head);
 
@@ -108,7 +109,7 @@ dump_debug_subrecord(struct jstream *js, off_t *off, off_t recsize, int level)
            break;
        }
        printf("%*.*s", level * 4, level * 4, "");
-       printf("@%lld ", base);
+       printf("@%jd ", (intmax_t)base);
        printf("RECORD %s [%04x/%d]", type_to_name(sub.rectype), 
                                (int)(u_int16_t)sub.rectype, sub.recsize);
        if (sub.recsize == -1) {
@@ -268,7 +269,7 @@ dump_debug_payload(int16_t rectype, struct jstream *js, off_t off,
            printf(" %d", (int)*(const u_int32_t *)buf);
            break;
        case 8:
-           printf(" %lld", (int64_t)*(const u_int64_t *)buf);
+           printf(" %jd", (intmax_t)*(const int64_t *)buf);
            break;
        default:
            printf(" ?");
@@ -287,7 +288,7 @@ dump_debug_payload(int16_t rectype, struct jstream *js, off_t off,
            printf(" 0x%08x", (int)*(const u_int32_t *)buf);
            break;
        case 8:
-           printf(" 0x%016llx", (int64_t)*(const u_int64_t *)buf);
+           printf(" 0x%016jx", (uintmax_t)*(const u_int64_t *)buf);
            break;
        default:
            printf(" ?");
@@ -306,7 +307,7 @@ dump_debug_payload(int16_t rectype, struct jstream *js, off_t off,
            printf(" %011o", (int)*(const u_int32_t *)buf);
            break;
        case 8:
-           printf(" %022llo", (int64_t)*(const u_int64_t *)buf);
+           printf(" %022jo", (intmax_t)*(const int64_t *)buf);
            break;
        default:
            printf(" ?");
index 57a5919..5890b97 100644 (file)
@@ -98,7 +98,7 @@ jopen_prefix(const char *prefix, int rw)
                den->d_name[baselen] == '.'
            ) {
                seq = strtoul(den->d_name + baselen + 1, &ptr, 16);
-               if (*ptr == 0 && seq != ULONG_MAX) {
+               if (*ptr == 0 && seq != UINT_MAX) {
                    if (seq_beg == (unsigned int)-1 || seq_beg > seq)
                        seq_beg = seq;
                    if (seq_end == (unsigned int)-1 || seq_end < seq)
@@ -700,8 +700,8 @@ jseek(struct jfile *jf, int64_t transid, enum jdirection direction)
                    jd =jread(jf, jd, JD_FORWARDS);
            }
            if (verbose_opt > 1) {
-               fprintf(stderr, "jseek returning seq %08x offset 0x%08llx\n",
-                       jd->jd_seq, jd->jd_pos);
+               fprintf(stderr, "jseek returning seq %08x offset 0x%08jx\n",
+                       jd->jd_seq, (uintmax_t)jd->jd_pos);
            }
            return(jd);
        }
index 8fde057..d3cd8f6 100644 (file)
@@ -269,16 +269,16 @@ main(int ac, char **av)
        transid = 0;
     if (verbose_opt) {
        if (jmodes & JMODEF_OUTPUT) {
-           fprintf(stderr, "Starting transid for OUTPUT: %016llx\n",
-                   output_transid);
+           fprintf(stderr, "Starting transid for OUTPUT: %016jx\n",
+                   (uintmax_t)output_transid);
        }
        if (jmodes & JMODEF_MIRROR) {
-           fprintf(stderr, "Starting transid for MIRROR: %016llx\n",
-                   mirror_transid);
+           fprintf(stderr, "Starting transid for MIRROR: %016jx\n",
+                   (uintmax_t)mirror_transid);
        }
        if (jmodes & JMODEF_RECORD) {
-           fprintf(stderr, "Starting transid for RECORD: %016llx\n",
-                   record_transid);
+           fprintf(stderr, "Starting transid for RECORD: %016jx\n",
+                   (uintmax_t)record_transid);
        }
     }
 
index 6de26fd..574c009 100644 (file)
@@ -69,9 +69,9 @@ jsession_update_transid(struct jsession *ss __unused, int64_t transid)
            exit(1);
        }
        if (ss->ss_direction == JD_FORWARDS)
-           snprintf(buf, sizeof(buf), "%016llx\n", transid);
+           snprintf(buf, sizeof(buf), "%016jx\n", (uintmax_t)transid);
        else
-           snprintf(buf, sizeof(buf), "%016llx\n", transid - 1);
+           snprintf(buf, sizeof(buf), "%016jx\n", (uintmax_t)(transid - 1));
        lseek(ss->ss_transid_fd, 0L, 0);
        write(ss->ss_transid_fd, buf, strlen(buf));
        if (fsync_opt > 1)
index 844d88e..b1f94e5 100644 (file)
@@ -125,26 +125,38 @@ retry:
            (head->streamid & JREC_STREAMCTL_BEGIN) == 0
        ) {
            if (verbose_opt > 1)
-               fprintf(stderr, "mid-transaction detected transid %016llx streamid %04x\n", jd->jd_transid, head->streamid & JREC_STREAMID_MASK);
+               fprintf(stderr, "mid-transaction detected transid %016jx "
+                               "streamid %04x\n",
+                       (uintmax_t)jd->jd_transid,
+                       head->streamid & JREC_STREAMID_MASK);
            if (jaddrecord_backtrack(ss, jd) == 0) {
                if (verbose_opt)
-                   fprintf(stderr, "mid-transaction streamid %04x collection succeeded\n", head->streamid & JREC_STREAMID_MASK);
+                   fprintf(stderr, "mid-transaction streamid %04x collection "
+                                   "succeeded\n",
+                           head->streamid & JREC_STREAMID_MASK);
                goto retry;
            }
-           fprintf(stderr, "mid-transaction streamid %04x collection failed\n", head->streamid & JREC_STREAMID_MASK);
+           fprintf(stderr, "mid-transaction streamid %04x collection failed\n",
+                   head->streamid & JREC_STREAMID_MASK);
            jscan_dispose(js);
            return(NULL);
        } else if (ss->ss_direction == JD_BACKWARDS &&
            (head->streamid & JREC_STREAMCTL_END) == 0
        ) {
            if (verbose_opt > 1)
-               fprintf(stderr, "mid-transaction detected transid %016llx streamid %04x\n", jd->jd_transid, head->streamid & JREC_STREAMID_MASK);
+               fprintf(stderr, "mid-transaction detected transid %016jx "
+                               "streamid %04x\n",
+                               (uintmax_t)jd->jd_transid,
+                               head->streamid & JREC_STREAMID_MASK);
            if (jaddrecord_backtrack(ss, jd) == 0) {
                if (verbose_opt)
-                   fprintf(stderr, "mid-transaction streamid %04x collection succeeded\n", head->streamid & JREC_STREAMID_MASK);
+                   fprintf(stderr, "mid-transaction streamid %04x "
+                                   "collection succeeded\n",
+                           head->streamid & JREC_STREAMID_MASK);
                goto retry;
            }
-           fprintf(stderr, "mid-transaction streamid %04x collection failed\n", head->streamid & JREC_STREAMID_MASK);
+           fprintf(stderr, "mid-transaction streamid %04x collection failed\n",
+                   head->streamid & JREC_STREAMID_MASK);
            jscan_dispose(js);
            return(NULL);
        }
index 014baef..8f2e127 100644 (file)
@@ -41,7 +41,7 @@ jf_warn(struct jfile *jf, const char *ctl, ...)
 {
     va_list va;
 
-    fprintf(stderr, "@0x%016llx ", jf->jf_pos);
+    fprintf(stderr, "@0x%016jx ", (uintmax_t)jf->jf_pos);
     va_start(va, ctl);
     vfprintf(stderr, ctl, va);
     va_end(va);
index 7717829..bc6b7f7 100644 (file)
@@ -466,7 +466,7 @@ mountctl_list(const char *keyword __unused, const char *mountpt,
     printf("    membufused=%s\n", numtostr(rstat->membufused));
     printf("    membufunacked=%s\n", numtostr(rstat->membufunacked));
     printf("    total_bytes=%s\n", numtostr(rstat->bytessent));
-    printf("    fifo_stalls=%lld\n", rstat->fifostalls);
+    printf("    fifo_stalls=%jd\n", (intmax_t)rstat->fifostalls);
 }
 
 static void
@@ -619,7 +619,7 @@ numtostr(int64_t num)
     static char buf[64];
 
     if (num < 1024)
-       snprintf(buf, sizeof(buf), "%lld", num);
+       snprintf(buf, sizeof(buf), "%jd", (intmax_t)num);
     else if (num < 10 * 1024)
        snprintf(buf, sizeof(buf), "%3.2fK", num / 1024.0);
     else if (num < 1024 * 1024)
index 7835557..fc4b555 100644 (file)
@@ -521,8 +521,10 @@ getnextinode(ino_t inumber)
        daddr_t dblk;
        static struct ufs1_dinode *dp;
 
-       if (inumber != nextino++ || inumber > maxino)
-               errx(1, "bad inode number %llu to nextinode", inumber);
+       if (inumber != nextino++ || inumber > maxino) {
+               errx(1, "bad inode number %ju to nextinode",
+                       (intmax_t)inumber);
+       }
        if (inumber >= lastinum) {
                readcnt++;
                dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
index dec1e92..5978a34 100644 (file)
@@ -400,8 +400,8 @@ gethdr:
                goto again;
        }
        if (tmpbuf.c_date != dumpdate || tmpbuf.c_ddate != dumptime) {
-               fprintf(stderr, "Wrong dump date\n\tgot: %s",
-                       ctime(&tmpbuf.c_date));
+               time_t c_date = tmpbuf.c_date;
+               fprintf(stderr, "Wrong dump date\n\tgot: %s", ctime(&c_date));
                fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
                volno = 0;
                goto again;
@@ -507,9 +507,12 @@ setdumpnum(void)
 void
 printdumpinfo(void)
 {
-       fprintf(stdout, "Dump   date: %s", ctime(&spcl.c_date));
+       time_t c_date = spcl.c_date;
+       time_t c_ddate = spcl.c_ddate;
+
+       fprintf(stdout, "Dump   date: %s", ctime(&c_date));
        fprintf(stdout, "Dumped from: %s",
-           (spcl.c_ddate == 0) ? "the epoch\n" : ctime(&spcl.c_ddate));
+           (spcl.c_ddate == 0) ? "the epoch\n" : ctime(&c_ddate));
        if (spcl.c_host[0] == '\0')
                return;
        fprintf(stderr, "Level %ld dump of %s on %s:%s\n",
index 18da3d6..8af09a9 100644 (file)
@@ -294,8 +294,8 @@ kmem_setup(void)
        }
                dumplo = kdumplo * DEV_BSIZE;
        if (verbose)
-               printf("dumplo = %lld (%lld * %d)\n",
-                   (long long)dumplo, kdumplo, DEV_BSIZE);
+               printf("dumplo = %jd (%jd * %d)\n",
+                   (intmax_t)dumplo, (intmax_t)kdumplo, DEV_BSIZE);
        Lseek(kmem, (off_t)current_nl[X_DUMPMAG].n_value, L_SET);
        Read(kmem, &dumpmag, sizeof(dumpmag));
        dumpfd = Open(ddname, O_RDWR);
@@ -431,7 +431,7 @@ err1:                       syslog(LOG_WARNING, "%s: %m", path);
        for (; dumpsize > 0; dumpsize -= nr) {
                printf("%6ldK\r", (long)(dumpsize / 1024));
                fflush(stdout);
-               nr = read(dumpfd, buf, MIN(dumpsize, sizeof(buf)));
+               nr = read(dumpfd, buf, MIN((uintmax_t)dumpsize, sizeof(buf)));
                if (nr <= 0) {
                        if (nr == 0)
                                syslog(LOG_WARNING,
index 30fa24b..750f96e 100644 (file)
@@ -382,7 +382,7 @@ S_sensor(int l2, void *p)
                            (s->value - 273150000) / 1000000.0);
                        break;
                case SENSOR_FANRPM:
-                       printf("%lld RPM", s->value);
+                       printf("%jd RPM", (intmax_t)s->value);
                        break;
                case SENSOR_VOLTS_DC:
                        printf("%.2f VDC", s->value / 1000000.0);
@@ -400,7 +400,7 @@ S_sensor(int l2, void *p)
                        printf("%s", s->value ? "On" : "Off");
                        break;
                case SENSOR_INTEGER:
-                       printf("%lld", s->value);
+                       printf("%jd", (intmax_t)s->value);
                        break;
                case SENSOR_PERCENT:
                        printf("%.2f%%", s->value / 1000.0);
@@ -735,10 +735,13 @@ show_var(int *oid, size_t nlen)
                fmt++;
                spacer = "";
                while (len >= sizeof(quad_t)) {
-                       if(*fmt == 'U')
-                               printf("%s%qu", spacer, *(u_quad_t *)p);
-                       else
-                               printf("%s%qd", spacer, *(quad_t *)p);
+                       if(*fmt == 'U') {
+                               printf("%s%ju",
+                                      spacer, (uintmax_t)*(u_quad_t *)p);
+                       } else {
+                               printf("%s%jd",
+                                      spacer, (intmax_t)*(quad_t *)p);
+                       }
                        spacer = " ";
                        len -= sizeof(int64_t);
                        p += sizeof(int64_t);
index d64ab1b..68c1c83 100644 (file)
@@ -27,6 +27,7 @@
  * $DragonFly: src/secure/lib/libssh/version.c,v 1.1 2004/07/31 20:05:00 geekgod Exp $
  */
 
+#include <string.h>
 #include "version.h"
 #include "includes.h"
 #include "xmalloc.h"
index f634054..002a961 100644 (file)
@@ -113,7 +113,7 @@ struct smbioc_rq {
 struct smbioc_t2rq {
        u_int16_t       ioc_setup[3];
        int             ioc_setupcnt;
-       char *          ioc_name;
+       const char *    ioc_name;
        u_short         ioc_tparamcnt;
        void *          ioc_tparam;
        u_short         ioc_tdatacnt;
index 4f0eb09..c89d582 100644 (file)
@@ -56,7 +56,7 @@ void
 diffmsg(const char *file1, const char *file2, off_t byte, off_t line)
 {
        if (!sflag)
-               (void)printf("%s %s differ: char %qd, line %qd\n",
-                   file1, file2, byte, line);
+               (void)printf("%s %s differ: char %jd, line %jd\n",
+                   file1, file2, (intmax_t)byte, (intmax_t)line);
        exit(DIFF_EXIT);
 }
index afcf35c..81407a1 100644 (file)
@@ -102,13 +102,16 @@ c_regular(int fd1, const char *file1, off_t skip1, off_t len1, int fd2,
                if ((ch = *p1) != *p2) {
                        if (xflag) {
                                dfound = 1;
-                               (void)printf("%08qx %02x %02x\n", byte - 1, ch, *p2);
+                               printf("%08jx %02x %02x\n",
+                                      (intmax_t)byte - 1, ch, *p2);
                        } else if (lflag) {
                                dfound = 1;
-                               (void)printf("%6qd %3o %3o\n", byte, ch, *p2);
-                       } else
+                               printf("%6jd %3o %3o\n",
+                                      (intmax_t)byte, ch, *p2);
+                       } else {
                                diffmsg(file1, file2, byte, line);
                                /* NOTREACHED */
+                       }
                }
                if (ch == '\n')
                        ++line;
index 133bf91..73e2507 100644 (file)
@@ -75,7 +75,8 @@ c_special(int fd1, const char *file1, off_t skip1, int fd2, const char *file2,
                if (ch1 != ch2) {
                        if (lflag) {
                                dfound = 1;
-                               (void)printf("%6qd %3o %3o\n", byte, ch1, ch2);
+                               printf("%6jd %3o %3o\n",
+                                      (intmax_t)byte, ch1, ch2);
                        } else {
                                diffmsg(file1, file2, byte, line);
                                /* NOTREACHED */
index 51b50f1..f566338 100644 (file)
@@ -305,7 +305,7 @@ show_text(const char *directory, const char *file_name, const char *header)
                return(0);
 
        /* If short enough, and no newlines, show it on a single line.*/
-       if (sb.st_size <= LINE_LEN - strlen(header) - 5) {
+       if ((uintptr_t)sb.st_size <= LINE_LEN - strlen(header) - 5) {
                nr = read(fd, tbuf, sizeof(tbuf));
                if (nr <= 0) {
                        (void)close(fd);
index 7511954..5279ec1 100644 (file)
@@ -115,7 +115,7 @@ enter_lastlog(PERSON *pn)
        }
        if (fd == -1 ||
            lseek(fd, (long)pn->uid * sizeof(ll), SEEK_SET) !=
-           (long)pn->uid * sizeof(ll) ||
+           (off_t)((long)pn->uid * sizeof(ll)) ||
            read(fd, (char *)&ll, sizeof(ll)) != sizeof(ll)) {
                        /* as if never logged in */
                        ll.ll_line[0] = ll.ll_host[0] = '\0';
index efb9856..45014b4 100644 (file)
@@ -98,8 +98,12 @@ addarc(nltype *parentp, nltype *childp, long count)
      */
 nltype **topsortnlp;
 
-topcmp(nltype **npp1, nltype **npp2)
+int
+topcmp(const void *arg1, const void *arg2)
 {
+    nltype *const*npp1 = arg1;
+    nltype *const*npp2 = arg2;
+
     return (*npp1) -> toporder - (*npp2) -> toporder;
 }
 
index 65a9a76..8763c81 100644 (file)
@@ -661,8 +661,10 @@ printblurb(char *blurbname)
 }
 
 int
-namecmp(nltype **npp1, nltype **npp2)
+namecmp(const void *arg1, const void *arg2)
 {
+    nltype *const*npp1 = arg1;
+    nltype *const*npp2 = arg2;
     return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
 }
 
index 0de352a..469ec02 100644 (file)
@@ -519,7 +519,7 @@ print_limit(rlim_t limit, unsigned divisor, const char * inf, const char * pfx,
     if (limit == RLIM_INFINITY)
        strcpy(numbr, inf);
     else
-       sprintf(numbr, "%qd", (quad_t)((limit + divisor/2) / divisor));
+       sprintf(numbr, "%jd", (intmax_t)((limit + divisor/2) / divisor));
     printf(pfx, which, numbr);
     printf(sfx, which);
 
index 18b5e3a..e2b1f8b 100644 (file)
@@ -166,7 +166,7 @@ monitor_events(void)
                printf("%-23s", elm->path);
                if (VerboseOpt && fstat(kev->ident, &st) == 0 &&
                    S_ISREG(st.st_mode)) {
-                       printf(" %10lld", st.st_size);
+                       printf(" %10jd", (intmax_t)st.st_size);
                }
                while (QuietOpt == 0 && (bno = ffs(kev->fflags)) > 0) {
                        printf(" ");
index 82e8782..7153613 100644 (file)
@@ -72,8 +72,8 @@ mapprint(struct mapinfo *mip, off_t startoff, off_t len)
        int n;
 
        while (len > 0) {
-               if (startoff < mip->mapoff || startoff >= mip->mapoff +
-                   mip->maplen) {
+               if (startoff < mip->mapoff ||
+                   startoff >= (intmax_t)(mip->mapoff + mip->maplen)) {
                        if (maparound(mip, startoff) != 0)
                                return (1);
                }
@@ -101,7 +101,7 @@ maparound(struct mapinfo *mip, off_t offset)
 
        mip->mapoff = offset & ~((off_t)TAILMAPLEN - 1);
        mip->maplen = TAILMAPLEN;
-       if (mip->maplen > mip->maxoff - mip->mapoff)
+       if (mip->maplen > (uintmax_t)(mip->maxoff - mip->mapoff))
                mip->maplen = mip->maxoff - mip->mapoff;
        if (mip->maplen <= 0)
                abort();
index c668c1c..695e8d7 100644 (file)
@@ -120,7 +120,8 @@ r_reg(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
        curoff = size - 2;
        lineend = size;
        while (curoff >= 0) {
-               if (curoff < map.mapoff || curoff >= map.mapoff + map.maplen) {
+               if (curoff < map.mapoff ||
+                   curoff >= (intmax_t)(map.mapoff + map.maplen)) {
                        if (maparound(&map, curoff) != 0) {
                                ierr();
                                return;
@@ -237,7 +238,7 @@ r_buf(FILE *fp)
        }
 
        if (enomem) {
-               warnx("warning: %qd bytes discarded", enomem);
+               warnx("warning: %jd bytes discarded", (intmax_t)enomem);
                rval = 1;
        }
 
index bf3d2cc..ce527a7 100644 (file)
@@ -49,7 +49,7 @@
 #include <string.h>
 #include <unistd.h>
 
-u_quad_t tlinect, twordct, tcharct;
+uintmax_t tlinect, twordct, tcharct;
 int doline, doword, dochar, domulti;
 
 static int     cnt(const char *);
@@ -108,11 +108,11 @@ main(int argc, char **argv)
 
        if (total > 1) {
                if (doline)
-                       printf(" %7qu", tlinect);
+                       printf(" %7ju", tlinect);
                if (doword)
-                       printf(" %7qu", twordct);
+                       printf(" %7ju", twordct);
                if (dochar || domulti)
-                       printf(" %7qu", tcharct);
+                       printf(" %7ju", tcharct);
                printf(" total\n");
        }
        exit(errors == 0 ? 0 : 1);
@@ -160,10 +160,10 @@ cnt(const char *file)
                                }
                        }
                        tlinect += linect;
-                       printf(" %7qu", linect);
+                       printf(" %7ju", linect);
                        if (dochar) {
                                tcharct += charct;
-                               printf(" %7qu", charct);
+                               printf(" %7ju", charct);
                        }
                        close(fd);
                        return (0);
@@ -232,15 +232,15 @@ word:     gotsp = 1;
        }
        if (doline) {
                tlinect += linect;
-               printf(" %7qu", linect);
+               printf(" %7ju", linect);
        }
        if (doword) {
                twordct += wordct;
-               printf(" %7qu", wordct);
+               printf(" %7ju", wordct);
        }
        if (dochar || domulti) {
                tcharct += charct;
-               printf(" %7qu", charct);
+               printf(" %7ju", charct);
        }
        close(fd);
        return (0);