fix misleading/wrong fd checks
This commit is contained in:
parent
292cce2ad1
commit
84e019aba3
12 changed files with 16 additions and 16 deletions
|
@ -153,7 +153,7 @@ char *dir;
|
||||||
if ((ofd = openout(to, asb, islink(to, asb), 1)) < 0) {
|
if ((ofd = openout(to, asb, islink(to, asb), 1)) < 0) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (ofd > 0) {
|
if (ofd >= 0) {
|
||||||
passdata(from, ifd, to, ofd);
|
passdata(from, ifd, to, ofd);
|
||||||
}
|
}
|
||||||
tstamp[0] = asb->sb_atime;
|
tstamp[0] = asb->sb_atime;
|
||||||
|
|
|
@ -129,7 +129,7 @@ xfidopen(Xfid *x)
|
||||||
* though, we'd need to squirrel away the data in case it's
|
* though, we'd need to squirrel away the data in case it's
|
||||||
* modified during the operation, e.g. by |sort
|
* modified during the operation, e.g. by |sort
|
||||||
*/
|
*/
|
||||||
if(w->rdselfd > 0){
|
if(w->rdselfd >= 0){
|
||||||
winunlock(w);
|
winunlock(w);
|
||||||
respond(x, &fc, Einuse);
|
respond(x, &fc, Einuse);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -127,7 +127,7 @@ main(int argc, char **argv)
|
||||||
origargs = procgetname();
|
origargs = procgetname();
|
||||||
/* see if we should use a larger message size */
|
/* see if we should use a larger message size */
|
||||||
fd = open("/dev/draw", OREAD);
|
fd = open("/dev/draw", OREAD);
|
||||||
if(fd > 0){
|
if(fd >= 0){
|
||||||
ms = iounit(fd);
|
ms = iounit(fd);
|
||||||
if(msgsize < ms+IOHDRSZ)
|
if(msgsize < ms+IOHDRSZ)
|
||||||
msgsize = ms+IOHDRSZ;
|
msgsize = ms+IOHDRSZ;
|
||||||
|
|
|
@ -77,7 +77,7 @@ filefree(Node *node)
|
||||||
if(fp == 0)
|
if(fp == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(fp->fd > 0){
|
if(fp->fd >= 0){
|
||||||
ntmp--;
|
ntmp--;
|
||||||
close(fp->fd);
|
close(fp->fd);
|
||||||
remove(fp->template);
|
remove(fp->template);
|
||||||
|
|
|
@ -52,7 +52,7 @@ writelog(HConnect *c, char *fmt, ...)
|
||||||
|
|
||||||
/* verbose logfile, for research on web traffic */
|
/* verbose logfile, for research on web traffic */
|
||||||
logfd = logall[today & 1];
|
logfd = logall[today & 1];
|
||||||
if(logfd > 0){
|
if(logfd >= 0){
|
||||||
if(c->hstop == c->header || c->hstop[-1] != '\n')
|
if(c->hstop == c->header || c->hstop[-1] != '\n')
|
||||||
*c->hstop = '\n';
|
*c->hstop = '\n';
|
||||||
*c->hstop = '\0';
|
*c->hstop = '\0';
|
||||||
|
|
|
@ -55,7 +55,7 @@ lookup(char *object, int section, Hit **list)
|
||||||
|
|
||||||
snprint(file, sizeof(file), "/sys/man/%d/INDEX", section);
|
snprint(file, sizeof(file), "/sys/man/%d/INDEX", section);
|
||||||
fd = open(file, OREAD);
|
fd = open(file, OREAD);
|
||||||
if(fd > 0){
|
if(fd >= 0){
|
||||||
Binit(&b, fd, OREAD);
|
Binit(&b, fd, OREAD);
|
||||||
for(;;){
|
for(;;){
|
||||||
p = Brdline(&b, '\n');
|
p = Brdline(&b, '\n');
|
||||||
|
|
|
@ -2758,7 +2758,7 @@ main(int argc, char **argv)
|
||||||
snprint(buf, sizeof buf, "%sctl", dev);
|
snprint(buf, sizeof buf, "%sctl", dev);
|
||||||
cfd = open(buf, ORDWR);
|
cfd = open(buf, ORDWR);
|
||||||
}
|
}
|
||||||
if(cfd > 0){
|
if(cfd >= 0){
|
||||||
if(baud)
|
if(baud)
|
||||||
fprint(cfd, "b%d", baud);
|
fprint(cfd, "b%d", baud);
|
||||||
fprint(cfd, "m1"); /* cts/rts flow control (and fifo's) on */
|
fprint(cfd, "m1"); /* cts/rts flow control (and fifo's) on */
|
||||||
|
|
|
@ -110,7 +110,7 @@ redistrib(uchar *buf, int len)
|
||||||
|
|
||||||
uh = (Udphdr *)buf;
|
uh = (Udphdr *)buf;
|
||||||
for (tp = forwtarg; tp < forwtarg + forwtcount; tp++)
|
for (tp = forwtarg; tp < forwtarg + forwtcount; tp++)
|
||||||
if (tp->fd > 0) {
|
if (tp->fd >= 0) {
|
||||||
memmove(uh->raddr, tp->addr, sizeof tp->addr);
|
memmove(uh->raddr, tp->addr, sizeof tp->addr);
|
||||||
hnputs(uh->rport, 53); /* dns port */
|
hnputs(uh->rport, 53); /* dns port */
|
||||||
if (write(tp->fd, buf, len) != len) {
|
if (write(tp->fd, buf, len) != len) {
|
||||||
|
|
|
@ -516,7 +516,7 @@ cd(String *str)
|
||||||
if(chdir(s))
|
if(chdir(s))
|
||||||
syserror("chdir");
|
syserror("chdir");
|
||||||
fd = open("/dev/wdir", OWRITE);
|
fd = open("/dev/wdir", OWRITE);
|
||||||
if(fd > 0)
|
if(fd >= 0)
|
||||||
write(fd, s, strlen(s));
|
write(fd, s, strlen(s));
|
||||||
dprint("!\n");
|
dprint("!\n");
|
||||||
Strinit(&owd);
|
Strinit(&owd);
|
||||||
|
|
|
@ -670,7 +670,7 @@ hplumb(int nc)
|
||||||
s = alloc(nc);
|
s = alloc(nc);
|
||||||
for(i=0; i<nc; i++)
|
for(i=0; i<nc; i++)
|
||||||
s[i] = getch();
|
s[i] = getch();
|
||||||
if(plumbfd > 0){
|
if(plumbfd >= 0){
|
||||||
m = plumbunpack(s, nc);
|
m = plumbunpack(s, nc);
|
||||||
if(m != 0)
|
if(m != 0)
|
||||||
plumbsend(plumbfd, m);
|
plumbsend(plumbfd, m);
|
||||||
|
|
|
@ -151,7 +151,7 @@ openf(void)
|
||||||
|
|
||||||
Bflush(output);
|
Bflush(output);
|
||||||
Bterm(output);
|
Bterm(output);
|
||||||
if(fd > 0)
|
if(fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = create(name,OWRITE,0666);
|
fd = create(name,OWRITE,0666);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
|
|
|
@ -336,7 +336,7 @@ print2(int fd, int ofd, char *fmt, ...)
|
||||||
return -1;
|
return -1;
|
||||||
m = strlen(s);
|
m = strlen(s);
|
||||||
n = write(fd, s, m);
|
n = write(fd, s, m);
|
||||||
if(ofd > 0)
|
if(ofd >= 0)
|
||||||
write(ofd, s, m);
|
write(ofd, s, m);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ write2(int fd, int ofd, char *buf, int n, int nofrom)
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
m = write(fd, buf, n);
|
m = write(fd, buf, n);
|
||||||
|
|
||||||
if(ofd <= 0)
|
if(ofd < 0)
|
||||||
return m;
|
return m;
|
||||||
|
|
||||||
if(nofrom == 0)
|
if(nofrom == 0)
|
||||||
|
@ -463,7 +463,7 @@ mesgsend(Message *m)
|
||||||
}
|
}
|
||||||
|
|
||||||
ofd = open(outgoing, OWRITE|OCEXEC); /* no error check necessary */
|
ofd = open(outgoing, OWRITE|OCEXEC); /* no error check necessary */
|
||||||
if(ofd > 0){
|
if(ofd >= 0){
|
||||||
/* From dhog Fri Aug 24 22:13:00 EDT 2001 */
|
/* From dhog Fri Aug 24 22:13:00 EDT 2001 */
|
||||||
now = ctime(time(0));
|
now = ctime(time(0));
|
||||||
fprint(ofd, "From %s %s", user, now);
|
fprint(ofd, "From %s %s", user, now);
|
||||||
|
@ -537,14 +537,14 @@ mesgsend(Message *m)
|
||||||
write2(p[1], ofd, "\n", 1, 0);
|
write2(p[1], ofd, "\n", 1, 0);
|
||||||
|
|
||||||
/* these look like pseudo-attachments in the "outgoing" box */
|
/* these look like pseudo-attachments in the "outgoing" box */
|
||||||
if(ofd>0 && natt>0){
|
if(ofd>=0 && natt>0){
|
||||||
for(i=0; i<natt; i++)
|
for(i=0; i<natt; i++)
|
||||||
if(included[i])
|
if(included[i])
|
||||||
fprint(ofd, "=====> Include: %s\n", attlist[i]);
|
fprint(ofd, "=====> Include: %s\n", attlist[i]);
|
||||||
else
|
else
|
||||||
fprint(ofd, "=====> Attach: %s\n", attlist[i]);
|
fprint(ofd, "=====> Attach: %s\n", attlist[i]);
|
||||||
}
|
}
|
||||||
if(ofd > 0)
|
if(ofd >= 0)
|
||||||
write(ofd, "\n", 1);
|
write(ofd, "\n", 1);
|
||||||
|
|
||||||
for(i=0; i<natt; i++)
|
for(i=0; i<natt; i++)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue