about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-10 21:59:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-10 22:09:49 -0700
commitdae48a07f34dcf714b3b57029f4e03a0b95a269e (patch)
tree4ced3fe4c6c167508f0f7d1308473dfec676846d /src/libstd/io
parent1add4dedc131d5f98d82feafe80d92ed1f3f6d49 (diff)
downloadrust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.tar.gz
rust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.zip
Register new snapshots
Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/tempfile.rs4
-rw-r--r--src/libstd/io/test.rs10
2 files changed, 6 insertions, 8 deletions
diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs
index 1d8aedb172b..e9d6ef2e341 100644
--- a/src/libstd/io/tempfile.rs
+++ b/src/libstd/io/tempfile.rs
@@ -38,14 +38,14 @@ impl TempDir {
             return TempDir::new_in(&os::make_absolute(tmpdir), suffix);
         }
 
-        static mut CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+        static CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
 
         let mut attempts = 0u;
         loop {
             let filename =
                 format!("rs-{}-{}-{}",
                         unsafe { libc::getpid() },
-                        unsafe { CNT.fetch_add(1, atomic::SeqCst) },
+                        CNT.fetch_add(1, atomic::SeqCst),
                         suffix);
             let p = tmpdir.join(filename);
             match fs::mkdir(&p, io::USER_RWX) {
diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs
index 1a47e20f585..9b4333a6d82 100644
--- a/src/libstd/io/test.rs
+++ b/src/libstd/io/test.rs
@@ -20,22 +20,20 @@ use sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
 
 /// Get a port number, starting at 9600, for use in tests
 pub fn next_test_port() -> u16 {
-    static mut next_offset: AtomicUint = INIT_ATOMIC_UINT;
-    unsafe {
-        base_port() + next_offset.fetch_add(1, Relaxed) as u16
-    }
+    static NEXT_OFFSET: AtomicUint = INIT_ATOMIC_UINT;
+    base_port() + NEXT_OFFSET.fetch_add(1, Relaxed) as u16
 }
 
 /// Get a temporary path which could be the location of a unix socket
 pub fn next_test_unix() -> Path {
-    static mut COUNT: AtomicUint = INIT_ATOMIC_UINT;
+    static COUNT: AtomicUint = INIT_ATOMIC_UINT;
     // base port and pid are an attempt to be unique between multiple
     // test-runners of different configurations running on one
     // buildbot, the count is to be unique within this executable.
     let string = format!("rust-test-unix-path-{}-{}-{}",
                          base_port(),
                          unsafe {libc::getpid()},
-                         unsafe {COUNT.fetch_add(1, Relaxed)});
+                         COUNT.fetch_add(1, Relaxed));
     if cfg!(unix) {
         os::tmpdir().join(string)
     } else {