kernel: use nil for pointers instead of 0, zero channel umc and dirrock in newchan()

This commit is contained in:
cinap_lenrek 2014-08-08 16:44:41 +02:00
parent 0ceeee4c8b
commit ee6409366e
2 changed files with 15 additions and 12 deletions

View file

@ -250,16 +250,20 @@ newchan(void)
c->offset = 0; c->offset = 0;
c->devoffset = 0; c->devoffset = 0;
c->iounit = 0; c->iounit = 0;
c->umh = 0; c->umh = nil;
c->umc = nil;
c->uri = 0; c->uri = 0;
c->dri = 0; c->dri = 0;
c->aux = 0; c->dirrock = nil;
c->mchan = 0; c->nrock = 0;
c->mcp = 0; c->mrock = 0;
c->mux = 0;
memset(&c->mqid, 0, sizeof(c->mqid));
c->path = 0;
c->ismtpt = 0; c->ismtpt = 0;
c->mcp = nil;
c->mux = nil;
c->aux = nil;
c->mchan = nil;
memset(&c->mqid, 0, sizeof(c->mqid));
c->path = nil;
return c; return c;
} }
@ -444,7 +448,7 @@ chanfree(Chan *c)
if(c->dirrock != nil){ if(c->dirrock != nil){
free(c->dirrock); free(c->dirrock);
c->dirrock = 0; c->dirrock = nil;
c->nrock = 0; c->nrock = 0;
c->mrock = 0; c->mrock = 0;
} }
@ -868,8 +872,7 @@ cclone(Chan *c)
error("clone failed"); error("clone failed");
nc = wq->clone; nc = wq->clone;
free(wq); free(wq);
nc->path = c->path; if((nc->path = c->path) != nil)
if(c->path)
incref(c->path); incref(c->path);
return nc; return nc;
} }
@ -924,7 +927,7 @@ domount(Chan **cp, Mhead **mp, Path **path)
if(findmount(cp, mp, (*cp)->type, (*cp)->dev, (*cp)->qid) == 0) if(findmount(cp, mp, (*cp)->type, (*cp)->dev, (*cp)->qid) == 0)
return 0; return 0;
if(path){ if(path != nil){
p = *path; p = *path;
p = uniquepath(p); p = uniquepath(p);
if(p->mlen <= 0) if(p->mlen <= 0)

View file

@ -355,7 +355,7 @@ unionread(Chan *c, void *va, long n)
/* Advance to next element */ /* Advance to next element */
c->uri++; c->uri++;
if(c->umc){ if(c->umc != nil){
cclose(c->umc); cclose(c->umc);
c->umc = nil; c->umc = nil;
} }