mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
logname: reduce range of unsafe block
This commit is contained in:
@@ -12,13 +12,11 @@ use uucore::translate;
|
||||
use uucore::{error::UResult, show_error};
|
||||
|
||||
fn get_userlogin() -> Option<String> {
|
||||
unsafe {
|
||||
let login: *const libc::c_char = libc::getlogin();
|
||||
if login.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string())
|
||||
}
|
||||
let login_ptr = unsafe { libc::getlogin() };
|
||||
if login_ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(String::from_utf8_lossy(unsafe { CStr::from_ptr(login_ptr) }.to_bytes()).to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user