kernel: consistent use of nil for pointer in sysfile.c
This commit is contained in:
parent
1fcc84d072
commit
769b3f1c2f
1 changed files with 25 additions and 26 deletions
|
@ -40,7 +40,7 @@ growfd(Fgrp *f, int fd) /* fd is always >= 0 */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
newfd = malloc((f->nfd+DELTAFD)*sizeof(Chan*));
|
newfd = malloc((f->nfd+DELTAFD)*sizeof(Chan*));
|
||||||
if(newfd == 0)
|
if(newfd == nil)
|
||||||
goto Exhausted;
|
goto Exhausted;
|
||||||
oldfd = f->fd;
|
oldfd = f->fd;
|
||||||
memmove(newfd, oldfd, f->nfd*sizeof(Chan*));
|
memmove(newfd, oldfd, f->nfd*sizeof(Chan*));
|
||||||
|
@ -64,7 +64,7 @@ findfreefd(Fgrp *f, int start)
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
for(fd=start; fd<f->nfd; fd++)
|
for(fd=start; fd<f->nfd; fd++)
|
||||||
if(f->fd[fd] == 0)
|
if(f->fd[fd] == nil)
|
||||||
break;
|
break;
|
||||||
if(fd >= f->nfd && growfd(f, fd) < 0)
|
if(fd >= f->nfd && growfd(f, fd) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -122,11 +122,11 @@ fdtochan(int fd, int mode, int chkmnt, int iref)
|
||||||
Chan *c;
|
Chan *c;
|
||||||
Fgrp *f;
|
Fgrp *f;
|
||||||
|
|
||||||
c = 0;
|
c = nil;
|
||||||
f = up->fgrp;
|
f = up->fgrp;
|
||||||
|
|
||||||
lock(f);
|
lock(f);
|
||||||
if(fd<0 || f->nfd<=fd || (c = f->fd[fd])==0) {
|
if(fd<0 || f->nfd<=fd || (c = f->fd[fd])==nil) {
|
||||||
unlock(f);
|
unlock(f);
|
||||||
error(Ebadfd);
|
error(Ebadfd);
|
||||||
}
|
}
|
||||||
|
@ -201,10 +201,10 @@ syspipe(va_list list)
|
||||||
ufd[0] = ufd[1] = fd[0] = fd[1] = -1;
|
ufd[0] = ufd[1] = fd[0] = fd[1] = -1;
|
||||||
d = devtab[devno('|', 0)];
|
d = devtab[devno('|', 0)];
|
||||||
c[0] = namec("#|", Atodir, 0, 0);
|
c[0] = namec("#|", Atodir, 0, 0);
|
||||||
c[1] = 0;
|
c[1] = nil;
|
||||||
if(waserror()){
|
if(waserror()){
|
||||||
cclose(c[0]);
|
cclose(c[0]);
|
||||||
if(c[1])
|
if(c[1] != nil)
|
||||||
cclose(c[1]);
|
cclose(c[1]);
|
||||||
nexterror();
|
nexterror();
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ sysdup(va_list list)
|
||||||
oc = f->fd[fd];
|
oc = f->fd[fd];
|
||||||
f->fd[fd] = c;
|
f->fd[fd] = c;
|
||||||
unlockfgrp(f);
|
unlockfgrp(f);
|
||||||
if(oc)
|
if(oc != nil)
|
||||||
cclose(oc);
|
cclose(oc);
|
||||||
}else{
|
}else{
|
||||||
if(waserror()) {
|
if(waserror()) {
|
||||||
|
@ -340,7 +340,7 @@ unionread(Chan *c, void *va, long n)
|
||||||
nr = 0;
|
nr = 0;
|
||||||
while(mount != nil){
|
while(mount != nil){
|
||||||
/* Error causes component of union to be skipped */
|
/* Error causes component of union to be skipped */
|
||||||
if(mount->to && !waserror()){
|
if(mount->to != nil && !waserror()){
|
||||||
if(c->umc == nil){
|
if(c->umc == nil){
|
||||||
c->umc = cclone(mount->to);
|
c->umc = cclone(mount->to);
|
||||||
c->umc = devtab[c->umc->type]->open(c->umc, OREAD);
|
c->umc = devtab[c->umc->type]->open(c->umc, OREAD);
|
||||||
|
@ -371,7 +371,7 @@ unionrewind(Chan *c)
|
||||||
{
|
{
|
||||||
eqlock(&c->umqlock);
|
eqlock(&c->umqlock);
|
||||||
c->uri = 0;
|
c->uri = 0;
|
||||||
if(c->umc){
|
if(c->umc != nil){
|
||||||
cclose(c->umc);
|
cclose(c->umc);
|
||||||
c->umc = nil;
|
c->umc = nil;
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ mountfix(Chan *c, uchar *op, long n, long maxn)
|
||||||
* If it's a union directory and the original is
|
* If it's a union directory and the original is
|
||||||
* in the union, don't rewrite anything.
|
* in the union, don't rewrite anything.
|
||||||
*/
|
*/
|
||||||
for(m=mh->mount; m; m=m->next)
|
for(m = mh->mount; m != nil; m = m->next)
|
||||||
if(eqchantdqid(m->to, d.type, d.dev, d.qid, 1))
|
if(eqchantdqid(m->to, d.type, d.dev, d.qid, 1))
|
||||||
goto Norewrite;
|
goto Norewrite;
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ mountfix(Chan *c, uchar *op, long n, long maxn)
|
||||||
putmhead(mh);
|
putmhead(mh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(buf)
|
if(buf != nil)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
if(p != e)
|
if(p != e)
|
||||||
|
@ -668,7 +668,7 @@ read(int fd, uchar *p, long n, vlong *offp)
|
||||||
if(c->qid.type & QTDIR){
|
if(c->qid.type & QTDIR){
|
||||||
if(mountrockread(c, p, n, &nn)){
|
if(mountrockread(c, p, n, &nn)){
|
||||||
/* do nothing: mountrockread filled buffer */
|
/* do nothing: mountrockread filled buffer */
|
||||||
}else if(c->umh)
|
}else if(c->umh != nil)
|
||||||
nn = unionread(c, p, n);
|
nn = unionread(c, p, n);
|
||||||
else{
|
else{
|
||||||
if(off != c->offset)
|
if(off != c->offset)
|
||||||
|
@ -932,7 +932,7 @@ pathlast(Path *p)
|
||||||
if(p->len == 0)
|
if(p->len == 0)
|
||||||
return nil;
|
return nil;
|
||||||
s = strrchr(p->s, '/');
|
s = strrchr(p->s, '/');
|
||||||
if(s)
|
if(s != nil)
|
||||||
return s+1;
|
return s+1;
|
||||||
return p->s;
|
return p->s;
|
||||||
}
|
}
|
||||||
|
@ -981,7 +981,7 @@ sysstat(va_list list)
|
||||||
}
|
}
|
||||||
r = devtab[c->type]->stat(c, s, l);
|
r = devtab[c->type]->stat(c, s, l);
|
||||||
name = pathlast(c->path);
|
name = pathlast(c->path);
|
||||||
if(name)
|
if(name != nil)
|
||||||
r = dirsetname(name, strlen(name), s, r, l);
|
r = dirsetname(name, strlen(name), s, r, l);
|
||||||
|
|
||||||
poperror();
|
poperror();
|
||||||
|
@ -1032,7 +1032,7 @@ bindmount(int ismount, int fd, int afd, char* arg0, char* arg1, ulong flag, char
|
||||||
ac = nil;
|
ac = nil;
|
||||||
bc = fdtochan(fd, ORDWR, 0, 1);
|
bc = fdtochan(fd, ORDWR, 0, 1);
|
||||||
if(waserror()) {
|
if(waserror()) {
|
||||||
if(ac)
|
if(ac != nil)
|
||||||
cclose(ac);
|
cclose(ac);
|
||||||
cclose(bc);
|
cclose(bc);
|
||||||
nexterror();
|
nexterror();
|
||||||
|
@ -1048,11 +1048,11 @@ bindmount(int ismount, int fd, int afd, char* arg0, char* arg1, ulong flag, char
|
||||||
ret = devno('M', 0);
|
ret = devno('M', 0);
|
||||||
c0 = devtab[ret]->attach((char*)&bogus);
|
c0 = devtab[ret]->attach((char*)&bogus);
|
||||||
poperror(); /* ac bc */
|
poperror(); /* ac bc */
|
||||||
if(ac)
|
if(ac != nil)
|
||||||
cclose(ac);
|
cclose(ac);
|
||||||
cclose(bc);
|
cclose(bc);
|
||||||
}else{
|
}else{
|
||||||
spec = 0;
|
spec = nil;
|
||||||
validaddr((uintptr)arg0, 1, 0);
|
validaddr((uintptr)arg0, 1, 0);
|
||||||
c0 = namec(arg0, Abind, 0, 0);
|
c0 = namec(arg0, Abind, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -1133,17 +1133,16 @@ sysunmount(va_list list)
|
||||||
name = va_arg(list, char*);
|
name = va_arg(list, char*);
|
||||||
old = va_arg(list, char*);
|
old = va_arg(list, char*);
|
||||||
|
|
||||||
cmounted = 0;
|
cmounted = nil;
|
||||||
validaddr((uintptr)old, 1, 0);
|
validaddr((uintptr)old, 1, 0);
|
||||||
cmount = namec(old, Amount, 0, 0);
|
cmount = namec(old, Amount, 0, 0);
|
||||||
if(waserror()) {
|
if(waserror()) {
|
||||||
cclose(cmount);
|
cclose(cmount);
|
||||||
if(cmounted)
|
if(cmounted != nil)
|
||||||
cclose(cmounted);
|
cclose(cmounted);
|
||||||
nexterror();
|
nexterror();
|
||||||
}
|
}
|
||||||
|
if(name != nil) {
|
||||||
if(name) {
|
|
||||||
/*
|
/*
|
||||||
* This has to be namec(..., Aopen, ...) because
|
* This has to be namec(..., Aopen, ...) because
|
||||||
* if arg[0] is something like /srv/cs or /fd/0,
|
* if arg[0] is something like /srv/cs or /fd/0,
|
||||||
|
@ -1156,7 +1155,7 @@ sysunmount(va_list list)
|
||||||
cunmount(cmount, cmounted);
|
cunmount(cmount, cmounted);
|
||||||
poperror();
|
poperror();
|
||||||
cclose(cmount);
|
cclose(cmount);
|
||||||
if(cmounted)
|
if(cmounted != nil)
|
||||||
cclose(cmounted);
|
cclose(cmounted);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1315,12 +1314,12 @@ packoldstat(uchar *buf, Dir *d)
|
||||||
uintptr
|
uintptr
|
||||||
sys_stat(va_list list)
|
sys_stat(va_list list)
|
||||||
{
|
{
|
||||||
|
static char old[] = "old stat system call - recompile";
|
||||||
Chan *c;
|
Chan *c;
|
||||||
uint l;
|
uint l;
|
||||||
uchar *s, buf[128]; /* old DIRLEN plus a little should be plenty */
|
uchar *s, buf[128]; /* old DIRLEN plus a little should be plenty */
|
||||||
char strs[128], *name;
|
char strs[128], *name;
|
||||||
Dir d;
|
Dir d;
|
||||||
char old[] = "old stat system call - recompile";
|
|
||||||
|
|
||||||
name = va_arg(list, char*);
|
name = va_arg(list, char*);
|
||||||
s = va_arg(list, uchar*);
|
s = va_arg(list, uchar*);
|
||||||
|
@ -1336,7 +1335,7 @@ sys_stat(va_list list)
|
||||||
if(l <= BIT16SZ) /* buffer too small; time to face reality */
|
if(l <= BIT16SZ) /* buffer too small; time to face reality */
|
||||||
error(old);
|
error(old);
|
||||||
name = pathlast(c->path);
|
name = pathlast(c->path);
|
||||||
if(name)
|
if(name != nil)
|
||||||
l = dirsetname(name, strlen(name), buf, l, sizeof buf);
|
l = dirsetname(name, strlen(name), buf, l, sizeof buf);
|
||||||
l = convM2D(buf, l, &d, strs);
|
l = convM2D(buf, l, &d, strs);
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
|
@ -1351,13 +1350,13 @@ sys_stat(va_list list)
|
||||||
uintptr
|
uintptr
|
||||||
sys_fstat(va_list list)
|
sys_fstat(va_list list)
|
||||||
{
|
{
|
||||||
|
static char old[] = "old fstat system call - recompile";
|
||||||
Chan *c;
|
Chan *c;
|
||||||
char *name;
|
char *name;
|
||||||
uint l;
|
uint l;
|
||||||
uchar *s, buf[128]; /* old DIRLEN plus a little should be plenty */
|
uchar *s, buf[128]; /* old DIRLEN plus a little should be plenty */
|
||||||
char strs[128];
|
char strs[128];
|
||||||
Dir d;
|
Dir d;
|
||||||
char old[] = "old fstat system call - recompile";
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = va_arg(list, int);
|
fd = va_arg(list, int);
|
||||||
|
@ -1373,7 +1372,7 @@ sys_fstat(va_list list)
|
||||||
if(l <= BIT16SZ) /* buffer too small; time to face reality */
|
if(l <= BIT16SZ) /* buffer too small; time to face reality */
|
||||||
error(old);
|
error(old);
|
||||||
name = pathlast(c->path);
|
name = pathlast(c->path);
|
||||||
if(name)
|
if(name != nil)
|
||||||
l = dirsetname(name, strlen(name), buf, l, sizeof buf);
|
l = dirsetname(name, strlen(name), buf, l, sizeof buf);
|
||||||
l = convM2D(buf, l, &d, strs);
|
l = convM2D(buf, l, &d, strs);
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue