Convert quad_t to int64_t and %q to %ll
authorguenther <guenther@openbsd.org>
Wed, 24 Aug 2016 03:13:45 +0000 (03:13 +0000)
committerguenther <guenther@openbsd.org>
Wed, 24 Aug 2016 03:13:45 +0000 (03:13 +0000)
Convert bzero() to memset() and bcopy() to memcpy()

ok natano@ millert@

usr.bin/du/du.c
usr.bin/hexdump/display.c
usr.bin/hexdump/parse.c
usr.bin/systat/vmstat.c

index 95b409c..c266382 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: du.c,v 1.31 2015/10/10 05:32:52 deraadt Exp $ */
+/*     $OpenBSD: du.c,v 1.32 2016/08/24 03:13:45 guenther Exp $        */
 /*     $NetBSD: du.c,v 1.11 1996/10/18 07:20:35 thorpej Exp $  */
 
 /*
@@ -50,7 +50,7 @@
 
 
 int     linkchk(FTSENT *);
-void    prtout(quad_t, char *, int);
+void    prtout(int64_t, char *, int);
 void    usage(void);
 
 int
@@ -59,7 +59,7 @@ main(int argc, char *argv[])
        FTS *fts;
        FTSENT *p;
        long blocksize;
-       quad_t totalblocks;
+       int64_t totalblocks;
        int ftsoptions, listfiles, maxdepth;
        int Hflag, Lflag, cflag, hflag, kflag;
        int ch, notused, rval;
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
                         * root of a traversal, display the total.
                         */
                        if (p->fts_level <= maxdepth)
-                               prtout((quad_t)howmany(p->fts_number,
+                               prtout(howmany(p->fts_number,
                                    (unsigned long)blocksize), p->fts_path,
                                    hflag);
                        break;
@@ -207,7 +207,7 @@ main(int argc, char *argv[])
        if (errno)
                err(1, "fts_read");
        if (cflag) {
-               prtout((quad_t)howmany(totalblocks, blocksize), "total", hflag);
+               prtout(howmany(totalblocks, blocksize), "total", hflag);
        }
        fts_close(fts);
        exit(rval);
@@ -301,17 +301,17 @@ linkchk(FTSENT *p)
 }
 
 void
-prtout(quad_t size, char *path, int hflag)
+prtout(int64_t size, char *path, int hflag)
 {
        if (!hflag)
-               (void)printf("%lld\t%s\n", (long long)size, path);
+               (void)printf("%lld\t%s\n", size, path);
        else {
                char buf[FMT_SCALED_STRSIZE];
 
                if (fmt_scaled(size * 512, buf) == 0)
                        (void)printf("%s\t%s\n", buf, path);
                else
-                       (void)printf("%lld\t%s\n", (long long)size, path);
+                       (void)printf("%lld\t%s\n", size, path);
        }
 }
 
index 88fed34..4696207 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: display.c,v 1.24 2016/03/15 04:19:13 mmcc Exp $       */
+/*     $OpenBSD: display.c,v 1.25 2016/08/24 03:13:45 guenther Exp $   */
 /*     $NetBSD: display.c,v 1.12 2001/12/07 15:14:29 bjh21 Exp $       */
 
 /*
@@ -100,7 +100,7 @@ display(void)
                for (pr = endfu->nextpr; pr; pr = pr->nextpr)
                        switch(pr->flags) {
                        case F_ADDRESS:
-                               (void)printf(pr->fmt, (quad_t)eaddress);
+                               (void)printf(pr->fmt, (int64_t)eaddress);
                                break;
                        case F_TEXT:
                                (void)printf("%s", pr->fmt);
@@ -123,7 +123,7 @@ print(PR *pr, u_char *bp)
 
        switch(pr->flags) {
        case F_ADDRESS:
-               (void)printf(pr->fmt, (quad_t)address);
+               (void)printf(pr->fmt, (int64_t)address);
                break;
        case F_BPAD:
                (void)printf(pr->fmt, "");
@@ -149,15 +149,15 @@ print(PR *pr, u_char *bp)
        case F_INT:
                switch(pr->bcnt) {
                case 1:
-                       (void)printf(pr->fmt, (quad_t)*bp);
+                       (void)printf(pr->fmt, (int64_t)*bp);
                        break;
                case 2:
                        memmove(&s2, bp, sizeof(s2));
-                       (void)printf(pr->fmt, (quad_t)s2);
+                       (void)printf(pr->fmt, (int64_t)s2);
                        break;
                case 4:
                        memmove(&s4, bp, sizeof(s4));
-                       (void)printf(pr->fmt, (quad_t)s4);
+                       (void)printf(pr->fmt, (int64_t)s4);
                        break;
                case 8:
                        memmove(&s8, bp, sizeof(s8));
@@ -180,15 +180,15 @@ print(PR *pr, u_char *bp)
        case F_UINT:
                switch(pr->bcnt) {
                case 1:
-                       (void)printf(pr->fmt, (u_quad_t)*bp);
+                       (void)printf(pr->fmt, (uint64_t)*bp);
                        break;
                case 2:
                        memmove(&u2, bp, sizeof(u2));
-                       (void)printf(pr->fmt, (u_quad_t)u2);
+                       (void)printf(pr->fmt, (uint64_t)u2);
                        break;
                case 4:
                        memmove(&u4, bp, sizeof(u4));
-                       (void)printf(pr->fmt, (u_quad_t)u4);
+                       (void)printf(pr->fmt, (uint64_t)u4);
                        break;
                case 8:
                        memmove(&u8, bp, sizeof(u8));
index 8d0a104..3217699 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.c,v 1.20 2016/03/15 04:19:13 mmcc Exp $ */
+/*     $OpenBSD: parse.c,v 1.21 2016/08/24 03:13:45 guenther Exp $     */
 /*     $NetBSD: parse.c,v 1.12 2001/12/07 13:37:39 bjh21 Exp $ */
 
 /*
@@ -217,7 +217,7 @@ rewrite(FS *fs)
        PR *pr, **nextpr;
        FU *fu;
        char *p1, *p2;
-       char savech, *fmtp, cs[3];
+       char savech, *fmtp, cs[4];
        int nconv, prec;
        size_t len;
 
@@ -295,9 +295,10 @@ rewrite(FS *fs)
                                else
                                        pr->flags = F_UINT;
 
-                               cs[2] = '\0';
-                               cs[1] = cs[0];
-                               cs[0] = 'q';
+                               cs[3] = '\0';
+                               cs[2] = cs[0];
+                               cs[1] = 'l';
+                               cs[0] = 'l';
                                switch(fu->bcnt) {
                                case 0: case 4:
                                        pr->bcnt = 4;
@@ -355,9 +356,10 @@ rewrite(FS *fs)
                                        ++p2;
                                        switch(p1[2]) {
                                        case 'd': case 'o': case'x':
-                                               cs[0] = 'q';
-                                               cs[1] = p1[2];
-                                               cs[2] = '\0';
+                                               cs[0] = 'l';
+                                               cs[1] = 'l';
+                                               cs[2] = p1[2];
+                                               cs[3] = '\0';
                                                break;
                                        default:
                                                if (p1[2])
index 4f53c0b..9410d4a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmstat.c,v 1.80 2015/08/20 22:32:42 deraadt Exp $     */
+/*     $OpenBSD: vmstat.c,v 1.81 2016/08/24 03:13:45 guenther Exp $    */
 /*     $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $       */
 
 /*-
@@ -64,7 +64,7 @@ static struct Info {
        struct  vmtotal Total;
        struct  nchstats nchstats;
        long    nchcount;
-       u_quad_t *intrcnt;
+       uint64_t *intrcnt;
 } s, s1, s2, s3, z;
 
 extern struct _disk    cur;
@@ -606,25 +606,25 @@ getinfo(struct Info *si)
        size = sizeof(si->time);
        if (sysctl(cp_time_mib, 2, &si->time, &size, NULL, 0) < 0) {
                error("Can't get KERN_CPTIME: %s\n", strerror(errno));
-               bzero(&si->time, sizeof(si->time));
+               memset(&si->time, 0, sizeof(si->time));
        }
 
        size = sizeof(si->nchstats);
        if (sysctl(nchstats_mib, 2, &si->nchstats, &size, NULL, 0) < 0) {
                error("Can't get KERN_NCHSTATS: %s\n", strerror(errno));
-               bzero(&si->nchstats, sizeof(si->nchstats));
+               memset(&si->nchstats, 0, sizeof(si->nchstats));
        }
 
        size = sizeof(si->uvmexp);
        if (sysctl(uvmexp_mib, 2, &si->uvmexp, &size, NULL, 0) < 0) {
                error("Can't get VM_UVMEXP: %s\n", strerror(errno));
-               bzero(&si->uvmexp, sizeof(si->uvmexp));
+               memset(&si->uvmexp, 0, sizeof(si->uvmexp));
        }
 
        size = sizeof(si->Total);
        if (sysctl(vmtotal_mib, 2, &si->Total, &size, NULL, 0) < 0) {
                error("Can't get VM_METER: %s\n", strerror(errno));
-               bzero(&si->Total, sizeof(si->Total));
+               memset(&si->Total, 0, sizeof(si->Total));
        }
 }
 
@@ -632,7 +632,7 @@ static void
 allocinfo(struct Info *si)
 {
        memset(si, 0, sizeof(*si));
-       si->intrcnt = calloc(nintr, sizeof(u_quad_t));
+       si->intrcnt = calloc(nintr, sizeof(*si->intrcnt));
        if (si->intrcnt == NULL)
                errx(2, "out of memory");
 }
@@ -640,11 +640,11 @@ allocinfo(struct Info *si)
 static void
 copyinfo(struct Info *from, struct Info *to)
 {
-       u_quad_t *intrcnt;
+       uint64_t *intrcnt;
 
        intrcnt = to->intrcnt;
        *to = *from;
-       bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (u_quad_t));
+       memcpy(to->intrcnt = intrcnt, from->intrcnt, nintr * sizeof(*intrcnt));
 }
 
 static void