From 5ccc06de8abb19b9c698ab5eeab7d0cc58ecc636 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 14 Dec 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-12-14 --- gnot/devincon.c | 11 ++++++----- gnot/fault68020.c | 11 ++--------- gnot/fns.h | 2 ++ port/devdk.c | 27 +++++++++++++-------------- port/devmnt.c | 6 ++++++ port/devnonet.c | 7 ++----- port/page.c | 2 +- port/stnoether.c | 2 +- port/stream.c | 10 ++++------ port/sturp.c | 1 + power/clock.c | 4 ++++ power/devhs.c | 5 +++-- power/devrtc.c | 1 + power/fns.h | 3 +++ power/lock.c | 14 ++++++++------ power/main.c | 1 + power/trap.c | 3 +++ 17 files changed, 61 insertions(+), 49 deletions(-) diff --git a/gnot/devincon.c b/gnot/devincon.c index 19e8f558e555faac43af27346f6f1e5a2b86a658..035cbd7059c1705d195dff793672d2a651472b5a 100644 --- a/gnot/devincon.c +++ b/gnot/devincon.c @@ -14,8 +14,7 @@ typedef struct Device Device; #define NOW (MACHP(0)->ticks*MS2HZ) -static int SpEcIaL; -#define MICROSECOND SpEcIaL = 0 +#define MICROSECOND USED(NOW) #define DPRINT if(0) @@ -643,7 +642,7 @@ inconkproc(void *arg) { Incon *ip; Block *bp, *nbp; - int i, n; + int i; int locked; ip = (Incon *)arg; @@ -675,12 +674,14 @@ inconkproc(void *arg) /* * die if the device is closed */ - locked = 1; + USED(locked); qlock(ip); + locked = 1; if(ip->rq == 0){ qunlock(ip); ip->kstarted = 0; wakeup(&ip->r); + poperror(); return; } @@ -690,12 +691,12 @@ inconkproc(void *arg) */ while(ip->ri != ip->wi){ bp = ip->inb[ip->ri]; - n = BLEN(bp); PUTNEXT(ip->rq, bp); bp = ip->inb[ip->ri] = allocb(Bsize); bp->wptr += 3; ip->ri = (ip->ri+1)%Nin; } + USED(locked); qunlock(ip); locked = 0; } diff --git a/gnot/fault68020.c b/gnot/fault68020.c index 70f6d8c3a4832818502eaca811c0bb37afc07f52..c7c2dcbc0e7d677e9a2f84fe8b025f0a8c8543d5 100644 --- a/gnot/fault68020.c +++ b/gnot/fault68020.c @@ -45,15 +45,8 @@ struct FFrame void fault68020(Ureg *ur, FFrame *f) { - ulong addr, mmuvirt, mmuphys, n, badvaddr; - Seg *s; - PTE *opte, *pte, *npte; - Orig *o; - char *l; - Page *pg; - KMap *k, *k1; - int zeroed = 0, head = 1; - int i, user, read, insyscall; + ulong addr, badvaddr; + int user, read, insyscall; if(u == 0){ dumpregs(ur); diff --git a/gnot/fns.h b/gnot/fns.h index b310c0ed23bd2d8d6d21de7f55ba6efc461ef2ee..1a484e771fd7d2a3eb5afd19ab831e30b3e79c62 100644 --- a/gnot/fns.h +++ b/gnot/fns.h @@ -199,3 +199,5 @@ Chan *walk(Chan*, char*, int); #define poperror() u->nerrlab-- #define evenaddr(x) /* 68020 doesn't care */ + +#define USED(x) if(x) diff --git a/port/devdk.c b/port/devdk.c index 872c534862bfd0fc4ca9a9a923da91ecdcd92ccb..32eb3c3f145eea63f441c54e1a40e48f34bc55f6 100644 --- a/port/devdk.c +++ b/port/devdk.c @@ -1075,25 +1075,20 @@ dkcall(int type, Chan *c, char *addr, char *nuser, char *machine) strcat(dialstr, machine); strcat(dialstr, "\n"); break; + default: + t_val = 0; + d_val = 0; + panic("bad dial type"); } /* - * close temporary channels on error + * open the data file */ - dc = 0; - csc = 0; + dc = dkopenline(dp, line); if(waserror()){ - if(csc) - close(csc); - if(dc) - close(dc); + close(dc); nexterror(); } - - /* - * open the data file - */ - dc = dkopenline(dp, line); lp->calltolive = 4; lp->state = Ldialing; @@ -1102,9 +1097,13 @@ dkcall(int type, Chan *c, char *addr, char *nuser, char *machine) */ DPRINT("dialout\n"); csc = dkopenline(dp, dp->ncsc); + if(waserror()){ + close(csc); + nexterror(); + } dkmesg(csc, t_val, d_val, line, W_WINDOW(dp->urpwindow,dp->urpwindow,2)); + poperror(); close(csc); - csc = 0; /* * if redial, wait for a dial tone (otherwise we might send @@ -1639,6 +1638,7 @@ dktimer(void *a) Line *lp; Chan *c; + dp = (Dk *)a; c = 0; if(waserror()){ /* @@ -1664,7 +1664,6 @@ dktimer(void *a) /* * open csc */ - dp = (Dk *)a; c = dkopenline(dp, dp->ncsc); for(;;){ diff --git a/port/devmnt.c b/port/devmnt.c index d026eaf296f0badd4b3c59cdc1f26c3d8c13d3ae..a8ba8ad060e1033bbbc3f2de167f6cbb354ed6f0 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -768,6 +768,7 @@ mntxmit(Mnt *m, Mnthdr *mh) if(q->reader == 0){ /* i will read */ q->reader = u->p; Read: + USED(qlocked); qunlock(q); qlocked = 0; if(waserror()){ /* 3 */ @@ -785,6 +786,7 @@ mntxmit(Mnt *m, Mnthdr *mh) /* * Response might not be mine */ + USED(qlocked); qlock(q); qlocked = 1; tag = mh->rhdr.tag; @@ -797,6 +799,7 @@ mntxmit(Mnt *m, Mnthdr *mh) wakeup(&w->r); } mh->active = 0; + USED(qlocked); qunlock(q); qlocked = 0; goto Respond; @@ -834,11 +837,13 @@ mntxmit(Mnt *m, Mnthdr *mh) } sleep(&mh->r, mntreadreply, mh); poperror(); + USED(qlocked); qlock(q); qlocked = 1; if(q->reader == u->p) /* i got promoted */ goto Read; mh->active = 0; + USED(qlocked); qunlock(q); qlocked = 0; goto Respond; @@ -865,6 +870,7 @@ mntxmit(Mnt *m, Mnthdr *mh) } mbfree(mh->mbr); mbfree(mbw); + USED(qlocked); poperror(); /* 1 */ } diff --git a/port/devnonet.c b/port/devnonet.c index c79f3c9fbaec0e68b9bc13ed58afefb1c5456010..e32f462cc360c7d777d939d0d5cc0166667b8ce4 100644 --- a/port/devnonet.c +++ b/port/devnonet.c @@ -236,7 +236,6 @@ Chan* nonetopen(Chan *c, int omode) { Stream *s; - Noconv *cp; Noifc *ifc; int line; @@ -252,7 +251,7 @@ nonetopen(Chan *c, int omode) * get an unused device and open it's control file */ ifc = &noifc[c->dev]; - cp = nonetopenclone(c, ifc); + nonetopenclone(c, ifc); break; case Nlistenqid: /* @@ -866,9 +865,7 @@ static void queueack(Noconv *cp, int mid) { int next; - ulong now; - now = NOW; next = (cp->anext + 1)&Nmask; if(next != cp->afirst){ cp->ack[cp->anext] = mid; @@ -959,6 +956,7 @@ sendmsg(Noconv *cp, Nomsg *mp) msgrem = mp->len; pktrem = msgrem > ifc->maxtu ? ifc->maxtu : msgrem; bp = mp->first; + SET(rptr); if(bp) rptr = bp->rptr; last = pkt = mkhdr(cp, msgrem); @@ -1189,7 +1187,6 @@ nonetfreeifc(Noifc *ifc) int nonetcksum(Block *bp, int offset) { - Block *nbp = bp; uchar *ep, *p; int n; ulong s; diff --git a/port/page.c b/port/page.c index 5560499bcdd8bf773ec402a0dcd3e3640561b6fa..d98a85b4361b440179573079c5803b944b6f30b1 100644 --- a/port/page.c +++ b/port/page.c @@ -341,7 +341,7 @@ loop: o->mqid = c->mqid; incref(c); }else{ - o->type = ~0; + o->type = 0xFFFF; o->qid = (Qid){~0, ~0}; o->mqid = (Qid){~0, ~0}; o->mchan = 0; diff --git a/port/stnoether.c b/port/stnoether.c index ee819e9c6e9b94fecc673cf65afa9d450898bad9..2fb8d85cb907e7b4d54a274de8c66f336d3ad338 100644 --- a/port/stnoether.c +++ b/port/stnoether.c @@ -62,7 +62,7 @@ noetherconnect(Noconv *cp, char *ea) eh = (Etherhdr *)cp->media->rptr; etherparse(eh->d, ea); eh->type[0] = ETHER_TYPE>>8; - eh->type[1] = ETHER_TYPE; + eh->type[1] = ETHER_TYPE & 0xff; } /* diff --git a/port/stream.c b/port/stream.c index d2139d5f15674b42e1c41af1cfdff0f1cfc938f0..0afd840305223a1bbadefc687d8c354f84577f10 100644 --- a/port/stream.c +++ b/port/stream.c @@ -109,6 +109,7 @@ newqinfo(Qinfo *qi) /* * upgrade a block 0 block to another class (called with bcp qlocked) */ +int newblock(Bclass *bcp) { Page *page; @@ -117,7 +118,7 @@ newblock(Bclass *bcp) uchar *cp; if(bcp->made > bcp->lim) - return; + return -1; if(bcp == bclass){ /* @@ -171,7 +172,7 @@ newblock(Bclass *bcp) bcp->last = bp; } } - return; + return 0; } /* @@ -421,7 +422,6 @@ putq(Queue *q, Block *bp) { int delim; - delim = 0; lock(q); if(q->first) q->last->next = bp; @@ -447,7 +447,6 @@ putb(Blist *q, Block *bp) { int delim; - delim = 0; if(q->first) q->last->next = bp; else @@ -914,7 +913,7 @@ streamclose(Chan *c) * if no stream, ignore it */ if(!c->stream) - return; + return 0; return streamclose1(c->stream); } @@ -933,7 +932,6 @@ stputq(Queue *q, Block *bp) wakeup(q->other->rp); delim = 1; } else { - delim = 0; lock(q); if(q->first) q->last->next = bp; diff --git a/port/sturp.c b/port/sturp.c index 0013e443f4489d6409692cff57b7466e72abf2a2..38ab348f67e299c0e3c56ac276ffdfe9af4568c4 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -541,6 +541,7 @@ urpctloput(Urp *up, Queue *q, Block *bp) case 1: outwin = strtoul(fields[0], 0, 0); } + USED(inwin); /* initinput(up, inwin); */ initoutput(up, outwin); freeb(bp); diff --git a/power/clock.c b/power/clock.c index 540b049fed104dcf0e92d9c42950db57305abe36..1cf8bd47b7d4d6d2ddde1c79cc8f15adced1c784 100644 --- a/power/clock.c +++ b/power/clock.c @@ -72,7 +72,9 @@ clockinit(void) t->cnt0 = TIME0; t->cnt0 = (TIME0>>8)&0xFF; i = *CLRTIM0; + USED(i); i = *CLRTIM1; + USED(i); m->ticks = 0; } @@ -86,6 +88,7 @@ clock(ulong n, ulong pc) if(n&INTR2){ i = *CLRTIM0; + USED(i); m->ticks++; if(m->machno == 0){ p = m->proc; @@ -114,6 +117,7 @@ clock(ulong n, ulong pc) extern ulong start; i = *CLRTIM1; + USED(i); #ifdef PROFILING pc -= (ulong)&start; pc /= sizeof(ulong); diff --git a/power/devhs.c b/power/devhs.c index 0ee5d4c470c79e8db438260a82e6caa43bd4e8eb..257d44c149029a2f6a7bfa0bfdce6f4ac4ad0d91 100644 --- a/power/devhs.c +++ b/power/devhs.c @@ -460,7 +460,6 @@ hsvmekproc(void *arg) Hsvme *hp; Device *addr; unsigned int c; - int miss; int locked; hp = (Hsvme *)arg; @@ -481,12 +480,14 @@ hsvmekproc(void *arg) /* * die if the device is closed */ + USED(locked); /* so locked = 0 and locked = 1 stay */ qlock(hp); locked = 1; if(hp->rq == 0){ qunlock(hp); hp->kstarted = 0; wakeup(&hp->r); + poperror(); return; } @@ -495,7 +496,6 @@ hsvmekproc(void *arg) */ while ((c = addr->data) != 0xFFFF) { hp->in++; - miss = 0; if(c & CHNO){ c &= 0x1FF; if(hp->chan == c) @@ -520,6 +520,7 @@ hsvmekproc(void *arg) upstream(hp, 0); } } + USED(locked); qunlock(hp); locked = 0; diff --git a/power/devrtc.c b/power/devrtc.c index 7a074ab66c81b2d16a1ea7220f83380aab610ae9..dde09fb9777f9245d726c8fafdd5880cbc84a91d 100644 --- a/power/devrtc.c +++ b/power/devrtc.c @@ -55,6 +55,7 @@ rtcpattern(void) * read the pattern sequence pointer to reset it */ ch = *nv; + USED(ch); /* * stuff the pattern recognition codes one bit at diff --git a/power/fns.h b/power/fns.h index 2faf77217de92e6bd7b46f67c1748b90147e3fb8..b46f1908aaef493fae93d6aecd0f8818316715fb 100644 --- a/power/fns.h +++ b/power/fns.h @@ -217,3 +217,6 @@ void wbflush(void); #define procsetup(x) #define procsave(x,y) #define procrestore(x,y) + +#define USED(x) if(x) +#define SET(x) x = 0 diff --git a/power/lock.c b/power/lock.c index b84e1dc93555e2fd86f492fa8e7e7864d1b1b751..18a0992bb92dc040787bab812cfb89a9174abc7c 100644 --- a/power/lock.c +++ b/power/lock.c @@ -31,14 +31,16 @@ lockinit(void) unlock(&semalloc.lock); } +#define PCOFF -9 + /* * If l->sbsem is zero, allocate a hardware semaphore first. * There is no way to free a semaphore. */ void -lock(Lock *l) +lock(Lock *ll) { -int addr; + Lock *l = ll; int i; ulong *sbsem; @@ -61,17 +63,17 @@ int addr; /* * Try the fast grab first */ - if((*sbsem&1) == 0){ - l->pc = ((ulong*)&addr)[-7]; + if((*sbsem&1) == 0){ + l->pc = ((ulong*)&ll)[PCOFF]; return; } for(i=0; i<10000000; i++) if((*sbsem&1) == 0){ - l->pc = ((ulong*)&addr)[-7]; + l->pc = ((ulong*)&ll)[PCOFF]; return; } *sbsem = 0; - print("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&addr)[-7], l->pc); + print("lock loop %lux pc %lux held by pc %lux\n", l, ((ulong*)&ll)[PCOFF], l->pc); dumpstack(); } diff --git a/power/main.c b/power/main.c index 3f2b1582984ffda018e4b2f51c063a8e9e997a39..9adf67fe974a6bcafe2d1372814eea9d3fa5856e 100644 --- a/power/main.c +++ b/power/main.c @@ -598,6 +598,7 @@ confinit(void) * clear MP bus error caused by sizing memory */ i = *SBEADDR; + USED(i); /* * set minimal default values diff --git a/power/trap.c b/power/trap.c index 41368cc33582ecb8bb1b6e35374851111af67a44..182626a7218058e009b9aa0cb38fc7e930fbd76f 100644 --- a/power/trap.c +++ b/power/trap.c @@ -80,6 +80,7 @@ trap(Ureg *ur) ulong x; char buf[ERRLEN]; + SET(x); ecode = EXCCODE(ur->cause); user = ur->status&KUP; if(u) @@ -200,6 +201,7 @@ intr(ulong cause, ulong pc) print("MP bus error %lux %lux\n", *MPBERR0, *MPBERR1); *MPBERR0 = 0; i = *SBEADDR; + USED(i); } /* @@ -223,6 +225,7 @@ intr(ulong cause, ulong pc) * 4. clear pending register */ i = SBCCREG->flevel; + USED(i); /* * 5a. process lance, scsi