changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: snap: consequently use ulong for page index and count

changeset 6909: d72ccdb6abdd
parent 6908: c0aa9db441a0
child 6910: 85ef38b2272f
author: cinap_lenrek@felloff.net
date: Thu, 22 Nov 2018 10:31:30 +0100
files: sys/src/cmd/snap/read.c sys/src/cmd/snap/write.c
description: snap: consequently use ulong for page index and count
     1.1--- a/sys/src/cmd/snap/read.c
     1.2+++ b/sys/src/cmd/snap/read.c
     1.3@@ -134,9 +134,9 @@ readseg(Seg **ps, Biobuf *b, Proc *plist
     1.4 {
     1.5 	Seg *s;
     1.6 	Page **pp;
     1.7-	int i, npg;
     1.8 	int t;
     1.9 	int n, len;
    1.10+	ulong i, npg;
    1.11 	ulong pid;
    1.12 	uvlong off;
    1.13 	char buf[Pagesize];
    1.14@@ -160,13 +160,13 @@ readseg(Seg **ps, Biobuf *b, Proc *plist
    1.15 	len = Pagesize;
    1.16 	for(i=0; i<npg; i++) {
    1.17 		if(i == npg-1)
    1.18-			len = s->len - i*Pagesize;
    1.19+			len = s->len - (uvlong)i*Pagesize;
    1.20 
    1.21 		switch(t = Bgetc(b)) {
    1.22 		case 'z':
    1.23 			pp[i] = datapage(zero, len);
    1.24 			if(debug)
    1.25-				fprint(2, "0x%.8llux all zeros\n", s->offset+i*Pagesize);
    1.26+				fprint(2, "0x%.8llux all zeros\n", s->offset+(uvlong)i*Pagesize);
    1.27 			break;
    1.28 		case 'm':
    1.29 		case 't':
    1.30@@ -177,14 +177,15 @@ readseg(Seg **ps, Biobuf *b, Proc *plist
    1.31 			if(pp[i] == nil)
    1.32 				panic("bad page reference in snapshot");
    1.33 			if(debug)
    1.34-				fprint(2, "0x%.8llux same as %s pid %lud 0x%.8llux\n", s->offset+i*Pagesize, t=='m'?"mem":"text", pid, off);
    1.35+				fprint(2, "0x%.8llux same as %s pid %lud 0x%.8llux\n",
    1.36+					s->offset+(uvlong)i*Pagesize, t=='m'?"mem":"text", pid, off);
    1.37 			break;
    1.38 		case 'r':
    1.39 			if((n=Bread(b, buf, len)) != len)
    1.40 				sysfatal("short read of segment %d/%d at %llx: %r", n, len, Boffset(b));
    1.41 			pp[i] = datapage(buf, len);
    1.42 			if(debug)
    1.43-				fprint(2, "0x%.8llux is raw data\n", s->offset+i*Pagesize);
    1.44+				fprint(2, "0x%.8llux is raw data\n", s->offset+(uvlong)i*Pagesize);
    1.45 			break;
    1.46 		default:
    1.47 			fprint(2, "bad type char %#.2ux\n", t);
     2.1--- a/sys/src/cmd/snap/write.c
     2.2+++ b/sys/src/cmd/snap/write.c
     2.3@@ -18,7 +18,7 @@ char *pfile[Npfile] = {
     2.4 static void
     2.5 writeseg(Biobuf *b, Proc *proc, Seg *s)
     2.6 {
     2.7-	int i, npg;
     2.8+	ulong i, npg;
     2.9 	Page **pp, *p;
    2.10 	int type;
    2.11 
    2.12@@ -50,7 +50,7 @@ writeseg(Biobuf *b, Proc *proc, Seg *s)
    2.13 				abort();
    2.14 			p->written = 1;
    2.15 			p->type = type;
    2.16-			p->offset = s->offset + i*Pagesize;
    2.17+			p->offset = s->offset + (uvlong)i*Pagesize;
    2.18 			p->pid = proc->pid;
    2.19 		}
    2.20 	}