about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2016-06-24 20:54:52 +0200
committerTobias Bucher <tobiasbucher5991@gmail.com>2016-07-12 10:40:40 +0200
commit81e95c18b7d4c45c7ef41b231af4ecd40543567d (patch)
treeced85ac151c5d6c0a892fc063906a232b3b49ea3 /src/libstd/sys/unix
parent2539c15b49530e882a3e8803b3f53a7914d367be (diff)
downloadrust-81e95c18b7d4c45c7ef41b231af4ecd40543567d.tar.gz
rust-81e95c18b7d4c45c7ef41b231af4ecd40543567d.zip
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/os.rs6
-rw-r--r--src/libstd/sys/unix/pipe.rs5
-rw-r--r--src/libstd/sys/unix/process.rs10
-rw-r--r--src/libstd/sys/unix/time.rs6
4 files changed, 15 insertions, 12 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 21ce6b19ceb..5f7588de776 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -227,11 +227,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
                        libc::KERN_PROC_ARGV];
         let mib = mib.as_mut_ptr();
         let mut argv_len = 0;
-        cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len,
-                         0 as *mut _, 0))?;
+        cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_len,
+                         ptr::null_mut(), 0))?;
         let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize);
         cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _,
-                         &mut argv_len, 0 as *mut _, 0))?;
+                         &mut argv_len, ptr::null_mut(), 0))?;
         argv.set_len(argv_len as usize);
         if argv[0].is_null() {
             return Err(io::Error::new(io::ErrorKind::Other,
diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs
index 2dde9c0e615..01059413338 100644
--- a/src/libstd/sys/unix/pipe.rs
+++ b/src/libstd/sys/unix/pipe.rs
@@ -14,6 +14,7 @@ use cmp;
 use io;
 use libc::{self, c_int};
 use mem;
+use ptr;
 use sys::cvt_r;
 use sys::fd::FileDesc;
 
@@ -92,8 +93,8 @@ pub fn read2(p1: AnonPipe,
             let mut read: libc::fd_set = mem::zeroed();
             libc::FD_SET(p1.raw(), &mut read);
             libc::FD_SET(p2.raw(), &mut read);
-            libc::select(max + 1, &mut read, 0 as *mut _, 0 as *mut _,
-                         0 as *mut _)
+            libc::select(max + 1, &mut read, ptr::null_mut(), ptr::null_mut(),
+                         ptr::null_mut())
         })?;
 
         // Read as much as we can from each pipe, ignoring EWOULDBLOCK or
diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs
index 98cfdcdf110..d68867fb3d2 100644
--- a/src/libstd/sys/unix/process.rs
+++ b/src/libstd/sys/unix/process.rs
@@ -96,7 +96,7 @@ impl Command {
         let mut saw_nul = false;
         let program = os2c(program, &mut saw_nul);
         Command {
-            argv: vec![program.as_ptr(), 0 as *const _],
+            argv: vec![program.as_ptr(), ptr::null()],
             program: program,
             args: Vec::new(),
             env: None,
@@ -117,7 +117,7 @@ impl Command {
         // pointer.
         let arg = os2c(arg, &mut self.saw_nul);
         self.argv[self.args.len() + 1] = arg.as_ptr();
-        self.argv.push(0 as *const _);
+        self.argv.push(ptr::null());
 
         // Also make sure we keep track of the owned value to schedule a
         // destructor for this memory.
@@ -134,7 +134,7 @@ impl Command {
                 envp.push(s.as_ptr());
                 map.insert(k, (envp.len() - 1, s));
             }
-            envp.push(0 as *const _);
+            envp.push(ptr::null());
             self.env = Some(map);
             self.envp = Some(envp);
         }
@@ -158,7 +158,7 @@ impl Command {
             Entry::Vacant(e) => {
                 let len = envp.len();
                 envp[len - 1] = new_key.as_ptr();
-                envp.push(0 as *const _);
+                envp.push(ptr::null());
                 e.insert((len - 1, new_key));
             }
         }
@@ -183,7 +183,7 @@ impl Command {
 
     pub fn env_clear(&mut self) {
         self.env = Some(HashMap::new());
-        self.envp = Some(vec![0 as *const _]);
+        self.envp = Some(vec![ptr::null()]);
     }
 
     pub fn cwd(&mut self, dir: &OsStr) {
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs
index 68eebba9e7b..a08cec38f73 100644
--- a/src/libstd/sys/unix/time.rs
+++ b/src/libstd/sys/unix/time.rs
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 use cmp::Ordering;
-use time::Duration;
 use libc;
+use time::Duration;
 
 pub use self::inner::{Instant, SystemTime, UNIX_EPOCH};
 
@@ -164,12 +164,14 @@ mod inner {
 
     impl SystemTime {
         pub fn now() -> SystemTime {
+            use ptr;
+
             let mut s = libc::timeval {
                 tv_sec: 0,
                 tv_usec: 0,
             };
             cvt(unsafe {
-                libc::gettimeofday(&mut s, 0 as *mut _)
+                libc::gettimeofday(&mut s, ptr::null_mut())
             }).unwrap();
             return SystemTime::from(s)
         }