M gnot/devincon.c => gnot/devincon.c +6 -5
@@ 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;
}
M gnot/fault68020.c => gnot/fault68020.c +2 -9
@@ 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);
M gnot/fns.h => gnot/fns.h +2 -0
@@ 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)
M port/devdk.c => port/devdk.c +13 -14
@@ 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(;;){
M port/devmnt.c => port/devmnt.c +6 -0
@@ 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 */
}
M port/devnonet.c => port/devnonet.c +2 -5
@@ 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;
M port/page.c => port/page.c +1 -1
@@ 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;
M port/stnoether.c => port/stnoether.c +1 -1
@@ 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;
}
/*
M port/stream.c => port/stream.c +4 -6
@@ 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;
M port/sturp.c => port/sturp.c +1 -0
@@ 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);
M power/clock.c => power/clock.c +4 -0
@@ 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);
M power/devhs.c => power/devhs.c +3 -2
@@ 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;
M power/devrtc.c => power/devrtc.c +1 -0
@@ 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
M power/fns.h => power/fns.h +3 -0
@@ 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
M power/lock.c => power/lock.c +8 -6
@@ 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();
}
M power/main.c => power/main.c +1 -0
@@ 598,6 598,7 @@ confinit(void)
* clear MP bus error caused by sizing memory
*/
i = *SBEADDR;
+ USED(i);
/*
* set minimal default values
M power/trap.c => power/trap.c +3 -0
@@ 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