Skip to content

Commit 286ae72

Browse files
Clean code a bit
1 parent 1194695 commit 286ae72

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/libstd/sys/unix/os.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -584,18 +584,15 @@ pub fn home_dir() -> Option<PathBuf> {
584584
n if n < 0 => 512 as usize,
585585
n => n as usize,
586586
};
587-
let me = libc::getuid();
588-
loop {
589-
let mut buf = Vec::with_capacity(amt);
590-
let mut passwd: libc::passwd = mem::zeroed();
591-
592-
if getpwduid_r(me, &mut passwd, &mut buf).is_some() {
593-
let ptr = passwd.pw_dir as *const _;
594-
let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
595-
return Some(OsStringExt::from_vec(bytes))
596-
} else {
597-
return None;
598-
}
587+
let mut buf = Vec::with_capacity(amt);
588+
let mut passwd: libc::passwd = mem::zeroed();
589+
590+
if getpwduid_r(libc::getuid(), &mut passwd, &mut buf).is_some() {
591+
let ptr = passwd.pw_dir as *const _;
592+
let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
593+
Some(OsStringExt::from_vec(bytes))
594+
} else {
595+
None
599596
}
600597
}
601598
}

0 commit comments

Comments
 (0)