Skip to content

Commit a611f98

Browse files
oech3cakebaker
authored andcommitted
tail: disallow clippy::wrong_self_convention
1 parent fab186e commit a611f98

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

‎src/uu/tail/src/follow/watch.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> {
482482
return Err(USimpleError::new(1, translate!("tail-no-files-remaining")));
483483
}
484484

485-
let mut process = platform::ProcessChecker::new(observer.pid);
485+
let process = platform::ProcessChecker::new(observer.pid);
486486

487487
let mut timeout_counter = 0;
488488

‎src/uu/tail/src/platform/unix.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ impl ProcessChecker {
1919
Self { pid: process_id }
2020
}
2121

22-
// Borrowing mutably to be aligned with Windows implementation
23-
#[allow(clippy::wrong_self_convention)]
24-
pub fn is_dead(&mut self) -> bool {
22+
pub fn is_dead(&self) -> bool {
2523
unsafe { libc::kill(self.pid, 0) != 0 && get_errno() != libc::EPERM }
2624
}
2725
}

‎src/uu/tail/src/platform/windows.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6+
use std::cell::Cell;
67
use windows_sys::Win32::Foundation::{CloseHandle, HANDLE, WAIT_FAILED, WAIT_OBJECT_0};
78
use windows_sys::Win32::System::Threading::{
89
OpenProcess, PROCESS_SYNCHRONIZE, WaitForSingleObject,
@@ -12,7 +13,7 @@ use windows_sys::core::BOOL;
1213
pub type Pid = u32;
1314

1415
pub struct ProcessChecker {
15-
dead: bool,
16+
dead: Cell<bool>,
1617
handle: HANDLE,
1718
}
1819

@@ -22,21 +23,20 @@ impl ProcessChecker {
2223
let FALSE: BOOL = 0;
2324
let h = unsafe { OpenProcess(PROCESS_SYNCHRONIZE, FALSE, process_id) };
2425
Self {
25-
dead: h.is_null(),
26+
dead: Cell::new(h.is_null()),
2627
handle: h,
2728
}
2829
}
2930

30-
#[allow(clippy::wrong_self_convention)]
31-
pub fn is_dead(&mut self) -> bool {
32-
if !self.dead {
33-
self.dead = unsafe {
31+
pub fn is_dead(&self) -> bool {
32+
if !self.dead.get() {
33+
self.dead.set(unsafe {
3434
let status = WaitForSingleObject(self.handle, 0);
3535
status == WAIT_OBJECT_0 || status == WAIT_FAILED
36-
}
36+
});
3737
}
3838

39-
self.dead
39+
self.dead.get()
4040
}
4141
}
4242

0 commit comments

Comments
 (0)