clang-10: use AFS_FALLTHROUGH for case fallthrough
[openafs.git] / src / rx / rx_trace.c
index 37b85d6..512491e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
+#include <roken.h>
 
-#ifdef RXDEBUG
-#include <string.h>
-#ifdef AFS_NT40_ENV
-#include <fcntl.h>
-#include <io.h>
-#else
-#include <sys/file.h>
-#include <unistd.h>
+#ifndef RXDEBUG
+char rxi_tracename[80] = "\0Tracing not compiled in";
+#ifdef DUMPTRACE
+int
+main(int argc, char **argv)
+{
+    return 0;
+}
 #endif
+#else
+
 #include "rx.h"
+#include "rx_atomic.h"
 #include "rx_globals.h"
+#include "rx_internal.h"
 #include "rx_trace.h"
 
+#include "rx_conn.h"
+#include "rx_call.h"
+
 #ifdef RXTRACEON
 char rxi_tracename[80] = "/tmp/rxcalltrace";
 #else
@@ -47,17 +53,20 @@ struct rx_trace {
 };
 
 void
-rxi_flushtrace()
+rxi_flushtrace(void)
 {
-    if (rxi_logfd >= 0)
-       write(rxi_logfd, rxi_tracebuf, rxi_tracepos);
+    afs_uint32 len = rxi_tracepos;
+
     rxi_tracepos = 0;
+    if (rxi_logfd < 0)
+       return;
+    if (write(rxi_logfd, rxi_tracebuf, len) < 0) {
+       /* don't care */
+    }
 }
 
 void
-rxi_calltrace(event, call)
-     unsigned int event;
-     struct rx_call *call;
+rxi_calltrace(unsigned int event, struct rx_call *call)
 {
     struct clock now;
     struct rx_trace rxtinfo;
@@ -76,7 +85,7 @@ rxi_calltrace(event, call)
     rxtinfo.now = now.sec * 1000 + now.usec / 1000;
     rxtinfo.cid = call->conn->cid;
     rxtinfo.call = *(call->callNumber);
-    rxtinfo.qlen = rx_nWaiting;
+    rxtinfo.qlen = rx_atomic_read(&rx_nWaiting);
     rxtinfo.servicetime = 0;
     rxtinfo.waittime = 0;
 
@@ -113,6 +122,8 @@ rxi_calltrace(event, call)
 
     case RX_CALL_ARRIVAL:
        call->traceWait = now;
+       break;
+
     default:
        break;
     }
@@ -124,14 +135,12 @@ rxi_calltrace(event, call)
 }
 
 #ifdef DUMPTRACE
-#include <errno.h>
 #ifdef AFS_NT40_ENV
 #include <afs/afsutil.h>
 #endif
 
 int
-main(argc, argv)
-     char **argv;
+main(int argc, char **argv)
 {
     struct rx_trace ip;
     int err = 0;
@@ -186,5 +195,4 @@ main(argc, argv)
 }
 
 #endif /* DUMPTRACE */
-
-#endif
+#endif /* RXDEBUG */