From 2b4b31a9eec2c03805703a54e4510f79c35882ed Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 7 Nov 2020 20:12:35 -0600 Subject: [PATCH] uucore/refactor ~ fix `cargo clippy` complaints (*allow* temporary_cstring_as_ptr; added FixME note) * otherwise, unsure how to fix this; the following change ```rust let res = unsafe { utmpxname(CString::new(f).unwrap().as_ptr()) }; ``` to ```rust let string_ptr = CString::new(f).unwrap().as_ptr(); let res = unsafe { utmpxname(string_ptr) }; ``` causes three `who` tests (test_who::test_all, test_who::test_boot, and test_who::test_login) to fail by generating no output. --- src/uucore/src/lib/features/utmpx.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 4a101e22c..ab3de65fa 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -242,6 +242,8 @@ impl UtmpxIter { /// /// If not set, default record file will be used(file path depends on the target OS) pub fn read_from(self, f: &str) -> Self { + // FixME: discuss and revise a rewrite which is correct and satisfies clippy/rustc + #[allow(clippy::temporary_cstring_as_ptr)] let res = unsafe { utmpxname(CString::new(f).unwrap().as_ptr()) }; if res != 0 { println!("Warning: {}", IOError::last_os_error());