]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/sys/unix/process.rs
Replace `0 as *const/mut T` with `ptr::null/null_mut()`
[rust.git] / src / libstd / sys / unix / process.rs
index 5bc6b0c703b1c9c90057820cb37f2880bec164aa..0eab27de43a9f08e995a56e4ad25d555f670d127 100644 (file)
@@ -11,7 +11,8 @@
 use prelude::v1::*;
 use self::Req::*;
 
-use collections;
+use collections::HashMap;
+use collections::hash_map::Hasher;
 use ffi::CString;
 use hash::Hash;
 use io::process::{ProcessExit, ExitStatus, ExitSignal};
@@ -60,7 +61,7 @@ pub fn spawn<K, V, C, P>(cfg: &C, in_fd: Option<P>,
                               out_fd: Option<P>, err_fd: Option<P>)
                               -> IoResult<Process>
         where C: ProcessConfig<K, V>, P: AsInner<FileDesc>,
-              K: BytesContainer + Eq + Hash, V: BytesContainer
+              K: BytesContainer + Eq + Hash<Hasher>, V: BytesContainer
     {
         use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
         use libc::funcs::bsd44::getdtablesize;
@@ -125,7 +126,7 @@ fn combine(arr: &[u8]) -> i32 {
                     return match input.read(&mut bytes) {
                         Ok(8) => {
                             assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
-                                "Validation on the CLOEXEC pipe failed: {}", bytes);
+                                "Validation on the CLOEXEC pipe failed: {:?}", bytes);
                             let errno = combine(bytes.slice(0, 4));
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
                             Err(super::decode_error(errno))
@@ -133,7 +134,7 @@ fn combine(arr: &[u8]) -> i32 {
                         Err(ref e) if e.kind == EndOfFile => Ok(p),
                         Err(e) => {
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
-                            panic!("the CLOEXEC pipe failed: {}", e)
+                            panic!("the CLOEXEC pipe failed: {:?}", e)
                         },
                         Ok(..) => { // pipe I/O up to PIPE_BUF bytes should be atomic
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
@@ -250,7 +251,7 @@ fn fail(output: &mut FileDesc) -> ! {
                             fn setgroups(ngroups: libc::c_int,
                                          ptr: *const libc::c_void) -> libc::c_int;
                         }
-                        let _ = setgroups(0, 0 as *const libc::c_void);
+                        let _ = setgroups(0, ptr::null());
 
                         if libc::setuid(u as libc::uid_t) != 0 {
                             fail(&mut output);
@@ -285,7 +286,7 @@ pub fn wait(&self, deadline: u64) -> IoResult<ProcessExit> {
         let mut status = 0 as c_int;
         if deadline == 0 {
             return match retry(|| unsafe { c::waitpid(self.pid, &mut status, 0) }) {
-                -1 => panic!("unknown waitpid error: {}", super::last_error()),
+                -1 => panic!("unknown waitpid error: {:?}", super::last_error()),
                 _ => Ok(translate_status(status)),
             }
         }
@@ -410,7 +411,7 @@ fn waitpid_helper(input: libc::c_int,
                         continue
                     }
 
-                    n => panic!("error in select {} ({})", os::errno(), n),
+                    n => panic!("error in select {:?} ({:?})", os::errno(), n),
                 }
 
                 // Process any pending messages
@@ -491,7 +492,7 @@ fn drain(fd: libc::c_int) -> bool {
                     n if n > 0 => { ret = true; }
                     0 => return true,
                     -1 if wouldblock() => return ret,
-                    n => panic!("bad read {} ({})", os::last_os_error(), n),
+                    n => panic!("bad read {:?} ({:?})", os::last_os_error(), n),
                 }
             }
         }
@@ -514,7 +515,7 @@ fn drain(fd: libc::c_int) -> bool {
             } {
                 1 => {}
                 -1 if wouldblock() => {} // see above comments
-                n => panic!("bad error on write fd: {} {}", n, os::errno()),
+                n => panic!("bad error on write fd: {:?} {:?}", n, os::errno()),
             }
         }
     }
@@ -526,7 +527,7 @@ pub fn try_wait(&self) -> Option<ProcessExit> {
         }) {
             n if n == self.pid => Some(translate_status(status)),
             0 => None,
-            n => panic!("unknown waitpid error `{}`: {}", n,
+            n => panic!("unknown waitpid error `{:?}`: {:?}", n,
                        super::last_error()),
         }
     }
@@ -553,11 +554,11 @@ fn with_argv<T,F>(prog: &CString, args: &[CString],
     cb(ptrs.as_ptr())
 }
 
-fn with_envp<K,V,T,F>(env: Option<&collections::HashMap<K, V>>,
+fn with_envp<K,V,T,F>(env: Option<&HashMap<K, V>>,
                       cb: F)
                       -> T
     where F : FnOnce(*const c_void) -> T,
-          K : BytesContainer + Eq + Hash,
+          K : BytesContainer + Eq + Hash<Hasher>,
           V : BytesContainer
 {
     // On posixy systems we can pass a char** for envp, which is a