format pointer subtraction results with %zd instead of %ld (for long -> intptr on amd64)

This commit is contained in:
cinap_lenrek 2016-01-07 04:44:13 +01:00
parent 9c99d0c8d3
commit 772afbe98c
35 changed files with 50 additions and 49 deletions

View file

@ -511,7 +511,7 @@ print("esp: bad auth %I -> %I!%ld\n", vers.raddr, vers.laddr, vers.spi);
payload = BLEN(bp) - vers.hdrlen - ecb->ahlen;
if(payload <= 0 || payload % 4 != 0 || payload % ecb->espblklen != 0) {
qunlock(c);
netlog(f, Logesp, "esp: bad length %I -> %I!%lud payload=%d BLEN=%lud\n",
netlog(f, Logesp, "esp: bad length %I -> %I!%lud payload=%d BLEN=%zd\n",
vers.raddr, vers.laddr, vers.spi, payload, BLEN(bp));
freeb(bp);
return;

View file

@ -310,7 +310,7 @@ pcmpinit(void)
*/
while(p < e) switch(*p){
default:
print("pcmpinit: unknown PCMP type 0x%uX (e-p 0x%luX)\n",
print("pcmpinit: unknown PCMP type 0x%uX (e-p 0x%zuX)\n",
*p, e-p);
while(p < e){
print("%uX ", *p);

View file

@ -2658,7 +2658,7 @@ transmit(Wifi *wifi, Wnode *wn, Block *b)
p = pool->p + pool->i * TxwiDmaSz;
w = (Wifipkt*)(p + Txwisize);
if(ctlr->wifi->debug){
print("transmit: %E->%E,%E nodeid=%x txq[%d]=%d size=%ld\n", w->a2, w->a1, w->a3, nodeid, qid, ctlr->tx[qid].i, BLEN(outb));
print("transmit: %E->%E,%E nodeid=%x txq[%d]=%d size=%zd\n", w->a2, w->a1, w->a3, nodeid, qid, ctlr->tx[qid].i, BLEN(outb));
}
tx->i = (tx->i + 1) % Ntx;

View file

@ -2141,7 +2141,7 @@ atarsp(Block *b)
case Crd:
case Crdext:
if(BLEN(b) - (Aoehsz + Aoeatasz) != n){
eventlog("%æ: misread blen %ld expect %d\n",
eventlog("%æ: misread blen %zd expect %d\n",
d, BLEN(b), n);
goto bail;
}
@ -2159,7 +2159,7 @@ atarsp(Block *b)
break;
case Cid:
if(BLEN(b) - (Aoehsz + Aoeatasz) < 512){
eventlog("%æ: runt identify blen %ld expect %d\n",
eventlog("%æ: runt identify blen %zd expect %d\n",
d, BLEN(b), 512 + Aoehsz + Aoeatasz);
goto bail;
}

View file

@ -1115,7 +1115,7 @@ tlsbread(Chan *c, long n, ulong offset)
/* return at most what was asked for */
b = qgrab(&tr->processed, n);
if(tr->debug) pprint("consumed processed %ld\n", BLEN(b));
if(tr->debug) pprint("consumed processed %zd\n", BLEN(b));
if(tr->debug) pdump(BLEN(b), b->rp, "consumed:");
qunlock(&tr->in.io);
poperror();
@ -1272,7 +1272,7 @@ tlsrecwrite(TlsRec *tr, int type, Block *b)
nexterror();
}
qlock(&out->io);
if(tr->debug)pprint("send %ld\n", BLEN(b));
if(tr->debug)pprint("send %zd\n", BLEN(b));
if(tr->debug)pdump(BLEN(b), b->rp, "sent:");

View file

@ -1362,7 +1362,7 @@ scheddump(void)
for(rq = &runq[Nrq-1]; rq >= runq; rq--){
if(rq->head == nil)
continue;
print("rq%ld:", rq-runq);
print("rq%zd:", rq-runq);
for(p = rq->head; p != nil; p = p->rnext)
print(" %lud(%lud)", p->pid, m->ticks - p->readytime);
print("\n");

View file

@ -130,7 +130,7 @@ newfid(Session *s)
*(f->owner) = 0;
f->owner = 0;
}
chat("%ld...", f - s->fids);
chat("%zd...", f - s->fids);
f->tstale = nfstime + staletime;
return f;
}
@ -153,7 +153,7 @@ setfid(Session *s, Fid *f)
void
putfid(Session *s, Fid *f)
{
chat("putfid %ld...", f-s->fids);
chat("putfid %zd...", f-s->fids);
if(s == 0 || f == 0){
clog("putfid(0x%p, 0x%p) %s", s, f, (s ? s->service : "?"));
return;

View file

@ -330,7 +330,7 @@ xfwalkcr(int type, Xfid *xf, String *elem, long perm)
newxf->urfid = nfid;
nfid->owner = &newxf->urfid;
}else if(newxf->urfid){
chat("old xfid %ld...", newxf->urfid-s->fids);
chat("old xfid %zd...", newxf->urfid-s->fids);
clunkfid(s, nfid);
}else{
newxf->urfid = nfid;

View file

@ -159,7 +159,7 @@ srvinit(int fd, char *file, char *addr)
xp->name = "/";
xf = xfid("none", xp, 1);
xf->urfid = f;
clog("service=%s uid=%s fid=%ld\n",
clog("service=%s uid=%s fid=%zd\n",
s->service, xf->uid, xf->urfid - s->fids);
if(tail)
tail->next = s;

View file

@ -57,7 +57,7 @@ strprint(int fd)
for(bin = stab; bin < stab+STRHASH; bin++)
for(x=*bin; x; x=x->next)
fprint(fd, "%ld %s\n", bin-stab, x->str);
fprint(fd, "%zd %s\n", bin-stab, x->str);
}
static long

View file

@ -255,7 +255,7 @@ rdcpline(Biobuf *b, Cpline *cpl)
cpl->dlen = cpl->bytes[0];
if(cpl->dlen + 5 != up - cpl->bytes){
fprint(2, "%d %ld\n", cpl->dlen + 5, up - cpl->bytes);
fprint(2, "%d %zd\n", cpl->dlen + 5, up - cpl->bytes);
return "bad data length";
}

View file

@ -225,7 +225,7 @@ iget(Icache *ic, Qid qid)
/*
* init inode and write to disk
*/
DPRINT(2, "new file %llud.%ld ino %ld\n",
DPRINT(2, "new file %llud.%ld ino %zd\n",
qid.path, qid.vers, m - ic->map);
b = ialloc(ic, m - ic->map);
b->inode.inuse = m->inuse = 1;

View file

@ -465,7 +465,7 @@ Raw:
fprint(2, "\n");
for(; p < end; p++){
if((p - (uchar *)buf) % 16 == 0)
fprint(2, "\n%06lx\t", p - (uchar *)buf);
fprint(2, "\n%06zx\t", p - (uchar *)buf);
if(isprint((char)*p))
fprint(2, "%c ", (char )*p);
else

View file

@ -212,7 +212,7 @@ wormunit(Device *d) /* d is l0 or r2 (e.g.) */
delay(100);
}
if(chatty)
fprint(2, "\tload r%ld drive %Z\n", v-w->side, w->drive[drive]);
fprint(2, "\tload r%zd drive %Z\n", v-w->side, w->drive[drive]);
if(mmove(w, w->mt0, v->elem, w->dt0+drive, v->rot)) {
qunlock(w);
goto sbad;
@ -398,7 +398,7 @@ loop:
goto loop;
}
if(chatty)
fprint(2, "\tunload r%ld drive %Z\n",
fprint(2, "\tunload r%zd drive %Z\n",
v-w->side, w->drive[drive]);
if(mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot)) {
qunlock(v);
@ -1319,7 +1319,7 @@ wormprobe(void)
if(v->status == Sstart && t > v->time) {
drive = v->drive;
if(chatty)
fprint(2, "\ttime r%ld drive %Z\n",
fprint(2, "\ttime r%zd drive %Z\n",
v-w->side, w->drive[drive]);
mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot);
v->status = Sunload;

View file

@ -324,7 +324,7 @@ notaccept(HConnect *c, HContent *type, HContent *enc, char *which)
hprint(hout, "Server: Plan9\r\n");
hprint(hout, "Date: %D\r\n", time(nil));
hprint(hout, "Content-Type: text/html\r\n");
hprint(hout, "Content-Length: %lud\r\n", s - c->xferbuf);
hprint(hout, "Content-Length: %zud\r\n", s - c->xferbuf);
if(c->head.closeit)
hprint(hout, "Connection: close\r\n");
else if(!http11(c))

View file

@ -851,7 +851,7 @@ netlog("***** unknown protocol\n");
return;
}
p += 2;
netlog("off = %ld ", p-s->his);
netlog("off = %zd ", p-s->his);
iph = (Iphdr*)p;
len = nhgets(iph->length);
ipcheck(p, len);

View file

@ -473,7 +473,7 @@ getframe(PPP *ppp, int *protop)
if(ppp->ctcp)
compress_error(ppp->ctcp);
ppp->in.discards++;
netlog("ppp: discard len %ld/%ld cksum %ux (%ux %ux %ux %ux)\n",
netlog("ppp: discard len %zd/%zd cksum %ux (%ux %ux %ux %ux)\n",
BLEN(b), BLEN(buf), fcs, b->rptr[0],
b->rptr[1], b->rptr[2], b->rptr[3]);
}
@ -506,7 +506,7 @@ putframe(PPP *ppp, int proto, Block *b)
b->rptr += 4;
}
netlog("ppp: putframe 0x%ux %ld\n", proto, b->wptr-b->rptr);
netlog("ppp: putframe 0x%ux %zd\n", proto, BLEN(b));
/* add in the protocol and address, we'd better have left room */
from = b->rptr;
@ -2272,7 +2272,7 @@ getpap(PPP *ppp, Block *b)
m = (Lcpmsg*)b->rptr;
len = 4;
if(BLEN(b) < 4 || BLEN(b) < (len = nhgets(m->len))){
syslog(0, LOG, "short pap message (%ld < %d)", BLEN(b), len);
syslog(0, LOG, "short pap message (%zd < %d)", BLEN(b), len);
freeb(b);
return;
}

View file

@ -155,7 +155,7 @@ p_framer(int fd, uchar *pkt, int pktlen)
/* accept if this is a good packet */
if(fcs != PPP_goodfcs)
print("bad frame %ld %2.2ux %2.2ux!\n", to-pkt, pkt[0], pkt[1]);
print("bad frame %zd %2.2ux %2.2ux!\n", to-pkt, pkt[0], pkt[1]);
else
return to-pkt;
}

View file

@ -76,7 +76,7 @@ p_seprint(Msg *m)
m->p = seprint(m->p, m->e, " totallen=%1d", NetL(h->ln));
/* these are not in the header, just print them for our convenience */
m->p = seprint(m->p, m->e, " dataln=%1ld", m->pe - m->ps);
m->p = seprint(m->p, m->e, " dataln=%1zd", m->pe - m->ps);
if ((h->flags & (FlagL|FlagS|FlagM)) == 0 && m->ps == m->pe)
m->p = seprint(m->p, m->e, " ack");

View file

@ -304,7 +304,7 @@ Bgeticon(Biobuf *b, Icon *icon)
xor += 4*ncolor;
end = xor + icon->h*4*((icon->bits*icon->w+31)/32);
if(end < buf || end > buf+icon->len){
werrstr("bad icon length %lux != %lux", end - buf, icon->len);
werrstr("bad icon length %zux != %lux", end - buf, icon->len);
return -1;
}

View file

@ -486,7 +486,7 @@ retry:
if (type == Tcname && sp->p - data == 2 && len == 0)
return rp;
if (len > sp->p - data){
dnslog("bad %s RR len (%d bytes nominal, %lud actual): %R",
dnslog("bad %s RR len (%d bytes nominal, %zud actual): %R",
rrname(type, ptype, sizeof ptype), len,
sp->p - data, rp);
rrfree(rp);

View file

@ -156,7 +156,7 @@ ctlstring(Umsc *lun)
fmtstrinit(&fmt);
fmtprint(&fmt, "dev %s\n", dev->dir);
fmtprint(&fmt, "lun %ld\n", lun - &ums->lun[0]);
fmtprint(&fmt, "lun %zd\n", lun - &ums->lun[0]);
if(lun->flags & Finqok)
fmtprint(&fmt, "inquiry %s\n", lun->inq);
if(lun->blocks > 0)

View file

@ -564,7 +564,7 @@ process(Biobuf *fd){
case TEXT: strarg(); text(argstr); pplots=0; break;
case VEC: numargs(2); vec(x[0], x[1]); break;
default:
sysfatal("%s:%d: plot: missing case %ld\n", fsp->name, fsp->lineno, pplots-plots);
sysfatal("%s:%d: plot: missing case %zd\n", fsp->name, fsp->lineno, pplots-plots);
}
}
return 1;

View file

@ -102,7 +102,7 @@ allocmsg(Conn *c, int type, int len)
void
unrecvmsg(Conn *c, Msg *m)
{
debug(DBG_PROTO, "unreceived %s len %ld\n", msgnames[m->type], m->ep - m->rp);
debug(DBG_PROTO, "unreceived %s len %zd\n", msgnames[m->type], m->ep - m->rp);
free(c->unget);
c->unget = m;
}
@ -171,7 +171,7 @@ recvmsg(Conn *c, int type)
Msg *m;
while((m = recvmsg0(c)) != nil){
debug(DBG_PROTO, "received %s len %ld\n", msgnames[m->type], m->ep - m->rp);
debug(DBG_PROTO, "received %s len %zd\n", msgnames[m->type], m->ep - m->rp);
if(m->type != SSH_MSG_DEBUG && m->type != SSH_MSG_IGNORE)
break;
if(m->type == SSH_MSG_DEBUG)

View file

@ -378,7 +378,7 @@ intable(int fd, long *table, struct convert *out)
c = table[*p];
if(c < 0){
if(squawk)
EPR "%s: bad char 0x%x near byte %ld in %s\n", argv0, *p, ninput+(p-e), file);
EPR "%s: bad char 0x%x near byte %zd in %s\n", argv0, *p, ninput+(p-e), file);
nerrors++;
if(clean)
continue;

View file

@ -1418,7 +1418,7 @@ receiver(Dev *d)
close(fd);
/* open connection through the file system interface */
sprint(file, "/net/telco/%ld/data", d - dev);
sprint(file, "/net/telco/%zd/data", d - dev);
fd = open(file, ORDWR);
if(fd < 0){
syslog(0, LOGFILE, "can't open %s: %r", file);

View file

@ -688,13 +688,13 @@ Bprintdfa(Biobuf *b, Dreprog *p)
nc = 0;
for(i=0; i<p->ninst; i++)
nc += p->inst[i].nc;
Bprint(b, "%d %d %ld %ld %ld %ld\n", p->ninst, nc,
Bprint(b, "%d %d %zd %zd %zd %zd\n", p->ninst, nc,
p->start[0]-p->inst, p->start[1]-p->inst,
p->start[2]-p->inst, p->start[3]-p->inst);
for(i=0; i<p->ninst; i++){
Bprint(b, "%d %d %d", p->inst[i].isfinal, p->inst[i].isloop, p->inst[i].nc);
for(j=0; j<p->inst[i].nc; j++)
Bprint(b, " %d %ld", p->inst[i].c[j].start, p->inst[i].c[j].next-p->inst);
Bprint(b, " %d %zd", p->inst[i].c[j].start, p->inst[i].c[j].next-p->inst);
Bprint(b, "\n");
}
}

View file

@ -117,7 +117,7 @@ main(int argc, char **argv)
n = m[2];
if(n <= 0){
fprint(2, "«%s» %.2ux", p, p[0]);
sysfatal("no regexps matched at %ld", off + (p-msg));
sysfatal("no regexps matched at %zd", off + (p-msg));
}
if(m[0] >= m[1] && m[0] >= m[2]){

View file

@ -1382,7 +1382,7 @@ mailplumb(Mailbox *mb, Message *m, int delete)
else
date = "";
sprint(lenstr, "%ld", m->end-m->start);
sprint(lenstr, "%zd", m->end-m->start);
if(biffing && !delete)
print("[ %s / %s / %s ]\n", from, subject, lenstr);

View file

@ -736,7 +736,7 @@ sortminibuffer(ISect *is, Minibuf *mb, uchar *buf, u32int nbuf, u32int bufsize)
zerorange(part, bucket2offset(is, lastb+1), bucket2offset(is, is->stop - is->start));
if(n != mb->nwentry)
fprint(2, "sortminibuffer bug: n=%ud nwentry=%ud have=%ld\n", n, mb->nwentry, (ep-buf)/IEntrySize);
fprint(2, "sortminibuffer bug: n=%ud nwentry=%ud have=%zd\n", n, mb->nwentry, (ep-buf)/IEntrySize);
free(buckdata);
}

View file

@ -1628,7 +1628,7 @@ Again:
}
if(ci >= eci || cit < ecit){
print("ran out of space editing existing directory; rewriting\n");
print("# eci %ld ci %ld ecit %ld cit %ld\n", eci-bci, ci-bci, ecit-bcit, cit-bcit);
print("# eci %zd ci %zd ecit %zd cit %zd\n", eci-bci, ci-bci, ecit-bcit, cit-bcit);
assert(smart); /* can't happen second time thru */
smart = 0;
goto Again;

View file

@ -156,7 +156,8 @@ unwhack(Unwhack *uw, uchar *dst, int ndst, uchar *src, int nsrc)
off++;
if(off > d - dst){
snprint(uw->err, WhackErrLen, "offset out of range: off=%d d=%ld len=%d nbits=%d", off, d - dst, len, uwnbits);
snprint(uw->err, WhackErrLen, "offset out of range: off=%d d=%zd len=%d nbits=%d",
off, d - dst, len, uwnbits);
return -1;
}
if(d + len > dmax){

View file

@ -84,7 +84,7 @@ static char *agent;
static Client client[64];
static int nclient;
#define CLIENTID(c) (((Client*)(c)) - client)
#define CLIENTID(c) ((int)(((Client*)(c)) - client))
Client*
newclient(void)
@ -222,7 +222,7 @@ fsmkdir(Dir *d, int level, void *aux)
d->length = strlen(((Key*)aux)->val);
break;
case Qclient:
snprint(buf, sizeof(buf), "%ld", CLIENTID(aux));
snprint(buf, sizeof(buf), "%d", CLIENTID(aux));
d->name = estrdup(buf);
break;
case Qctl:
@ -530,7 +530,7 @@ fsread(Req *r)
respond(r, nil);
return;
case Qctl:
snprint(buf, sizeof(buf), "%ld\n", CLIENTID(f->client));
snprint(buf, sizeof(buf), "%d\n", CLIENTID(f->client));
goto String;
case Qheader:
snprint(buf, sizeof(buf), "%s", f->key->val);

View file

@ -833,9 +833,9 @@ Vfmt(Fmt *f)
r = p;
e = r->ref;
if(c == 'A')
return fmtprint(f, "Arg%ld=%V", r->ptr - e->arg, *r->ptr);
return fmtprint(f, "Arg%zd=%V", r->ptr - e->arg, *r->ptr);
if(c == 'L')
return fmtprint(f, "Local%ld=%V", r->ptr - e->loc, *r->ptr);
return fmtprint(f, "Local%zd=%V", r->ptr - e->loc, *r->ptr);
case 'n':
return fmtprint(f, "%s", (char*)p);
case 's':
@ -901,7 +901,7 @@ dumpregs(void)
print("\n*** dumpregs: PC=%p FP=%p\n", PC, FP);
e = nil;
for(f = FP; f >= FB; f--){
print("%.8p.%.2lx: %-8s %N\t", f->start, f-FB, f->phase, f->dot);
print("%.8p.%.2zx: %-8s %N\t", f->start, f-FB, f->phase, f->dot);
if(f->op)
print("%s", f->op->name);
print("(");
@ -950,7 +950,7 @@ xec(uchar *pc, uchar *end, Name *dot, Env *env, void **pret)
if((++loop & 127) == 0)
gc();
if(amldebug)
print("\n%.8p.%.2lx %-8s\t%N\t", PC, FP - FB, FP->phase, FP->dot);
print("\n%.8p.%.2zx %-8s\t%N\t", PC, FP - FB, FP->phase, FP->dot);
r = nil;
c = *FP->phase++;
switch(c){

View file

@ -478,7 +478,7 @@ deflateb(LZstate *lz, LZblock *lzb, void *rr, int (*r)(void*, void*, int))
lzput(lz, lz->eof && !lz->avail, 1);
if(lz->debug){
fprint(2, "block: bytes=%lud entries=%ld extra bits=%d\n\tuncompressed=%lud fixed=%lud dynamic=%lud huffman=%lud\n",
fprint(2, "block: bytes=%lud entries=%zd extra bits=%d\n\tuncompressed=%lud fixed=%lud dynamic=%lud huffman=%lud\n",
nunc, lzb->eparse - lzb->parse, lzb->excost, (nunc + 4) * 8, nfix, ndyn, nhuff);
fprint(2, "\tnlit=%lud matches=%lud eof=%d\n", nlits, nmatches, lz->eof && !lz->avail);
}