Make lucio happier Reference: /n/patches.lsub.org/patch/fdzero Date: Thu Apr 26 17:08:54 CES 2012 Signed-off-by: paurea@lsub.org --- /sys/src/cmd/aux/gps/gpsfs.c Thu Apr 12 12:25:24 2012 +++ /sys/src/cmd/aux/gps/gpsfs.c Mon Apr 23 09:26:35 2012 @@ -573,12 +573,12 @@ void rtcset(long t) { - static int fd; + static int fd = -1; long r; int n; char buf[32]; - if(fd <= 0 && (fd = open("#r/rtc", ORDWR)) < 0){ + if(fd < 0 && (fd = open("#r/rtc", ORDWR)) < 0){ fprint(2, "Can't open #r/rtc: %r\n"); return; } --- /sys/src/cmd/aux/gps/util.c Thu Apr 12 12:25:24 2012 +++ /sys/src/cmd/aux/gps/util.c Mon Apr 23 09:26:49 2012 @@ -145,12 +145,12 @@ static void rtcset(long t) /* We may use this some day */ { - static int fd; + static int fd = -1; long r; int n; char buf[32]; - if(fd <= 0 && (fd = open("#r/rtc", ORDWR)) < 0){ + if(fd < 0 && (fd = open("#r/rtc", ORDWR)) < 0){ fprint(2, "Can't open #r/rtc: %r\n"); return; } --- /sys/src/cmd/ndb/dnresolve.c Thu Apr 12 12:25:55 2012 +++ /sys/src/cmd/ndb/dnresolve.c Mon Apr 23 09:28:57 2012 @@ -666,7 +666,7 @@ memset(srcip, 0, IPaddrlen); alarm(ms); if (medium == Udp) - if (qp->udpfd <= 0) + if (qp->udpfd < 0) dnslog("readnet: qp->udpfd closed"); else { len = read(qp->udpfd, ibuf, Udphdrsize+Maxudpin); @@ -683,7 +683,7 @@ if (!qp->tcpset) dnslog("readnet: tcp params not set"); fd = qp->tcpfd; - if (fd <= 0) + if (fd < 0) dnslog("readnet: %s: tcp fd unset for dest %I", qp->dp->name, qp->tcpip); else if (readn(fd, lenbuf, 2) != 2) { @@ -1003,7 +1003,7 @@ } close(nfd); - if (qp->udpfd <= 0) + if (qp->udpfd < 0) dnslog("mydnsquery: qp->udpfd %d closed", qp->udpfd); else { if (write(qp->udpfd, udppkt, len+Udphdrsize) != --- /sys/src/cmd/sam/mesg.c Thu Apr 12 12:26:00 2012 +++ /sys/src/cmd/sam/mesg.c Mon Apr 23 09:29:58 2012 @@ -86,9 +86,9 @@ void journal(int out, char *s) { - static int fd = 0; + static int fd = -1; - if(fd <= 0) + if(fd < 0) fd = create("/tmp/sam.out", 1, 0666L); fprint(fd, "%s%s\n", out? "out: " : "in: ", s); } --- /sys/src/games/blabs/blabs.c Thu Apr 12 12:26:11 2012 +++ /sys/src/games/blabs/blabs.c Thu Apr 26 16:15:18 2012 @@ -721,20 +721,7 @@ int msec(void) { - static int fd; - int n; - char buf[64]; - - if(fd <= 0) - fd = open("/dev/msec", OREAD); - if(fd < 0) - return 0; - if(seek(fd, 0, 0) < 0) - return 0; - if((n=read(fd, buf, sizeof(buf)-1)) < 0) - return 0; - buf[n] = 0; - return atoi(buf); + return (nsec()+500000)/1000000; } /* --- /sys/src/games/blabs/mkfile Thu Apr 12 12:26:11 2012 +++ /sys/src/games/blabs/mkfile Thu Apr 26 15:57:44 2012 @@ -23,7 +23,7 @@ $who.bits -