diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-23 22:05:46 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-23 22:05:46 +0200 |
commit | ff03b72ed5f365a2ca052218e055fac678cf0e23 (patch) | |
tree | 3c6089d3274890bd7e947fbe9369d42481ed5dd5 | |
parent | 0b3fd7c05208b6de625bb0b4d1719b9fd22156ae (diff) | |
download | plan9front-ff03b72ed5f365a2ca052218e055fac678cf0e23.tar.xz |
devaoe: more nil vs. 0
-rw-r--r-- | sys/src/9/port/devaoe.c | 10 | ||||
-rw-r--r-- | sys/src/9/port/sdaoe.c | 41 |
2 files changed, 21 insertions, 30 deletions
diff --git a/sys/src/9/port/devaoe.c b/sys/src/9/port/devaoe.c index 7f6a052c0..68d66c25d 100644 --- a/sys/src/9/port/devaoe.c +++ b/sys/src/9/port/devaoe.c @@ -542,7 +542,7 @@ hset(Aoedev *d, Frame *f, Aoehdr *h, int cmd, int new) l = pickdevlink(d); i = pickea(l); if(i == -1){ - if(!(cmd == ACata && f->srb && Nofail(d, s))) + if(!(cmd == ACata && f->srb != nil && Nofail(d, s))) downdev(d, "resend fails; no netlink/ea"); return -1; } @@ -1238,7 +1238,7 @@ rw(Aoedev *d, int write, uchar *db, long len, uvlong off) if(write && !copy) memmove(srb->data, db, n); strategy(d, srb); - if(srb->error) + if(srb->error != nil) error(srb->error); if(!write && !copy) memmove(db, srb->data, n); @@ -1970,7 +1970,7 @@ qcfgrsp(Block *b, Netlink *nl) srb = f->srb; f->dp = nil; f->srb = nil; - if(srb){ + if(srb != nil){ srb->nout--; srbwakeup(srb); d->nout--; @@ -2133,7 +2133,7 @@ atarsp(Block *b) if(ahin->cmdstat & 0xa9){ eventlog("%æ: ata error cmd %.2ux stat %.2ux\n", d, ahout->cmdstat, ahin->cmdstat); - if(srb) + if(srb != nil) srb->error = Eio; } else { n = ahout->scnt * Aoesectsz; @@ -2174,7 +2174,7 @@ atarsp(Block *b) } f->srb = nil; - if(srb){ + if(srb != nil){ srb->nout--; srbwakeup(srb); } diff --git a/sys/src/9/port/sdaoe.c b/sys/src/9/port/sdaoe.c index 7c3c7bf67..9561113b1 100644 --- a/sys/src/9/port/sdaoe.c +++ b/sys/src/9/port/sdaoe.c @@ -85,20 +85,16 @@ aoectl(Ctlr *d, char *s) { Chan *c; - c = nil; + uprint("%s/ctl", d->path); + c = namec(up->genbuf, Aopen, OWRITE, 0); if(waserror()){ - if(c) - cclose(c); print("sdaoectl: %s\n", up->errstr); + cclose(c); nexterror(); } - - uprint("%s/ctl", d->path); - c = namec(up->genbuf, Aopen, OWRITE, 0); devtab[c->type]->write(c, s, strlen(s), 0); - - poperror(); cclose(c); + poperror(); } /* must call with d qlocked */ @@ -107,20 +103,16 @@ aoeidentify(Ctlr *d, SDunit *u) { Chan *c; - c = nil; + uprint("%s/ident", d->path); + c = namec(up->genbuf, Aopen, OREAD, 0); if(waserror()){ - if(c) - cclose(c); iprint("aoeidentify: %s\n", up->errstr); + cclose(c); nexterror(); } - - uprint("%s/ident", d->path); - c = namec(up->genbuf, Aopen, OREAD, 0); devtab[c->type]->read(c, d->ident, sizeof d->ident, 0); - - poperror(); cclose(c); + poperror(); d->feat = 0; identify(d, (ushort*)d->ident); @@ -140,7 +132,7 @@ ctlrlookup(char *path) Ctlr *c; lock(&ctlrlock); - for(c = head; c; c = c->next) + for(c = head; c != nil; c = c->next) if(strcmp(c->path, path) == 0) break; unlock(&ctlrlock); @@ -175,15 +167,15 @@ delctlr(Ctlr *c) lock(&ctlrlock); - for(prev = 0, x = head; x; prev = x, x = c->next) + for(prev = 0, x = head; x != nil; prev = x, x = c->next) if(strcmp(c->path, x->path) == 0) break; - if(x == 0){ + if(x == nil){ unlock(&ctlrlock); error(Enonexist); } - if(prev) + if(prev != nil) prev->next = x->next; else head = x->next; @@ -191,7 +183,7 @@ delctlr(Ctlr *c) tail = prev; unlock(&ctlrlock); - if(x->c) + if(x->c != nil) cclose(x->c); free(x); } @@ -204,12 +196,11 @@ aoeprobe(char *path, SDev *s) Chan *c; Ctlr *ctlr; - if((p = strrchr(path, '/')) == 0) + if((p = strrchr(path, '/')) == nil) error(Ebadarg); *p = 0; uprint("%s/ctl", path); *p = '/'; - c = namec(up->genbuf, Aopen, OWRITE, 0); if(waserror()) { cclose(c); @@ -217,8 +208,8 @@ aoeprobe(char *path, SDev *s) } n = uprint("discover %s", p+1); devtab[c->type]->write(c, up->genbuf, n, 0); - poperror(); cclose(c); + poperror(); for(i = 0;; i += Probeintvl){ if(i > Probemax || waserror()) @@ -256,7 +247,7 @@ aoepnp(void) char *p; SDev *h, *t, *s; - if((p = getconf("aoedev")) == 0) + if((p = getconf("aoedev")) == nil) return 0; kstrdup(&probebuf, p); nprobe = tokenize(probebuf, probef, nelem(probef)); |