From 513bdcccdc023f17bd36a388d09f8a03a7a707a7 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 2 Sep 2011 14:12:39 +0200 Subject: chan: use chanpath() in chan DBG, do more checking in cclose and cclone --- sys/src/9/port/chan.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/src/9/port/chan.c b/sys/src/9/port/chan.c index d21e9ac3a..28ac86e13 100644 --- a/sys/src/9/port/chan.c +++ b/sys/src/9/port/chan.c @@ -472,10 +472,10 @@ chanfree(Chan *c) void cclose(Chan *c) { - if(c->flag&CFREE) + if(c == nil || c->ref < 1 || c->flag&CFREE) panic("cclose %#p", getcallerpc(&c)); - DBG("cclose %p name=%s ref=%ld\n", c, c->path->s, c->ref); + DBG("cclose %p name=%s ref=%ld\n", c, chanpath(c), c->ref); if(decref(c)) return; @@ -503,10 +503,10 @@ void closeproc(void*); void ccloseq(Chan *c) { - if(c->flag&CFREE) - panic("cclose %#p", getcallerpc(&c)); + if(c == nil || c->ref < 1 || c->flag&CFREE) + panic("ccloseq %#p", getcallerpc(&c)); - DBG("ccloseq %p name=%s ref=%ld\n", c, c->path->s, c->ref); + DBG("ccloseq %p name=%s ref=%ld\n", c, chanpath(c), c->ref); if(decref(c)) return; @@ -822,6 +822,8 @@ cclone(Chan *c) Chan *nc; Walkqid *wq; + if(c == nil || c->ref < 1 || c->flag&CFREE) + panic("cclone: %#p", getcallerpc(&c)); wq = devtab[c->type]->walk(c, nil, nil, 0); if(wq == nil) error("clone failed"); -- cgit v1.2.3