ref: 84e019aba3dd233d817272cc62ca2a95a5263de7
parent: 292cce2ad127d30d29ca2824f7dd484620256ceb
author: BurnZeZ <devnull@localhost>
date: Sat Oct 20 14:44:09 EDT 2018
fix misleading/wrong fd checks
--- a/sys/src/ape/cmd/pax/pass.c
+++ b/sys/src/ape/cmd/pax/pass.c
@@ -153,7 +153,7 @@
if ((ofd = openout(to, asb, islink(to, asb), 1)) < 0) {
return (-1);
}
- if (ofd > 0) {
+ if (ofd >= 0) {
passdata(from, ifd, to, ofd);
}
tstamp[0] = asb->sb_atime;
--- a/sys/src/cmd/acme/xfid.c
+++ b/sys/src/cmd/acme/xfid.c
@@ -129,7 +129,7 @@
* though, we'd need to squirrel away the data in case it's
* modified during the operation, e.g. by |sort
*/
- if(w->rdselfd > 0){
+ if(w->rdselfd >= 0){
winunlock(w);
respond(x, &fc, Einuse);
return;
--- a/sys/src/cmd/cpu.c
+++ b/sys/src/cmd/cpu.c
@@ -127,7 +127,7 @@
origargs = procgetname();
/* see if we should use a larger message size */
fd = open("/dev/draw", OREAD);
- if(fd > 0){
+ if(fd >= 0){
ms = iounit(fd);
if(msgsize < ms+IOHDRSZ)
msgsize = ms+IOHDRSZ;
--- a/sys/src/cmd/ip/ftpfs/file.c
+++ b/sys/src/cmd/ip/ftpfs/file.c
@@ -77,7 +77,7 @@
if(fp == 0)
return;
- if(fp->fd > 0){
+ if(fp->fd >= 0){
ntmp--;
close(fp->fd);
remove(fp->template);
--- a/sys/src/cmd/ip/httpd/log.c
+++ b/sys/src/cmd/ip/httpd/log.c
@@ -52,7 +52,7 @@
/* verbose logfile, for research on web traffic */
logfd = logall[today & 1];
- if(logfd > 0){
+ if(logfd >= 0){
if(c->hstop == c->header || c->hstop[-1] != '\n')
*c->hstop = '\n';
*c->hstop = '\0';
--- a/sys/src/cmd/ip/httpd/man2html.c
+++ b/sys/src/cmd/ip/httpd/man2html.c
@@ -55,7 +55,7 @@
snprint(file, sizeof(file), "/sys/man/%d/INDEX", section);
fd = open(file, OREAD);
- if(fd > 0){
+ if(fd >= 0){
Binit(&b, fd, OREAD);
for(;;){
p = Brdline(&b, '\n');
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -2758,7 +2758,7 @@
snprint(buf, sizeof buf, "%sctl", dev);
cfd = open(buf, ORDWR);
}
- if(cfd > 0){
+ if(cfd >= 0){
if(baud)
fprint(cfd, "b%d", baud);
fprint(cfd, "m1"); /* cts/rts flow control (and fifo's) on */
--- a/sys/src/cmd/ndb/dnudpserver.c
+++ b/sys/src/cmd/ndb/dnudpserver.c
@@ -110,7 +110,7 @@
uh = (Udphdr *)buf;
for (tp = forwtarg; tp < forwtarg + forwtcount; tp++)
- if (tp->fd > 0) {
+ if (tp->fd >= 0) {
memmove(uh->raddr, tp->addr, sizeof tp->addr);
hnputs(uh->rport, 53); /* dns port */
if (write(tp->fd, buf, len) != len) {
--- a/sys/src/cmd/sam/sam.c
+++ b/sys/src/cmd/sam/sam.c
@@ -516,7 +516,7 @@
if(chdir(s))
syserror("chdir");
fd = open("/dev/wdir", OWRITE);
- if(fd > 0)
+ if(fd >= 0)
write(fd, s, strlen(s));
dprint("!\n");
Strinit(&owd);
--- a/sys/src/cmd/samterm/mesg.c
+++ b/sys/src/cmd/samterm/mesg.c
@@ -670,7 +670,7 @@
s = alloc(nc);
for(i=0; i<nc; i++)
s[i] = getch();
- if(plumbfd > 0){
+ if(plumbfd >= 0){
m = plumbunpack(s, nc);
if(m != 0)
plumbsend(plumbfd, m);
--- a/sys/src/cmd/split.c
+++ b/sys/src/cmd/split.c
@@ -151,7 +151,7 @@
Bflush(output);
Bterm(output);
- if(fd > 0)
+ if(fd >= 0)
close(fd);
fd = create(name,OWRITE,0666);
if(fd < 0) {
--- a/sys/src/cmd/upas/Mail/reply.c
+++ b/sys/src/cmd/upas/Mail/reply.c
@@ -336,7 +336,7 @@
return -1;
m = strlen(s);
n = write(fd, s, m);
- if(ofd > 0)
+ if(ofd >= 0)
write(ofd, s, m);
return n;
}
@@ -350,7 +350,7 @@
if(fd >= 0)
m = write(fd, buf, n);
- if(ofd <= 0)
+ if(ofd < 0)
return m;
if(nofrom == 0)
@@ -463,7 +463,7 @@
}
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 */
now = ctime(time(0));
fprint(ofd, "From %s %s", user, now);
@@ -537,7 +537,7 @@
write2(p[1], ofd, "\n", 1, 0);
/* 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++)
if(included[i])
fprint(ofd, "=====> Include: %s\n", attlist[i]);
@@ -544,7 +544,7 @@
else
fprint(ofd, "=====> Attach: %s\n", attlist[i]);
}
- if(ofd > 0)
+ if(ofd >= 0)
write(ofd, "\n", 1);
for(i=0; i<natt; i++)