* patch: fd check fixes
@ 2018-10-18 18:54 BurnZeZ
0 siblings, 0 replies; only message in thread
From: BurnZeZ @ 2018-10-18 18:54 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 62 bytes --]
Some stuff seems to have wrong fd checks, so here’s a diff.
[-- Attachment #2: fd.diff --]
[-- Type: text/plain, Size: 5293 bytes --]
diff -r 4c1c90cb3a47 sys/src/ape/cmd/pax/pass.c
--- a/sys/src/ape/cmd/pax/pass.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/ape/cmd/pax/pass.c Wed Oct 17 19:37:32 2018 +0000
@@ -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;
diff -r 4c1c90cb3a47 sys/src/cmd/acme/xfid.c
--- a/sys/src/cmd/acme/xfid.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/acme/xfid.c Wed Oct 17 19:37:32 2018 +0000
@@ -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;
diff -r 4c1c90cb3a47 sys/src/cmd/cpu.c
--- a/sys/src/cmd/cpu.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/cpu.c Wed Oct 17 19:37:32 2018 +0000
@@ -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;
diff -r 4c1c90cb3a47 sys/src/cmd/ip/ftpfs/file.c
--- a/sys/src/cmd/ip/ftpfs/file.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/ip/ftpfs/file.c Wed Oct 17 19:37:32 2018 +0000
@@ -77,7 +77,7 @@
if(fp == 0)
return;
- if(fp->fd > 0){
+ if(fp->fd >= 0){
ntmp--;
close(fp->fd);
remove(fp->template);
diff -r 4c1c90cb3a47 sys/src/cmd/ip/httpd/log.c
--- a/sys/src/cmd/ip/httpd/log.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/ip/httpd/log.c Wed Oct 17 19:37:32 2018 +0000
@@ -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';
diff -r 4c1c90cb3a47 sys/src/cmd/ip/httpd/man2html.c
--- a/sys/src/cmd/ip/httpd/man2html.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/ip/httpd/man2html.c Wed Oct 17 19:37:32 2018 +0000
@@ -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');
diff -r 4c1c90cb3a47 sys/src/cmd/ip/ppp/ppp.c
--- a/sys/src/cmd/ip/ppp/ppp.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/ip/ppp/ppp.c Wed Oct 17 19:37:32 2018 +0000
@@ -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 */
diff -r 4c1c90cb3a47 sys/src/cmd/ndb/dnudpserver.c
--- a/sys/src/cmd/ndb/dnudpserver.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/ndb/dnudpserver.c Wed Oct 17 19:37:32 2018 +0000
@@ -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) {
diff -r 4c1c90cb3a47 sys/src/cmd/sam/sam.c
--- a/sys/src/cmd/sam/sam.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/sam/sam.c Wed Oct 17 19:37:32 2018 +0000
@@ -516,7 +519,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);
diff -r 4c1c90cb3a47 sys/src/cmd/samterm/mesg.c
--- a/sys/src/cmd/samterm/mesg.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/samterm/mesg.c Wed Oct 17 19:37:32 2018 +0000
@@ -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);
diff -r 4c1c90cb3a47 sys/src/cmd/split.c
--- a/sys/src/cmd/split.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/split.c Wed Oct 17 19:37:32 2018 +0000
@@ -151,7 +179,7 @@
Bflush(output);
Bterm(output);
- if(fd > 0)
+ if(fd >= 0)
close(fd);
fd = create(name,OWRITE,0666);
if(fd < 0) {
diff -r 4c1c90cb3a47 sys/src/cmd/upas/Mail/reply.c
--- a/sys/src/cmd/upas/Mail/reply.c Tue Oct 16 12:53:55 2018 -0700
+++ b/sys/src/cmd/upas/Mail/reply.c Wed Oct 17 19:37:32 2018 +0000
@@ -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,14 +537,14 @@
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]);
else
fprint(ofd, "=====> Attach: %s\n", attlist[i]);
}
- if(ofd > 0)
+ if(ofd >= 0)
write(ofd, "\n", 1);
for(i=0; i<natt; i++)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-18 18:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18 18:54 patch: fd check fixes BurnZeZ
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).