ok/jj
1
0
Fork 0
forked from mirrors/jj

fix windows warnings in src/cleanup_guard.rs

Fix warnings encountered on non-Unix platforms:

```
Compiling jujutsu v0.7.0 (C:\github.com\71\jj)
warning: unnecessary `unsafe` block
  --> src\cleanup_guard.rs:17:29
   |
17 |         if let Err(ref e) = unsafe { platform::init() } {
   |                             ^^^^^^ unnecessary `unsafe` block
   |
   = note: `#[warn(unused_unsafe)]` on by default

warning: function `on_signal` is never used
  --> src\cleanup_guard.rs:47:4
   |
47 | fn on_signal(guards: &mut GuardTable) {
   |    ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: `jujutsu` (lib) generated 2 warnings
```
This commit is contained in:
Grégoire Geis 2023-04-30 14:23:14 +09:00 committed by Grégoire Geis
parent 8395764de8
commit 0628379eed

View file

@ -43,13 +43,6 @@ impl Drop for CleanupGuard {
}
}
// Invoked on a background thread. Process exits after this returns.
fn on_signal(guards: &mut GuardTable) {
for guard in guards.drain() {
guard();
}
}
#[cfg(unix)]
mod platform {
use std::os::unix::io::{IntoRawFd as _, RawFd};
@ -93,6 +86,13 @@ mod platform {
Ok(())
}
// Invoked on a background thread. Process exits after this returns.
fn on_signal(guards: &mut GuardTable) {
for guard in guards.drain() {
guard();
}
}
unsafe extern "C" fn handler(signal: c_int) {
// Treat the second signal as instantly fatal.
static SIGNALED: AtomicBool = AtomicBool::new(false);
@ -112,7 +112,9 @@ mod platform {
mod platform {
use super::*;
pub fn init() -> io::Result<()> {
/// Safety: this function is safe to call, but is marked as unsafe to have
/// the same signature as other `init` functions in other platforms.
pub unsafe fn init() -> io::Result<()> {
Ok(())
}
}