about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-08 07:20:51 -0700
committerGitHub <noreply@github.com>2016-09-08 07:20:51 -0700
commitc615b215331d2715cc2eed31b98f41393242f39d (patch)
tree0aa8c6f39eedc2d8f923bd03a6685216ff7877ca /src/libstd/sys
parent0b02ae02bbcae5e48da810fec24ae5d3d947115c (diff)
parent286ae72fb7954ee51a6f4a1aeacbed6be4e6f37e (diff)
downloadrust-c615b215331d2715cc2eed31b98f41393242f39d.tar.gz
rust-c615b215331d2715cc2eed31b98f41393242f39d.zip
Auto merge of #36048 - GuillaumeGomez:code_clean, r=brson
Clean code a bit
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/os.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index e61804efd50..82606d2c728 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -584,18 +584,15 @@ pub fn home_dir() -> Option<PathBuf> {
             n if n < 0 => 512 as usize,
             n => n as usize,
         };
-        let me = libc::getuid();
-        loop {
-            let mut buf = Vec::with_capacity(amt);
-            let mut passwd: libc::passwd = mem::zeroed();
-
-            if getpwduid_r(me, &mut passwd, &mut buf).is_some() {
-                let ptr = passwd.pw_dir as *const _;
-                let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
-                return Some(OsStringExt::from_vec(bytes))
-            } else {
-                return None;
-            }
+        let mut buf = Vec::with_capacity(amt);
+        let mut passwd: libc::passwd = mem::zeroed();
+
+        if getpwduid_r(libc::getuid(), &mut passwd, &mut buf).is_some() {
+            let ptr = passwd.pw_dir as *const _;
+            let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
+            Some(OsStringExt::from_vec(bytes))
+        } else {
+            None
         }
     }
 }