fix tests/run formatting

This commit is contained in:
dvermd 2025-08-10 08:24:48 +02:00
parent 307ebca295
commit dde77db2ab
5 changed files with 19 additions and 21 deletions

View File

@ -7,12 +7,10 @@ fn main() {
use std::hint::black_box;
macro_rules! check {
($ty:ty, $expr:expr) => {
{
const EXPECTED: $ty = $expr;
assert_eq!($expr, EXPECTED);
}
};
($ty:ty, $expr:expr) => {{
const EXPECTED: $ty = $expr;
assert_eq!($expr, EXPECTED);
}};
}
check!(u32, (2220326408_u32 + black_box(1)) >> (32 - 6));

View File

@ -12,7 +12,7 @@ fn main() {
let arg_count = std::env::args().count();
let int = isize::MAX;
let _int = int + arg_count as isize; // overflow
let _int = int + arg_count as isize; // overflow
// If overflow checking is disabled, we should reach here.
#[cfg(not(debug_assertions))]

View File

@ -27,12 +27,8 @@ fn one() -> isize {
#[no_mangle]
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
let test = Test {
field: one(),
};
let two = Two {
two: 2,
};
let test = Test { field: one() };
let two = Two { two: 2 };
unsafe {
libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two);

View File

@ -12,15 +12,11 @@ struct Struct {
func: unsafe fn(*const ()),
}
fn func(_ptr: *const ()) {
}
fn func(_ptr: *const ()) {}
fn main() {
let mut x = MaybeUninit::<&Struct>::uninit();
x.write(&Struct {
pointer: std::ptr::null(),
func,
});
x.write(&Struct { pointer: std::ptr::null(), func });
let x = unsafe { x.assume_init() };
let value = unsafe { (x as *const Struct).read_volatile() };
println!("{:?}", value);

View File

@ -7,7 +7,14 @@ mod libc {
#[link(name = "c")]
extern "C" {
pub fn sigaction(signum: i32, act: *const sigaction, oldact: *mut sigaction) -> i32;
pub fn mmap(addr: *mut (), len: usize, prot: i32, flags: i32, fd: i32, offset: i64) -> *mut ();
pub fn mmap(
addr: *mut (),
len: usize,
prot: i32,
flags: i32,
fd: i32,
offset: i64,
) -> *mut ();
pub fn mprotect(addr: *mut (), len: usize, prot: i32) -> i32;
}
@ -54,7 +61,8 @@ fn main() {
libc::MAP_PRIVATE | libc::MAP_ANONYMOUS,
-1,
0,
).cast();
)
.cast();
if STORAGE == libc::MAP_FAILED {
panic!("error: mmap failed");
}