rx-trace-check-correctly-for-file-descriptor-validity-20011009
authorNickolai Zeldovich <kolya@mit.edu>
Wed, 10 Oct 2001 00:59:46 +0000 (00:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 10 Oct 2001 00:59:46 +0000 (00:59 +0000)
file descriptor numbered 0 is valid

src/rx/rx_trace.c

index 05f0589..f388520 100644 (file)
@@ -36,7 +36,7 @@ char rxi_tracename[80]="/tmp/rxcalltrace";
 #else
 char rxi_tracename[80]="\0Change This pathname (and preceding NUL) to initiate tracing";
 #endif
-int rxi_logfd = 0;
+int rxi_logfd = -1;
 char rxi_tracebuf[4096];
 afs_uint32 rxi_tracepos = 0;
 
@@ -52,7 +52,7 @@ struct rx_trace {
 
 void rxi_flushtrace()
 {
-    if (rxi_logfd)
+    if (rxi_logfd >= 0)
        write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
     rxi_tracepos = 0;
 }
@@ -67,9 +67,9 @@ void rxi_calltrace(event, call)
   if (!rxi_tracename[0])
     return;
 
-  if (!rxi_logfd) {
+  if (rxi_logfd < 0) {
     rxi_logfd = open(rxi_tracename, O_WRONLY | O_CREAT | O_TRUNC, 0777);
-    if (!rxi_logfd)
+    if (rxi_logfd < 0)
       rxi_tracename[0] = '\0';
   }
   clock_GetTime(&now);
@@ -153,7 +153,7 @@ char **argv;
   }
 
   rxi_logfd = open(rxi_tracename, O_RDONLY);
-  if (!rxi_logfd) {
+  if (rxi_logfd < 0) {
     perror("");
     exit(errno);
   }