shithub: drawcpu

Download patch

ref: cc7216394dd7f921e6856a9ce7fa0344816a222e
parent: 215ef6c03d4d69a4455e9729c463d6d8bc145848
author: halfwit <michaelmisch1985@gmail.com>
date: Fri Jan 2 23:06:58 EST 2026

Silence some build warnings

--- a/kern/chan.c
+++ b/kern/chan.c
@@ -414,7 +414,10 @@
 void
 cclose(Chan *c)
 {
-	if(c == nil || c->ref.ref < 1 || c->flag&CFREE)
+	if(c == nil)
+		return;
+
+	if(c->ref.ref < 1 || c->flag&CFREE)
 		panic("cclose %#p", getcallerpc(&c));
 
 	if(decref(&c->ref))
--- a/kern/devdup.c
+++ b/kern/devdup.c
@@ -7,7 +7,7 @@
 /* Qid is (2*fd + (file is ctl))+1 */
 
 static int
-dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
+dupgen(Chan *c, char *uc, Dirtab *ud, int ui, int s, Dir *dp)
 {
 	Fgrp *fgrp;
 	Chan *f;
@@ -14,6 +14,7 @@
 	static int perm[] = { 0400, 0200, 0600, 0 };
 	int p;
 	Qid q;
+	USED(uc); USED(ud); USED(ui);
 
 	fgrp = up->fgrp;
 	if(s == DEVDOTDOT){
@@ -92,8 +93,9 @@
 }
 
 static void
-dupclose(Chan*)
+dupclose(Chan* c)
 {
+	USED(c);
 }
 
 static long
@@ -114,12 +116,15 @@
 		return readstr((ulong)offset, va, n, buf);
 	}
 	panic("dupread");
+	return 0; /* Not reachable */
 }
 
 static long
-dupwrite(Chan*, void*, long, vlong)
+dupwrite(Chan *c, void *v, long l, vlong t)
 {
+	USED(c); USED(v); USED(l); USED(t);
 	error(Eperm);
+	return 0;
 }
 
 Dev dupdevtab = {
--- a/kern/devproc.c
+++ b/kern/devproc.c
@@ -178,22 +178,22 @@
 		error(Eprocdied);
 
 	incref(&f->ref);
-	lock(&f->lk);
+	lock(&f->lk.lk);
 	while(fd <= f->maxfd){
 		c = f->fd[fd];
 		if(c != nil){
 			f->fd[fd] = nil;
-			unlock(&f->lk);
+			unlock(&f->lk.lk);
 			qunlock(&p->debug);
 			cclose(c);
 			qlock(&p->debug);
-			lock(&f->lk);
+			lock(&f->lk.lk);
 		}
 		if(!all)
 			break;
 		fd++;
 	}
-	unlock(&f->lk);
+	unlock(&f->lk.lk);
 	closefgrp(f);
 }
 
@@ -898,7 +898,7 @@
 		kstrdup(&p->user, d->uid);
 	}
 	/* p->procmode determines default mode for files in /proc */
-	if(d->mode != ~0UL)
+	if(d->mode != ~0)
 		p->procmode = d->mode&0777;
 
 	qunlock(&p->debug);
--- a/kern/devsrv.c
+++ b/kern/devsrv.c
@@ -60,11 +60,11 @@
 {
 	Link *lp;
 
-	if(qidpath != ~0UL){
+	if(qidpath != ~0){
 		qidpath = SRVPATH(qidpath);
 	}
 	for(lp = l; lp != nil; lp = lp->link){
-		if(qidpath != ~0UL && lp->path == qidpath)
+		if(qidpath != ~0 && lp->path == qidpath)
 			return lp;
 		if(name != nil && strcmp(lp->name, name) == 0)
 			return lp;
@@ -78,17 +78,17 @@
 	Link *lp;
 	Link **last;
 
-	if(qidpath != ~0UL){
+	if(qidpath != ~0){
 		assert(SRVTYPE(qidpath) == Qsrv);
 		qidpath = SRVPATH(qidpath);
 	}
 	last = l;
 	for(lp = *l; lp != nil; lp = lp->link){
-		if(qidpath != ~0UL && lp->path == qidpath)
+		if(qidpath != ~0 && lp->path == qidpath)
 			break;
 		if(name != nil && strcmp(lp->name, name) == 0)
 			break;
-		last = &lp->link;
+		last = (Link**)&lp->link;
 	}
 	if(lp == nil)
 		return nil;
@@ -116,7 +116,7 @@
 	if(b == &srvroot)
 		return;
 
-	if(decref(b))
+	if(decref(&b->rf))
 		return;
 
 	/*
@@ -130,7 +130,7 @@
 		assert(b->parent != nil);
 
 		/* unlink from parent board */
-		ch = bremove((Link**)&b->parent->child, b->ln.name, ~0UL);
+		ch = bremove((Link**)&b->parent->child, b->ln.name, ~0);
 		assert(ch == b);
 
 		/* unlink from all boards list */
@@ -138,16 +138,18 @@
 		ch->next->prev = ch->prev;
 
 		b = ch->parent;
-		freelink(ch);
+		freelink(&ch->ln);
 	}
 }
 
 static int
-srvgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
+srvgen(Chan *c, char *name, Dirtab* dt, int t, int s, Dir *dp)
 {
 	Srv *sp;
 	Board *b, *ch;
 	Qid q;
+	USED(t);
+	USED(dt);
 
 	if(name != nil && strlen(name) >= sizeof(up->genbuf))
 		return -1;
@@ -174,9 +176,9 @@
 		if(strcmp(name, clone) == 0)
 			goto Clone;
 
-		sp = lookup(b->srv, name, ~0UL);
+		sp = lookup(&b->srv->ln, name, ~0);
 		if(sp == nil)
-			ch = lookup(b->child, name, ~0UL);
+			ch = lookup(&b->child->ln, name, ~0);
 	} else {
 		if(s == 0)
 			goto Clone;
@@ -250,7 +252,7 @@
 	if(b == &srvroot)
 		return wq;
 
-	incref(b);
+	incref(&b->rf);
 	return wq;
 }
 
@@ -301,7 +303,7 @@
 		do {
 			ch->ln.path = srvpath++;
 			snprint(buf, sizeof buf, "%ld", ch->ln.path);
-		} while(lookup(b->srv, buf, ~0UL) != nil);
+		} while(lookup(&b->srv->ln, buf, ~0) != nil);
 		kstrdup(&ch->ln.name, buf);
 		kstrdup(&ch->ln.owner, up->user);
 
@@ -344,7 +346,7 @@
 	if(b->closed)
 		error(Eshutdown);
 
-	sp = lookup(b->srv, nil, c->qid.path);
+	sp = lookup(&b->srv->ln, nil, c->qid.path);
 	if(sp == nil)
 		error(Eshutdown);
 	nc = sp->chan;
@@ -354,7 +356,7 @@
 		error(Eperm);
 	devpermcheck(sp->ln.owner, sp->ln.perm, omode);
 
-	incref(nc);
+	incref(&nc->ref);
 
 	runlock(&srvlk);
 	poperror();
@@ -386,15 +388,15 @@
 	wlock(&srvlk);
 	if(waserror()){
 		wunlock(&srvlk);
-		freelink(sp);
+		freelink(&sp->ln);
 		nexterror();
 	}
 	if(b->closed)
 		error(Eshutdown);
 	devpermcheck(b->ln.owner, b->ln.perm, OWRITE);
-	if(lookup(b->srv, name, ~0UL) != nil)
+	if(lookup(&b->srv->ln, name, ~0) != nil)
 		error(Eexist);
-	if(lookup(b->child, name, ~0UL) != nil)
+	if(lookup(&b->child->ln, name, ~0) != nil)
 		error(Eexist);
 
 	sp->ln.perm = perm&0777;
@@ -436,7 +438,7 @@
 		error(Eperm);
 	}
 
-	sp = lookup(b->srv, nil, c->qid.path);
+	sp = lookup(&b->srv->ln, nil, c->qid.path);
 	if(sp == nil)
 		error(Enonexist);
 
@@ -451,7 +453,7 @@
 
 	if(sp->chan != nil)
 		cclose(sp->chan);
-	freelink(sp);
+	freelink(&sp->ln);
 }
 
 static int
@@ -489,9 +491,9 @@
 		error(Eshutdown);
 
 	if(c->qid.type == QTDIR)
-		lp = b;
+		lp = &b->ln;
 	else
-		lp = lookup(b->srv, nil, c->qid.path);
+		lp = lookup(&b->srv->ln, nil, c->qid.path);
 	if(lp == nil)
 		error(Enonexist);
 
@@ -511,15 +513,15 @@
 			s = b->parent;
 		else
 			s = b;
-		if(lookup(s->srv, d.name, ~0UL) != nil)
+		if(lookup(&s->srv->ln, d.name, ~0) != nil)
 			error(Eexist);
-		if(lookup(s->child, d.name, ~0UL) != nil)
+		if(lookup(&s->child->ln, d.name, ~0) != nil)
 			error(Eexist);
 		kstrdup(&lp->name, d.name);
 	}
 	if(d.uid != nil && *d.uid)
 		kstrdup(&lp->owner, d.uid);
-	if(d.mode != ~0UL)
+	if(d.mode != ~0)
 		lp->perm = d.mode & 0777;
 
 	wunlock(&srvlk);
@@ -572,7 +574,7 @@
 		link = sp->ln.link;
 		if(sp->chan != nil)
 			cclose(sp->chan);
-		freelink(sp);
+		freelink(&sp->ln);
 	}
 }
 
@@ -598,7 +600,7 @@
 }
 
 static long
-srvwrite(Chan *c, void *va, long n, vlong)
+srvwrite(Chan *c, void *va, long n, vlong t)
 {
 	Board *b;
 	Srv *sp;
@@ -605,6 +607,7 @@
 	Chan *c1;
 	int fd;
 	char buf[32];
+	USED(t);
 
 	if(SRVTYPE(c->qid.path) == Qlease)
 		error(Eperm);
@@ -628,7 +631,7 @@
 		error(Eshutdown);
 	if(c1->qid.type & QTAUTH)
 		error("cannot post auth file in srv");
-	sp = lookup(b->srv, nil, c->qid.path);
+	sp = lookup(&b->srv->ln, nil, c->qid.path);
 	if(sp == nil)
 		error(Enonexist);
 
--- a/kern/syscall.c
+++ b/kern/syscall.c
@@ -136,7 +136,7 @@
 	size = arg(2);
 	off = argv(3);
 	if(debug)
-		print("syspread: size=0x%lux off=0x%lux\n", size, off);
+		print("syspread: fd=%d size=0x%lux off=0x%lux\n", fd, size, off);
 	targ = bufifnec(buf, size, &buffered);
 	up->R[0] = noteerr(pread(fd, targ, size, off), size);
 	if(buffered)
@@ -272,8 +272,7 @@
 	edir = arg(1);
 	nedir = arg(2);
 	edirt = copyifnec(edir, nedir, &copied);
-	if(debug)
-		print("sysfwstat: %d, %#ux, %d\n",fd, edir, nedir);
+		print("sysfwstat: fd=%d edir=%s nedir=%d copied=%d\n", fd, edirt, nedir, copied);
 	up->R[0] = noteerr(fwstat(fd, edirt, nedir), nedir);
 	if(copied)
 		free(edirt);
@@ -342,6 +341,8 @@
 	utfecpy(srct, srct + len, buf);
 	if(copied)
 		copyback(src, len, srct);
+	if(debug)
+		print("syserrstr buf=%s\n", buf);
 	up->R[0] = 0;
 }
 
@@ -393,7 +394,7 @@
 
 	flags = arg(0);
 	if(debug)
-		print("rfork(%#o) for proc pid=%lud\n", flags, up->pid);
+		print("sysrfork(%#o) for proc pid=%lud\n", flags, up->pid);
 	up->R[0] = noteerr(rfork(flags), 0);
 }
 
@@ -411,7 +412,7 @@
 	segunlock(seg1);
 	argvt = vaddr(argv, 0, &seg1);
 	if(debug)
-		fprint(2, "exec(%#ux=\"%s\", %#ux)\n", name, namet, argv);
+		fprint(2, "sysexec(%#ux=\"%s\", %#ux)\n", name, namet, argv);
 	for(argc = 0; argvt[argc]; argc++)
 		;
 	argvv = emalloc(sizeof(char *) * argc);
@@ -607,6 +608,8 @@
 		cclose(c);
 		nexterror();
 	}
+	if(debug)
+		print("sysfauth\n");
 	ac = mntauth(c, aname);
 	/* at this point ac is responsible for keeping c alive */
 	poperror();	/* c */
--