On Sun, Aug 14, 2016 at 09:59:21PM -0700, Philip Guenther wrote: > > du is an easy on, though the use of fts_number here reminded me that we > need to increase to a long long at some point like the other BSDs did. > > hexdump is...subtle, as it both creates format strings on the fly and > *rewrites* them! Turns out it was using %q for both of those, hah! The > display.c change is a straight forward quad_t-->int64_t conversion, while > the parse.c change is to use %ll instead of %q. > > systat just needs u_quad_t to be converted to uint64_t, but while we're > here let's convert bcopy() to memcpy() and bzero() to memset(). > > ok?
QK, reads fine to me. See one comment below. > > PHilip > > Index: usr.bin/du/du.c > =================================================================== > RCS file: /data/src/openbsd/src/usr.bin/du/du.c,v > retrieving revision 1.31 > diff -u -p -r1.31 du.c > --- usr.bin/du/du.c 10 Oct 2015 05:32:52 -0000 1.31 > +++ usr.bin/du/du.c 15 Aug 2016 04:08:25 -0000 > @@ -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: usr.bin/hexdump/display.c > =================================================================== > RCS file: /data/src/openbsd/src/usr.bin/hexdump/display.c,v > retrieving revision 1.24 > diff -u -p -r1.24 display.c > --- usr.bin/hexdump/display.c 15 Mar 2016 04:19:13 -0000 1.24 > +++ usr.bin/hexdump/display.c 15 Aug 2016 04:16:35 -0000 > @@ -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: usr.bin/hexdump/parse.c > =================================================================== > RCS file: /data/src/openbsd/src/usr.bin/hexdump/parse.c,v > retrieving revision 1.20 > diff -u -p -r1.20 parse.c > --- usr.bin/hexdump/parse.c 15 Mar 2016 04:19:13 -0000 1.20 > +++ usr.bin/hexdump/parse.c 15 Aug 2016 04:13:28 -0000 > @@ -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: usr.bin/systat/vmstat.c > =================================================================== > RCS file: /data/src/openbsd/src/usr.bin/systat/vmstat.c,v > retrieving revision 1.80 > diff -u -p -r1.80 vmstat.c > --- usr.bin/systat/vmstat.c 20 Aug 2015 22:32:42 -0000 1.80 > +++ usr.bin/systat/vmstat.c 15 Aug 2016 04:35:28 -0000 > @@ -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); The little *intrcnt is looking for his parens. Seriously, this is somewhat confusing here without them. > } > > static void >