Skip to content

Commit c46ddaf

Browse files
committed
chore: fix clippy lints/cargo warnings
The main one I am not sure about is the change of the ffi calling convension in the windows code. According to rust-lang#137018, "stdcall" is only for 32bit targets, which we do not support, and everything else should just use "C". There are some more fixes than what the CI complains about, because the CI does not run clippy on the windows target, but my local setup does, so I fixed up some additional warnings. Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
1 parent b0a10d6 commit c46ddaf

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/mmap/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<B: Bitmap> VolatileMemory for MmapRegion<B> {
395395
&self,
396396
offset: usize,
397397
count: usize,
398-
) -> volatile_memory::Result<VolatileSlice<BS<B>>> {
398+
) -> volatile_memory::Result<VolatileSlice<'_, BS<'_, B>>> {
399399
let _ = self.compute_end_offset(offset, count)?;
400400

401401
Ok(

src/mmap/windows.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::volatile_memory::{self, compute_offset, VolatileMemory, VolatileSlice
1818

1919
#[allow(non_snake_case)]
2020
#[link(name = "kernel32")]
21-
extern "stdcall" {
21+
extern "C" {
2222
pub fn VirtualAlloc(
2323
lpAddress: *mut c_void,
2424
dwSize: size_t,
@@ -55,7 +55,7 @@ const MEM_RELEASE: u32 = 0x00008000;
5555
const FILE_MAP_ALL_ACCESS: u32 = 0xf001f;
5656
const PAGE_READWRITE: u32 = 0x04;
5757

58-
pub const MAP_FAILED: *mut c_void = 0 as *mut c_void;
58+
pub const MAP_FAILED: *mut c_void = null_mut::<c_void>();
5959
pub const INVALID_HANDLE_VALUE: RawHandle = (-1isize) as RawHandle;
6060
#[allow(dead_code)]
6161
pub const ERROR_INVALID_PARAMETER: i32 = 87;
@@ -95,7 +95,7 @@ impl<B: NewBitmap> MmapRegion<B> {
9595
}
9696
// This is safe because we are creating an anonymous mapping in a place not already used by
9797
// any other area in this process.
98-
let addr = unsafe { VirtualAlloc(0 as *mut c_void, size, MEM_COMMIT, PAGE_READWRITE) };
98+
let addr = unsafe { VirtualAlloc(null_mut::<c_void>(), size, MEM_COMMIT, PAGE_READWRITE) };
9999
if addr == MAP_FAILED {
100100
return Err(io::Error::last_os_error());
101101
}
@@ -111,7 +111,7 @@ impl<B: NewBitmap> MmapRegion<B> {
111111
///
112112
/// # Arguments
113113
/// * `file_offset` - The mapping will be created at offset `file_offset.start` in the file
114-
/// referred to by `file_offset.file`.
114+
/// referred to by `file_offset.file`.
115115
/// * `size` - The size of the memory region in bytes.
116116
pub fn from_file(file_offset: FileOffset, size: usize) -> io::Result<Self> {
117117
let handle = file_offset.file().as_raw_handle();
@@ -151,7 +151,7 @@ impl<B: NewBitmap> MmapRegion<B> {
151151
CloseHandle(mapping);
152152
}
153153

154-
if addr == null_mut() {
154+
if addr.is_null() {
155155
return Err(io::Error::last_os_error());
156156
}
157157
Ok(Self {
@@ -200,7 +200,7 @@ impl<B: Bitmap> VolatileMemory for MmapRegion<B> {
200200
&self,
201201
offset: usize,
202202
count: usize,
203-
) -> volatile_memory::Result<VolatileSlice<BS<Self::B>>> {
203+
) -> volatile_memory::Result<VolatileSlice<'_, BS<'_, Self::B>>> {
204204
let end = compute_offset(offset, count)?;
205205
if end > self.size {
206206
return Err(volatile_memory::Error::OutOfBounds { addr: end });

0 commit comments

Comments
 (0)