shithub: riscv

Download patch

ref: 33636932054f74c7a922a9713a9229d6d5fc7f38
parent: 56927887249d8529afa57c38d7935edb2d9cc49f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Nov 22 05:31:30 EST 2018

snap: consequently use ulong for page index and count

--- a/sys/src/cmd/snap/read.c
+++ b/sys/src/cmd/snap/read.c
@@ -134,9 +134,9 @@
 {
 	Seg *s;
 	Page **pp;
-	int i, npg;
 	int t;
 	int n, len;
+	ulong i, npg;
 	ulong pid;
 	uvlong off;
 	char buf[Pagesize];
@@ -160,13 +160,13 @@
 	len = Pagesize;
 	for(i=0; i<npg; i++) {
 		if(i == npg-1)
-			len = s->len - i*Pagesize;
+			len = s->len - (uvlong)i*Pagesize;
 
 		switch(t = Bgetc(b)) {
 		case 'z':
 			pp[i] = datapage(zero, len);
 			if(debug)
-				fprint(2, "0x%.8llux all zeros\n", s->offset+i*Pagesize);
+				fprint(2, "0x%.8llux all zeros\n", s->offset+(uvlong)i*Pagesize);
 			break;
 		case 'm':
 		case 't':
@@ -177,7 +177,8 @@
 			if(pp[i] == nil)
 				panic("bad page reference in snapshot");
 			if(debug)
-				fprint(2, "0x%.8llux same as %s pid %lud 0x%.8llux\n", s->offset+i*Pagesize, t=='m'?"mem":"text", pid, off);
+				fprint(2, "0x%.8llux same as %s pid %lud 0x%.8llux\n",
+					s->offset+(uvlong)i*Pagesize, t=='m'?"mem":"text", pid, off);
 			break;
 		case 'r':
 			if((n=Bread(b, buf, len)) != len)
@@ -184,7 +185,7 @@
 				sysfatal("short read of segment %d/%d at %llx: %r", n, len, Boffset(b));
 			pp[i] = datapage(buf, len);
 			if(debug)
-				fprint(2, "0x%.8llux is raw data\n", s->offset+i*Pagesize);
+				fprint(2, "0x%.8llux is raw data\n", s->offset+(uvlong)i*Pagesize);
 			break;
 		default:
 			fprint(2, "bad type char %#.2ux\n", t);
--- a/sys/src/cmd/snap/write.c
+++ b/sys/src/cmd/snap/write.c
@@ -18,7 +18,7 @@
 static void
 writeseg(Biobuf *b, Proc *proc, Seg *s)
 {
-	int i, npg;
+	ulong i, npg;
 	Page **pp, *p;
 	int type;
 
@@ -50,7 +50,7 @@
 				abort();
 			p->written = 1;
 			p->type = type;
-			p->offset = s->offset + i*Pagesize;
+			p->offset = s->offset + (uvlong)i*Pagesize;
 			p->pid = proc->pid;
 		}
 	}