From e3e01a36f7b77dc44628dd8bbb711b4cce2a3d00 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 5 Nov 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-11-05 --- carrera/kbd.c | 2 ++ ip/devip.c | 9 ++------- pc/devether.c | 2 ++ pc/kbd.c | 2 ++ port/alloc.c | 18 ++++++++++++++++++ port/devcons.c | 2 ++ port/devmnt.c | 2 -- port/devns16552.c | 2 ++ port/netif.c | 16 +++++++++++----- port/qio.c | 16 +--------------- port/sysfile.c | 7 ------- 11 files changed, 42 insertions(+), 36 deletions(-) diff --git a/carrera/kbd.c b/carrera/kbd.c index f02fd2651d1beede3059f20eb080fc6a87e97833..18b29ce9e4948ab5e045211f39c08047a1a8398a 100644 --- a/carrera/kbd.c +++ b/carrera/kbd.c @@ -356,6 +356,8 @@ kbdinit(void) int i; kbdq = qopen(4*1024, 0, 0, 0); + if(kbdq == nil) + panic("kbdinit"); qnoblock(kbdq, 1); /* diff --git a/ip/devip.c b/ip/devip.c index 13cca1d5cf90b0b097dca6aa2f32c1877cfd3546..ccb371c36a46d198aafaa3ba51bd4026b1d2eb34 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -470,14 +470,9 @@ ipread(Chan *ch, void *a, long n, ulong offset) sprint(buf, "%s/%d %d %s \n", c->p->name, c->x, c->inuse, statename); return readstr(offset, p, n, buf); case Qdata: -{int xxx; -poot("ipread 1", 0); c = fs.p[PROTO(ch->qid)]->conv[CONV(ch->qid)]; -// return qread(c->rq, a, n); - xxx = qread(c->rq, a, n); -poot("ipread 2", 0); - return xxx; -} + return qread(c->rq, a, n); + case Qerr: c = fs.p[PROTO(ch->qid)]->conv[CONV(ch->qid)]; return qread(c->eq, a, n); diff --git a/pc/devether.c b/pc/devether.c index 8684d64f95deecf670fc897478074ecbb5a854bd..5fafe6a32da94f2670248f1b82dd91157346aa90 100644 --- a/pc/devether.c +++ b/pc/devether.c @@ -378,6 +378,8 @@ etherreset(void) if(ether->oq == 0) ether->oq = qopen(64*1024, 1, 0, 0); } + if(ether->oq == 0) + panic("etherreset %s", name); ether->alen = Eaddrlen; memmove(ether->addr, ether->ea, Eaddrlen); memset(ether->bcast, 0xFF, Eaddrlen); diff --git a/pc/kbd.c b/pc/kbd.c index e7575fb265c4932c3d28748833709cfef322e9d4..123b00b7a6f0f0495e717e29e35ccb6d988a0871 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -380,6 +380,8 @@ kbdinit(void) int c; kbdq = qopen(4*1024, 0, 0, 0); + if(kbdq == nil) + panic("kbdinit"); qnoblock(kbdq, 1); intrenable(VectorKBD, i8042intr, 0, BUSUNKNOWN); diff --git a/port/alloc.c b/port/alloc.c index 66d4ae0e51e8a92608d124d584eb65562f0c65b9..e62f90d82a750b8c72d8000d3dbe8b857299e1cd 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -601,3 +601,21 @@ poolcompact(Pool *pool) return compacted; } + +int +recur(Bhdr *t) +{ + if(t == 0) + return 1; + if(((ulong)t) < 0x80000000) + return 0; + if(((ulong)t) > 0x90000000) + return 0; + return recur(t->right) && recur(t->left); +} + +int +poolok(void) +{ + return recur(mainmem->root); +} diff --git a/port/devcons.c b/port/devcons.c index 6276dd23db0fdfd036a3dbb3622c9b2883c42d27..f2fc584f57e8bc890c52435915f59421a444ca8f 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -37,6 +37,8 @@ void printinit(void) { lineq = qopen(2*1024, 0, 0, 0); + if(lineq == nil) + panic("printinit"); qnoblock(lineq, 1); } diff --git a/port/devmnt.c b/port/devmnt.c index af1cacb2e3ea32700e21dc85e5987f36b886981d..9863801bc54f053cdce83849cef519714154e7c4 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -696,12 +696,10 @@ mountio(Mnt *m, Mntrpc *r) } m->rip = up; unlock(m); -poot("M1", m->c->qid.path); while(r->done == 0) { mntrpcread(m, r); mountmux(m, r); } -poot("M2", m->c->qid.path); mntgate(m); } diff --git a/port/devns16552.c b/port/devns16552.c index 8357de1786846ee3eb920765d2f02e8da1116fa8..e228d4652bc9e76cf30c0ab3ab791f56d011adbd 100644 --- a/port/devns16552.c +++ b/port/devns16552.c @@ -480,6 +480,8 @@ ns16552setup0(Uart *p) p->iq = qopen(4*1024, 0, ns16552flow, p); p->oq = qopen(4*1024, 0, ns16552kick, p); + if(p->iq == nil || p->oq == nil) + panic("ns16552setup0"); p->ip = p->istage; p->ie = &p->istage[Stagesize]; diff --git a/port/netif.c b/port/netif.c index ff9a8b9064e4362fe7cbc79312fc417cce0e16a8..6af9bb38b5a11b518b8f93371b179276bc02a401 100644 --- a/port/netif.c +++ b/port/netif.c @@ -387,17 +387,23 @@ openfile(Netif *nif, int id) } qlock(nif); + if(waserror()){ + qunlock(nif); + nexterror(); + } efp = &nif->f[nif->nfile]; for(fp = nif->f; fp < efp; fp++){ f = *fp; if(f == 0){ f = malloc(sizeof(Netfile)); - if(f == 0){ - qunlock(nif); - error(Enodev); + if(f == 0) + exhausted("memory"); + f->in = qopen(nif->limit, 1, 0, 0); + if(f->in == nil){ + free(f); + exhausted("memory"); } *fp = f; - f->in = qopen(nif->limit, 1, 0, 0); qlock(f); } else { qlock(f); @@ -411,9 +417,9 @@ openfile(Netif *nif, int id) netown(f, up->user, 0); qunlock(f); qunlock(nif); + poperror(); return fp - nif->f; } - qunlock(nif); error(Enodev); return -1; /* not reached */ } diff --git a/port/qio.c b/port/qio.c index fae8760f10545b7501d02e6d2ea4aff4b70ea06a..7d1ad976785792aabd0f51336b62c9fe5a9b26e2 100644 --- a/port/qio.c +++ b/port/qio.c @@ -21,7 +21,7 @@ static ulong qcopycnt; static int debuging; -#define QDEBUG if(1) +#define QDEBUG if(0) /* * IO queues @@ -115,8 +115,6 @@ allocb(int size) ulong addr; int n; - if(size < 0) - panic("allocb < 0"); n = sizeof(Block) + size + (BY2V-1); b = mallocz(n+Hdrspc, 0); if(b == 0) @@ -150,8 +148,6 @@ iallocb(int size) return 0; } - if(size < 0) - panic("iallocb < 0"); n = sizeof(Block) + size + (BY2V-1); b = mallocz(n+Hdrspc, 0); if(b == nil){ @@ -797,7 +793,6 @@ qbread(Queue *q, int len) Block *b, *nb; int n, dowakeup; -poot("QB start", len); qlock(&q->rlock); if(waserror()){ qunlock(&q->rlock); @@ -826,12 +821,9 @@ poot("QB start", len); q->state |= Qstarve; /* flag requesting producer to wake me */ iunlock(q); -poot("QB before sleep", len); sleep(&q->rr, notempty, q); -poot("QB after sleep", len); } -poot("QB 1", len); /* remove a buffered block */ q->bfirst = b->next; b->next = 0; @@ -848,7 +840,6 @@ poot("QB 1", len); /* split block if it's too big and this is not a message-oriented queue */ nb = b; -poot("QB 2", len); if(n > len){ if((q->state&Qmsg) == 0){ iunlock(q); @@ -879,7 +870,6 @@ poot("QB 2", len); poperror(); qunlock(&q->rlock); -poot("QB end", nb); return nb; } @@ -892,17 +882,13 @@ qread(Queue *q, void *vp, int len) { Block *b; -poot("Q 1", 0); b = qbread(q, len); -poot("Q 2", 0); if(b == 0) return 0; len = BLEN(b); memmove(vp, b->rp, len); -poot("Q 3", 0); freeb(b); -poot("Q 4", 0); return len; } diff --git a/port/sysfile.c b/port/sysfile.c index e845386a363e5a0a7c7cf9234f0133e077739701..13edeffdbdda09a36092f10d4b12e53040e3fdb3 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -5,13 +5,6 @@ #include "fns.h" #include "../port/error.h" -void -poot(char *s, int d) -{ - if(up->slash->type<0||up->slash->type>50||(up->slash->flag&COPEN)) - panic("poot: %s %d=%lux\n", s, d, d); -} - /* * The sys*() routines needn't poperror() as they return directly to syscall(). */