ref: f597758079cff5504bf21fad75e4c40ecc0a90a0
parent: 58e4e95cee26798a051f02fa7987f6b85dd11403
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Jan 8 09:04:02 EST 2021
fix warnings when building for 32-bit platforms
--- a/ebml.c
+++ b/ebml.c
@@ -337,7 +337,7 @@
return -1;
}
if(n == 1 && c == 0){
- werrstr("invalid number: %02x at %#zx", c, Boffset(f));
+ werrstr("invalid number: %02x at %#llux", c, Boffset(f));
return -1;
}
v |= c;
@@ -423,8 +423,9 @@
return 0;
Bungetc(f);
- n = 0;
- if((n += (r = ebmlid(f, sz, &x))) >= sz || r < 0){
+ r = ebmlid(f, sz, &x);
+ n = r;
+ if(r >= sz || r < 0){
werrstr("id: %r");
return -1;
}
@@ -433,8 +434,10 @@
else
memset(el, 0, sizeof(*el));
el->id = x;
- if((n += (r = ebmluint(f, sz-n, &x))) >= sz || r < 0 || sz-n < x){
- werrstr("sz: (sz=%zd n=%zd r=%zd x=%zd): %r", sz, n, r, x);
+ r = ebmluint(f, sz-n, &x);
+ n += r;
+ if(n >= sz || r < 0 || sz-n < x){
+ werrstr("sz: (sz=%lld n=%lld r=%lld x=%lld): %r", sz, n, r, x);
return -1;
}
*esz = x;
--- a/iso.c
+++ b/iso.c
@@ -346,9 +346,9 @@
Bprint(&stderr, "\t%.*sflags\t0x%ux\n", dind, ind, b->flags);
}
if(dflag > 1){
- Bprint(&stderr, "\t%.*soffset\t%zd\n", dind, ind, b->offset);
- Bprint(&stderr, "\t%.*sdstart\t%zd\n", dind, ind, b->dstart);
- Bprint(&stderr, "\t%.*sdsize\t%zd\n", dind, ind, b->dsz);
+ Bprint(&stderr, "\t%.*soffset\t%lld\n", dind, ind, b->offset);
+ Bprint(&stderr, "\t%.*sdstart\t%lld\n", dind, ind, b->dstart);
+ Bprint(&stderr, "\t%.*sdsize\t%lld\n", dind, ind, b->dsz);
}
if(b->type == BoxFtyp){
@@ -359,15 +359,15 @@
Bprint(&stderr, "\t%.*s%T", dind, ind, b->ftyp.compat[i]);
Bprint(&stderr, "\n");
}else if(b->type == BoxMdhd){
- Bprint(&stderr, "\t%.*screation\t%zd\n", dind, ind, b->mdhd.creation);
- Bprint(&stderr, "\t%.*smodification\t%zd\n", dind, ind, b->mdhd.modification);
+ Bprint(&stderr, "\t%.*screation\t%llud\n", dind, ind, b->mdhd.creation);
+ Bprint(&stderr, "\t%.*smodification\t%llud\n", dind, ind, b->mdhd.modification);
Bprint(&stderr, "\t%.*stimescale\t%ud\n", dind, ind, b->mdhd.timescale);
- Bprint(&stderr, "\t%.*sduration\t%zd\n", dind, ind, b->mdhd.duration);
+ Bprint(&stderr, "\t%.*sduration\t%llud\n", dind, ind, b->mdhd.duration);
}else if(b->type == BoxMvhd){
- Bprint(&stderr, "\t%.*screation\t%zd\n", dind, ind, b->mvhd.creation);
- Bprint(&stderr, "\t%.*smodification\t%zd\n", dind, ind, b->mvhd.modification);
+ Bprint(&stderr, "\t%.*screation\t%llud\n", dind, ind, b->mvhd.creation);
+ Bprint(&stderr, "\t%.*smodification\t%llud\n", dind, ind, b->mvhd.modification);
Bprint(&stderr, "\t%.*stimescale\t%ud\n", dind, ind, b->mvhd.timescale);
- Bprint(&stderr, "\t%.*sduration\t%zd\n", dind, ind, b->mvhd.duration);
+ Bprint(&stderr, "\t%.*sduration\t%llud\n", dind, ind, b->mvhd.duration);
Bprint(&stderr, "\t%.*srate\t0x%ux\n", dind, ind, b->mvhd.rate);
Bprint(&stderr, "\t%.*svolume\t0x%ux\n", dind, ind, b->mvhd.volume);
Bprint(&stderr, "\t%.*snexttrack\t0x%ux\n", dind, ind, b->mvhd.nexttrack);
@@ -394,7 +394,7 @@
}else if(b->type == BoxTfhd){
Bprint(&stderr, "\t%.*strackid\t%d\n", dind, ind, b->tfhd.trackid);
if(b->flags & 1)
- Bprint(&stderr, "\t%.*sbaseoffset\t%zd\n", dind, ind, b->tfhd.baseoffset);
+ Bprint(&stderr, "\t%.*sbaseoffset\t%llud\n", dind, ind, b->tfhd.baseoffset);
Bprint(&stderr, "\t%.*sdefsample\n", dind, ind);
if(b->flags & 2)
Bprint(&stderr, "\t\t%.*sdescrindex\t0x%ux\n", dind, ind, b->tfhd.defsample.descrindex);
@@ -409,7 +409,7 @@
if(b->flags & 0x20000)
Bprint(&stderr, "\t%.*sdefault base is moof\n", dind, ind);
}else if(b->type == BoxTfdt){
- Bprint(&stderr, "\t%.*sdecodetime\t%zd\n", dind, ind, b->tfdt.decodetime);
+ Bprint(&stderr, "\t%.*sdecodetime\t%llud\n", dind, ind, b->tfdt.decodetime);
}else if(b->type == BoxTrun){
Bprint(&stderr, "\t%.*ssamplecount\t%ud\n", dind, ind, b->trun.samplecount);
if(b->flags & 1)
@@ -417,18 +417,18 @@
if(b->flags & 2)
Bprint(&stderr, "\t%.*sfirstsampleflags\t0x%ux\n", dind, ind, b->trun.firstsampleflags);
for(u = 0; dflag > 1 && u < b->trun.samplecount; u++){
- Bprint(&stderr, "\t%.*ssamples[%zd]\n", dind, ind, u);
+ Bprint(&stderr, "\t%.*ssamples[%llud]\n", dind, ind, u);
Bprint(&stderr, "\t\t%.*sduration\t%ud\n", dind, ind, b->trun.samples[u].duration);
Bprint(&stderr, "\t\t%.*ssize\t%ud\n", dind, ind, b->trun.samples[u].size);
Bprint(&stderr, "\t\t%.*sflags\t0x%ux\n", dind, ind, b->trun.samples[u].flags);
if(b->flags & 0x800)
- Bprint(&stderr, "\t\t%.*stimeoffset\t%zd\n", dind, ind, b->trun.samples[u].timeoffset);
+ Bprint(&stderr, "\t\t%.*stimeoffset\t%lld\n", dind, ind, b->trun.samples[u].timeoffset);
}
}else if(b->type == BoxStsd){
Bprint(&stderr, "\t%.*sid\t%d\n", dind, ind, b->stsd.id);
Bprint(&stderr, "\t%.*sentry_count\t%ud\n", dind, ind, b->stsd.entrycount);
for(u = 0; u < b->stsd.entrycount; u++){
- Bprint(&stderr, "\t%.*sentry[%zd]\n", dind, ind, u);
+ Bprint(&stderr, "\t%.*sentry[%llud]\n", dind, ind, u);
Bprint(&stderr, "\t\t%.*sdatarefid\t%d\n", dind, ind, b->stsd.entry[u].datarefid);
Bprint(&stderr, "\t\t%.*sformat\t%T\n", dind, ind, b->stsd.entry[u].format);
if(b->stsd.entry[u].video.format != 0){
@@ -466,7 +466,7 @@
}else if(b->type == BoxStts){
Bprint(&stderr, "\t%.*sentry_count\t%ud\n", dind, ind, b->stts.entrycount);
for(u = 0; dflag > 1 && u < b->stts.entrycount; u++){
- Bprint(&stderr, "\t%.*sentry[%zd]\n", dind, ind, u);
+ Bprint(&stderr, "\t%.*sentry[%llud]\n", dind, ind, u);
Bprint(&stderr, "\t\t%.*ssample_count\t%ud\n", dind, ind, b->stts.entry[u].samplecount);
Bprint(&stderr, "\t\t%.*ssamples_delta\t%ud\n", dind, ind, b->stts.entry[u].sampledelta);
}
@@ -475,7 +475,7 @@
}else if(b->type == BoxStsc){
Bprint(&stderr, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
for(u = 0; dflag > 1 && u < b->stsc.entrycount; u++){
- Bprint(&stderr, "\t%.*sentry[%zd]\n", dind, ind, u);
+ Bprint(&stderr, "\t%.*sentry[%llud]\n", dind, ind, u);
Bprint(&stderr, "\t\t%.*sfirst_chunk\t%ud\n", dind, ind, b->stsc.entry[u].firstchunk);
Bprint(&stderr, "\t\t%.*ssamples_per_chunk\t%ud\n", dind, ind, b->stsc.entry[u].samplesperchunk);
Bprint(&stderr, "\t\t%.*ssample_description_table\t%ud\n", dind, ind, b->stsc.entry[u].sdt);
@@ -485,13 +485,13 @@
Bprint(&stderr, "\t%.*ssample_count\t%ud\n", dind, ind, b->stsz.samplecount);
if(dflag > 1 && b->stsz.samplesizeeach == 0){
for(u = 0; u < b->stsz.samplecount; u++)
- Bprint(&stderr, "\t%.*ssamplesize[%zd]\t%ud\n", dind, ind, u, b->stsz.samplesize[u]);
+ Bprint(&stderr, "\t%.*ssamplesize[%llud]\t%ud\n", dind, ind, u, b->stsz.samplesize[u]);
}
}else if(b->type == BoxTkhd){
- Bprint(&stderr, "\t%.*screation_time\t%zd\n", dind, ind, b->tkhd.creattime);
- Bprint(&stderr, "\t%.*smodification_time\t%zd\n", dind, ind, b->tkhd.modtime);
+ Bprint(&stderr, "\t%.*screation_time\t%llud\n", dind, ind, b->tkhd.creattime);
+ Bprint(&stderr, "\t%.*smodification_time\t%llud\n", dind, ind, b->tkhd.modtime);
Bprint(&stderr, "\t%.*strack_id\t%ud\n", dind, ind, b->tkhd.trackid);
- Bprint(&stderr, "\t%.*sduration\t%zd\n", dind, ind, b->tkhd.duration);
+ Bprint(&stderr, "\t%.*sduration\t%llud\n", dind, ind, b->tkhd.duration);
Bprint(&stderr, "\t%.*swidth\t%ud\n", dind, ind, b->tkhd.width);
Bprint(&stderr, "\t%.*sheight\t%ud\n", dind, ind, b->tkhd.height);
}else if(b->type == BoxHdlr){
@@ -500,7 +500,7 @@
}else if(b->type == BoxStco || b->type == BoxCo64){
Bprint(&stderr, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
for(u = 0; dflag > 1 && u < b->stco_co64.entrycount; u++)
- Bprint(&stderr, "\t%.*schunkoffset[%zd]\t%zd\n", dind, ind, u, b->stco_co64.chunkoffset[u]);
+ Bprint(&stderr, "\t%.*schunkoffset[%llud]\t%llud\n", dind, ind, u, b->stco_co64.chunkoffset[u]);
}
}
@@ -685,7 +685,7 @@
raw[5] = (sz&7)<<5 | 0x1f; /* frame length, fullness */
raw[6] = 0xfc; /* fullness, number of frames */
if(Bseek(f, s->offset, 0) != s->offset){
- werrstr("couldn't seek to offset %zd", s->offset);
+ werrstr("couldn't seek to offset %lld", s->offset);
return -1;
}
if(Bread(f, raw+7, s->size) != s->size){
@@ -708,7 +708,7 @@
raw[10] = ts >> 48;
raw[11] = ts >> 56;
if(Bseek(f, s->offset, 0) != s->offset){
- werrstr("couldn't seek to offset %zd", s->offset);
+ werrstr("couldn't seek to offset %lld", s->offset);
return -1;
}
if(Bread(f, raw+12, s->size) != s->size){
@@ -1438,12 +1438,14 @@
static int
parsebox(Biobuf *f, Box *b, int *eof)
{
- vlong sz, start;
+ vlong start;
u8int d[8];
int r;
*eof = 0;
- b->dstart = b->offset = start = Boffset(f);
+ start = Boffset(f);
+ b->offset = start;
+ b->dstart = start;
if((r = Bread(f, d, 8)) != 8){
if(r == 0)
*eof = 1;
@@ -1452,10 +1454,10 @@
goto err;
}
b->dstart += 8;
- b->dsz = sz = d[0]<<24 | d[1]<<16 | d[2]<<8 | d[3];
+ b->dsz = d[0]<<24 | d[1]<<16 | d[2]<<8 | d[3];
b->type = d[4]<<24 | d[5]<<16 | d[6]<<8 | d[7];
- if(sz == 1){
+ if(b->dsz == 1){
if(Bread(f, d, 8) != 8){
werrstr("largesize");
goto err;
@@ -1462,7 +1464,7 @@
}
b->dstart += 8;
b->dsz = (vlong)d[0]<<56 | (vlong)d[1]<<48 | (vlong)d[2]<<40 | (vlong)d[3]<<32 | d[4]<<24 | d[5]<<16 | d[6]<<8 | d[7];
- }else if(sz == 0){
+ }else if(b->dsz == 0){
b->dsz = (vlong)1<<63 - 1;
}
--- a/matroska.c
+++ b/matroska.c
@@ -214,8 +214,9 @@
}
off = Boffset(f);
- if((n = ebmlel(f, left, &el, &sz)) < 0){
- werrstr("invalid ebml: %r at %#zx (size %zd)", off, sz);
+ n = ebmlel(f, left, &el, &sz);
+ if(n < 0){
+ werrstr("invalid ebml: %r at %#llx (size %lld)", off, sz);
goto err;
}
if(n == 0) /* eof */
@@ -265,7 +266,8 @@
}else if((el.id == ESimpleBlock || el.id == EBlock) && !skipdata){
if(te.tracknum == -1)
memmove(&te, &e, sizeof(e));
- if((n = ebmluint(f, sz, &track)) < 0){
+ n = ebmluint(f, sz, &track);
+ if(n < 0){
werrstr("block: %r");
goto err;
}
@@ -333,11 +335,12 @@
packetsz = 0;
off = 4;
for(i = 0; i < npackets-1; i++){
- if((n = (i == 0 ? ebmluintb : ebmlsintb)(buf+off, sz, &x)) < 0)
+ n = (i == 0 ? ebmluintb : ebmlsintb)(buf+off, sz, &x);
+ if(n < 0)
goto err;
packetsz += x;
if(packetsz < 0){
- werrstr("invalid frame size %zd", packetsz);
+ werrstr("invalid frame size %lld", packetsz);
goto err;
}
packets[i].sz = packetsz;
@@ -346,7 +349,7 @@
}
for(i = 0; i < npackets-1; i++){
if(packets[i].sz > sz){
- werrstr("frame %d/%d out of bounds: %d > %zd", i, npackets-1, packets[i].sz, sz);
+ werrstr("frame %d/%d out of bounds: %d > %lld", i, npackets-1, packets[i].sz, sz);
goto err;
}
packets[i].data = buf+off;
--- a/srt.c
+++ b/srt.c
@@ -20,12 +20,12 @@
sec = nsec / 1000000000ULL;
msec = nsec/1000000ULL - sec*1000ULL;
if(sec >= 3600){
- s = seprint(s, e, "%02zd:", sec/3600);
+ s = seprint(s, e, "%02llud:", sec/3600);
sec %= 3600;
}
- s = seprint(s, e, "%02zd:", sec/60);
+ s = seprint(s, e, "%02llud:", sec/60);
sec %= 60;
- seprint(s, e, "%02zd,%03zd", sec, msec);
+ seprint(s, e, "%02llud,%03llud", sec, msec);
return fmtstrcpy(f, tmp);
}
@@ -55,7 +55,7 @@
}
if(*o == '\n' && o != p->data)
o--;
- Bprint(out, "%zd\n%P --> %P\n", ++ctx->frid, ts, ts+ctx->blockdur);
+ Bprint(out, "%llud\n%P --> %P\n", ++ctx->frid, ts, ts+ctx->blockdur);
Bwrite(out, p->data, o - p->data);
Bwrite(out, "\n\n", 2);
}