Skip to content

Commit 1fd388f

Browse files
committed
Clippy & Fmt
1 parent 8f64d50 commit 1fd388f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/utils.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod altstack {
1616
use std::{io, mem::MaybeUninit, ptr};
1717

1818
/// Represents the desired configuration of the alternate signal stack.
19+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
1920
pub enum State {
2021
/// Disables Rust's alternate signal stack.
2122
Disabled,
@@ -27,6 +28,12 @@ pub mod altstack {
2728
},
2829
}
2930

31+
impl Default for State {
32+
fn default() -> Self {
33+
Self::Enabled { size: 8 * 1024 }
34+
}
35+
}
36+
3037
/// Configures the alternate signal stack according to the provided status.
3138
pub fn set(state: State) -> io::Result<()> {
3239
match state {
@@ -37,7 +44,7 @@ pub mod altstack {
3744
ss_size: 0,
3845
};
3946

40-
let result = unsafe { sigaltstack(&ss, ptr::null_mut()) };
47+
let result = unsafe { sigaltstack(&raw const ss, ptr::null_mut()) };
4148
if result != 0 {
4249
return Err(io::Error::last_os_error());
4350
}
@@ -65,7 +72,7 @@ pub mod altstack {
6572
ss_flags: 0,
6673
};
6774

68-
let result = unsafe { sigaltstack(&ss, ptr::null_mut()) };
75+
let result = unsafe { sigaltstack(&raw const ss, ptr::null_mut()) };
6976
if result != 0 {
7077
return Err(io::Error::last_os_error());
7178
}

tests/unhandled_managed_exeptions.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
#[path = "common.rs"]
55
mod common;
66

7-
use netcorehost::{nethost, pdcstr, utils::altstack::{self, State}};
8-
use rusty_fork::{ChildWrapper, ExitStatusWrapper, fork, rusty_fork_id};
9-
use std::{process::Stdio, io::Read};
7+
use netcorehost::{
8+
nethost, pdcstr,
9+
utils::altstack::{self, State},
10+
};
11+
use rusty_fork::{fork, rusty_fork_id, ChildWrapper, ExitStatusWrapper};
12+
use std::{io::Read, process::Stdio};
1013

1114
macro_rules! function_name {
1215
() => {{
@@ -60,7 +63,7 @@ fn segfault_with_small_altstack() {
6063
|status, _, stderr| {
6164
assert_eq!(status.unix_signal(), Some(libc::SIGSEGV));
6265
assert_not_contains!(stderr, MANAGED_HANDLER_OUTPUT);
63-
}
66+
},
6467
);
6568
}
6669

@@ -75,7 +78,7 @@ fn no_segfault_with_large_altstack() {
7578
|status, _, stderr| {
7679
assert_ne!(status.unix_signal(), Some(libc::SIGSEGV));
7780
assert_contains!(stderr, MANAGED_HANDLER_OUTPUT);
78-
}
81+
},
7982
);
8083
}
8184

@@ -90,14 +93,14 @@ fn no_segfault_with_altstack_disabled() {
9093
|status, _, stderr| {
9194
assert_ne!(status.unix_signal(), Some(libc::SIGSEGV));
9295
assert_contains!(stderr, MANAGED_HANDLER_OUTPUT);
93-
}
96+
},
9497
);
9598
}
9699

97100
fn altstack_test(
98101
test_name: &str,
99102
configure_altstack: impl FnOnce(),
100-
verify: impl FnOnce(ExitStatusWrapper, /* stdout */ String, /* stderr */String)
103+
verify: impl FnOnce(ExitStatusWrapper, /* stdout */ String, /* stderr */ String),
101104
) {
102105
common::setup();
103106

@@ -137,7 +140,7 @@ fn altstack_test(
137140
.unwrap()
138141
.read_to_string(&mut stdout)
139142
.unwrap();
140-
143+
141144
let mut stderr = String::new();
142145
child
143146
.inner_mut()
@@ -161,5 +164,6 @@ fn altstack_test(
161164
configure_child,
162165
supervise,
163166
body,
164-
).expect("fork failed");
167+
)
168+
.expect("fork failed");
165169
}

0 commit comments

Comments
 (0)