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.
This commit is contained in:
Roy Ivy III 2020-11-07 20:12:35 -06:00
parent 3dc9f76c7f
commit 2b4b31a9ee

View file

@ -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());