From a2cd4b647c1058c3012348774481ade30dddd601 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Sun, 15 Jan 2017 16:39:22 -0800 Subject: Cleanup getpwuid_r wrapper The wrapper had some transmutes still from an earlier implementation, and they are not needed now. --- src/tty.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tty.rs b/src/tty.rs index ad89397d..c9feae36 100644 --- a/src/tty.rs +++ b/src/tty.rs @@ -17,7 +17,6 @@ use std::env; use std::ffi::CStr; use std::fs::File; -use std::mem; use std::os::unix::io::FromRawFd; use std::ptr; @@ -192,13 +191,13 @@ fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd { // Transmute is used here to conveniently cast from the raw CStr to a &str with the appropriate // lifetime. Passwd { - name: unsafe { mem::transmute(CStr::from_ptr(entry.pw_name).to_str().unwrap()) }, - passwd: unsafe { mem::transmute(CStr::from_ptr(entry.pw_passwd).to_str().unwrap()) }, + name: unsafe { CStr::from_ptr(entry.pw_name).to_str().unwrap() }, + passwd: unsafe { CStr::from_ptr(entry.pw_passwd).to_str().unwrap() }, uid: entry.pw_uid, gid: entry.pw_gid, - gecos: unsafe { mem::transmute(CStr::from_ptr(entry.pw_gecos).to_str().unwrap()) }, - dir: unsafe { mem::transmute(CStr::from_ptr(entry.pw_dir).to_str().unwrap()) }, - shell: unsafe { mem::transmute(CStr::from_ptr(entry.pw_shell).to_str().unwrap()) }, + gecos: unsafe { CStr::from_ptr(entry.pw_gecos).to_str().unwrap() }, + dir: unsafe { CStr::from_ptr(entry.pw_dir).to_str().unwrap() }, + shell: unsafe { CStr::from_ptr(entry.pw_shell).to_str().unwrap() }, } } -- cgit