shithub: riscv

Download patch

ref: d52d7bc121c9c761659b6ca3556f360d341ed6c8
parent: 2de164c51dc3330859c160b80440e1363fb5b566
author: Ori Bernstein <[email protected]>
date: Sat Apr 25 06:57:17 EDT 2020

Backed out changeset 2737b9af622b

not what I wanted to commit.

--- a/sys/src/cmd/6c/txt.c
+++ b/sys/src/cmd/6c/txt.c
@@ -363,7 +363,6 @@
 			if(reg[i] == 0 && !resvreg[i])
 				goto out;
 		diag(tn, "out of float registers");
-		abort();
 		goto out;
 	}
 	diag(tn, "unknown type in regalloc: %T", tn->type);
--- a/sys/src/cmd/aux/getflags.c
+++ b/sys/src/cmd/aux/getflags.c
@@ -26,13 +26,9 @@
 char*
 argname(char *p)
 {
-	char *s;
 	Rune r;
 	int n;
 
-	s = p;
-	if(*p == ' ')
-		p++;
 	while(1){
 		n = chartorune(&r, p);
 		if(!isalpharune(r) && !isdigitrune(r))
@@ -39,8 +35,6 @@
 			break;
 		p += n;
 	}
-	if(*s == ' ')
-		return s;
 	return p;
 }
 
--- a/sys/src/cmd/cpp/macro.c
+++ b/sys/src/cmd/cpp/macro.c
@@ -350,7 +350,7 @@
 void
 substargs(Nlist *np, Tokenrow *rtr, Tokenrow **atr)
 {
-	Tokenrow ttr, rp, rn;
+	Tokenrow ttr;
 	Token *tp, *ap, *an, *pp, *pn;
 	int ntok, argno, hs;
 
@@ -369,25 +369,19 @@
 			insertrow(rtr, ntok, stringify(atr[argno]));
 		} else if (ispaste(rtr, &ap, &an, &ntok)) { /* first token, just do the next one */
 			pp = ap;
-			rp.tp = nil;
 			pn = an;
-			rn.tp = nil;
 			if (ap && (argno = lookuparg(np, ap)) >= 0){
 				pp = nil;
-				rp = *atr[argno];
-				if(rp.tp != rp.lp)
-					pp = --rp.lp;
+				if(atr[argno]->tp != atr[argno]->lp)
+					pp = atr[argno]->lp - 1;
 			}
 			if (an && (argno = lookuparg(np, an)) >= 0) {
 				pn = nil;
-				rn = *atr[argno];
-				if(rn.tp != rn.lp)
-					pn = rn.bp++;
+				if(atr[argno]->tp != atr[argno]->lp)
+					pn = atr[argno]->lp - 1;
 			}
 			glue(&ttr, pp, pn);
-			insertrow(rtr, 0, &rp);
 			insertrow(rtr, ntok, &ttr);
-			insertrow(rtr, 0, &rn);
 			free(ttr.bp);
 		} else if (rtr->tp->type==NAME) {
 			if((argno = lookuparg(np, rtr->tp)) >= 0) {
--- a/sys/src/cmd/cpp/test.c
+++ b/sys/src/cmd/cpp/test.c
@@ -21,9 +21,6 @@
 #define FOO	CAT(BAR, 3)
 FOO
 
-/* Expected: a bc d */
-CAT(a b, c d)
-
 /*
  * CURRENTLY BROKEN:
  *     __VA_ARGS__ requires at least one item.
@@ -61,4 +58,4 @@
  *     It should treat no args as a single empty arg list.
 p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
 char c[2][6] = { str(hello), str() };
-*/
+*/
\ No newline at end of file
--- a/sys/src/cmd/dossrv/dosfs.c
+++ b/sys/src/cmd/dossrv/dosfs.c
@@ -550,7 +550,7 @@
 /*
  * wipe out a dos directory entry
  */
-static int
+static void
 doremove(Xfs *xf, Dosptr *dp)
 {
 	Iosect *p;
@@ -565,8 +565,6 @@
 	}
 	if(prevdo < 0 && dp->prevaddr != -1){
 		p = getsect(xf, dp->prevaddr);
-		if(p == nil)
-			return -1;
 		for(prevdo = ((Dosbpb*)xf->ptr)->sectsize-DOSDIRSIZE; prevdo >= 0; prevdo -= DOSDIRSIZE){
 			if(p->iobuf[prevdo+11] != 0xf)
 				break;
@@ -574,8 +572,7 @@
 			p->flags |= BMOD;
 		}
 		putsect(p);
-	}
-	return 0;		
+	}		
 }
 
 void
@@ -604,7 +601,8 @@
 	 * or it's a read only file in the root directory
 	 */
 	parp = getsect(f->xf, dp->paddr);
-	if(parp == nil || getfile(f) < 0){
+	if(parp == nil
+	|| getfile(f) < 0){
 		errno = Eio;
 		goto out;
 	}
@@ -619,10 +617,7 @@
 		errno = Eio;
 		goto out;
 	}
-	if(doremove(f->xf, f->ptr) == -1){
-		errno = Eio;
-		goto out;
-	}
+	doremove(f->xf, f->ptr);
 	if(!isroot(dp->paddr)){
 		puttime(pard, 0);
 		parp->flags |= BMOD;
--- a/sys/src/cmd/dossrv/dossubs.c
+++ b/sys/src/cmd/dossrv/dossubs.c
@@ -1000,8 +1000,6 @@
 			c = count;
 		if(c == bp->sectsize){
 			p = getosect(xf, addr);
-			if(p == nil)
-				return -1;
 			p->flags = 0;
 		}else{
 			p = getsect(xf, addr);
@@ -1634,8 +1632,7 @@
 			if(rp == nil)
 				return -1;
 			wp = getosect(xf, ws);
-			if(wp == nil)
-				return -1;
+			assert(wp != nil);
 			memmove(wp->iobuf, rp->iobuf, bp->sectsize);
 			wp->flags = BMOD;
 			putsect(rp);
@@ -1705,8 +1702,6 @@
 	k = clust2sect(bp, n);
 	for(i=0; i<bp->clustsize; i++){
 		p = getosect(xf, k+i);
-		if(p == nil)
-			return -1;
 		memset(p->iobuf, 0, bp->sectsize);
 		p->flags = BMOD;
 		putsect(p);
--- a/sys/src/cmd/dossrv/iotrack.c
+++ b/sys/src/cmd/dossrv/iotrack.c
@@ -39,11 +39,8 @@
 	int toff;
 	Iosect *p;
 
-	if(addr < 0){
-		chat("invalid address\n");
-		errno = Eio;
+	if(addr < 0)
 		return nil;
-	}
 	toff = addr % Sect2trk;
 	taddr = addr - toff;
 	t = getiotrack(xf, taddr);
@@ -56,10 +53,8 @@
 	}
 	t->ref++;
 	p = t->tp->p[toff];
-	if(p == nil){
+	if(p == 0){
 		p = newsect();
-		if(p == nil)
-			return nil;
 		t->tp->p[toff] = p;
 		p->flags = t->flags&BSTALE;
 		p->lock.key = 0;
@@ -201,10 +196,10 @@
 			t->flags &= ~BSTALE;
 	}
 	if(devwrite(t->xf, t->addr, t->tp->buf, Trksize) < 0){
-		chat("error]\n");
+		chat("error]");
 		return -1;
 	}
-	chat(" done]\n");
+	chat(" done]");
 	return 0;
 }
 
@@ -309,8 +304,6 @@
 	else
 		p = malloc(sizeof(Iosect));
 	unmlock(&freelock);
-	if(p == nil)
-		return nil;
 	p->next = 0;
 	return p;
 }
--- a/sys/src/cmd/plumb/plumb.c
+++ b/sys/src/cmd/plumb/plumb.c
@@ -35,50 +35,29 @@
 	}
 }
 
-int
-matchmsg(Plumbmsg *m, Plumbmsg *pat)
-{
-	Plumbattr *a;
-	char *v;
-
-	if(pat->src && strcmp(m->src, pat->src) != 0)
-		return 0;
-	if(pat->dst && strcmp(m->dst, pat->dst) != 0)
-		return 0;
-	if(pat->wdir && strcmp(m->wdir, pat->wdir) != 0)
-		return 0;
-	if(pat->type && strcmp(m->type, pat->type) != 0)
-		return 0;
-	for(a = m->attr; a != nil; a = a->next){
-		v = plumblookup(pat->attr, a->name);
-		if(v != nil && strcmp(a->value, v) != 0)
-			return 0;
-	}
-	return 1;
-}
-
 void
 main(int argc, char *argv[])
 {
-	char buf[1024], *p, *readport;
+	char buf[1024], *p;
 	int fd, i, input;
-	Plumbmsg *rmsg;
-	Plumbattr *a;
 
 	input = 0;
-	readport = nil;
-	m.src = nil;
+	m.src = "plumb";
 	m.dst = nil;
-	m.wdir = nil;
+	m.wdir = getwd(buf, sizeof buf);
 	m.type = "text";
 	m.attr = nil;
 	ARGBEGIN{
 	case 'a':
-		p = EARGF(usage());
+		p = ARGF();
+		if(p == nil)
+			usage();
 		m.attr = plumbaddattr(m.attr, plumbunpackattr(p));
 		break;
 	case 'd':
-		m.dst = EARGF(usage());
+		m.dst = ARGF();
+		if(m.dst == nil)
+			usage();
 		break;
 	case 'i':
 		input++;
@@ -85,27 +64,30 @@
 		break;
 	case 't':
 	case 'k':	/* for backwards compatibility */
-		m.type = EARGF(usage());
+		m.type = ARGF();
+		if(m.type == nil)
+			usage();
 		break;
 	case 'p':
-		plumbfile = EARGF(usage());
+		plumbfile = ARGF();
+		if(plumbfile == nil)
+			usage();
 		break;
 	case 's':
-		m.src = EARGF(usage());
+		m.src = ARGF();
+		if(m.src == nil)
+			usage();
 		break;
 	case 'w':
-		m.wdir = EARGF(usage());
+		m.wdir = ARGF();
+		if(m.wdir == nil)
+			usage();
 		break;
-	case 'r':
-		readport = EARGF(usage());
-		break;
 	}ARGEND
 
-	if((input && argc>0) || (!input && argc<1) && readport == nil)
+	if((input && argc>0) || (!input && argc<1))
 		usage();
-	if(readport != nil)
-		fd = plumbopen(readport, OREAD);
-	else if(plumbfile != nil)
+	if(plumbfile != nil)
 		fd = open(plumbfile, OWRITE);
 	else
 		fd = plumbopen("send", OWRITE);
@@ -113,30 +95,6 @@
 		fprint(2, "plumb: can't open plumb file: %r\n");
 		exits("open");
 	}
-	if(readport != nil){
-again:
-		rmsg = plumbrecv(fd);
-		if(rmsg == nil){
-			fprint(2, "plumb: receive failed: %r\n");
-			exits("recv");
-		}
-		print("got message, matching\n");
-		if(!matchmsg(rmsg, &m))
-			goto again;
-		print("src %s\n", rmsg->src);
-		print("dst %s\n", rmsg->dst);
-		print("wdir %s\n", rmsg->wdir);
-		print("type %s\n", rmsg->type);
-		print("data %.*s\n", rmsg->ndata, rmsg->data);
-		for(a = rmsg->attr; a; a = a->next)
-			print("attr %s=%s\n", a->name, a->value);
-		plumbfree(rmsg);
-		exits(nil);
-	}
-	if(m.src == nil)
-		m.src = "plumb";
-	if(m.wdir == nil)
-		m.wdir = getwd(buf, sizeof buf);
 	if(input){
 		gather();
 		if(plumblookup(m.attr, "action") == nil)
--- a/sys/src/cmd/samterm/flayer.c
+++ b/sys/src/cmd/samterm/flayer.c
@@ -258,7 +258,7 @@
 
 	if(l->visible!=All)
 		flupfront(l);
-	dt = mousep->msec - l->click;
+	dt = l->click = mousep->msec;
 	dx = abs(mousep->xy.x - clickpt.x);
 	dy = abs(mousep->xy.y - clickpt.y);
 
@@ -279,6 +279,7 @@
 {
 	ulong fp0, fp1;
 
+	l->click = 0;
 	if(l->visible==None || !flprepare(l)){
 		l->p0 = p0, l->p1 = p1;
 		return;