Skip to content

Commit

Permalink
Run clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars T Hansen committed Apr 5, 2024
1 parent c5e3d9c commit d09ff81
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ extern "C" fn sonar_signal_handler(_: libc::c_int) {
pub fn handle_interruptions() {
unsafe {
let nomask : libc::sigset_t = std::mem::zeroed();
let mut action = libc::sigaction {
let action = libc::sigaction {
sa_sigaction: sonar_signal_handler as usize,
sa_mask: nomask,
sa_flags: 0,
sa_restorer: None,
};
libc::sigaction(libc::SIGTERM, &mut action, std::ptr::null_mut());
libc::sigaction(libc::SIGHUP, &mut action, std::ptr::null_mut());
libc::sigaction(libc::SIGTERM, &action, std::ptr::null_mut());
libc::sigaction(libc::SIGHUP, &action, std::ptr::null_mut());
}
}

Expand Down
14 changes: 6 additions & 8 deletions src/procfsapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ impl ProcfsAPI for RealFS {
fn read_proc_pids(&self) -> Result<Vec<(usize, u32)>, String> {
let mut pids = vec![];
if let Ok(dir) = fs::read_dir("/proc") {
for dirent in dir {
if let Ok(dirent) = dirent {
if let Ok(meta) = dirent.metadata() {
let uid = meta.st_uid();
if let Some(name) = dirent.path().file_name() {
if let Ok(pid) = name.to_string_lossy().parse::<usize>() {
pids.push((pid, uid));
}
for dirent in dir.flatten() {
if let Ok(meta) = dirent.metadata() {
let uid = meta.st_uid();
if let Some(name) = dirent.path().file_name() {
if let Ok(pid) = name.to_string_lossy().parse::<usize>() {
pids.push((pid, uid));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ fn print_record(
}
s += "\n";

writer.write(s.as_bytes())?;
let _ = writer.write(s.as_bytes())?;

Ok(true)
}
2 changes: 1 addition & 1 deletion src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn now_iso8601() -> String {
unsafe {
let t = libc::time(std::ptr::null_mut());

if libc::localtime_r(&t, &mut timebuf) == std::ptr::null_mut() {
if libc::localtime_r(&t, &mut timebuf).is_null() {
panic!("localtime_r");
}

Expand Down

0 comments on commit d09ff81

Please sign in to comment.