We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37d07e4 commit 230e0cfCopy full SHA for 230e0cf
1 file changed
src/uu/logname/src/logname.rs
@@ -12,13 +12,11 @@ use uucore::translate;
12
use uucore::{error::UResult, show_error};
13
14
fn get_userlogin() -> Option<String> {
15
- unsafe {
16
- let login: *const libc::c_char = libc::getlogin();
17
- if login.is_null() {
18
- None
19
- } else {
20
- Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string())
21
- }
+ 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())
22
}
23
24
0 commit comments