Skip to content

Commit 0300d05

Browse files
committed
try to fix clippy stupidity
clippy stable seems to believe ::libc::c_int == ::core::ffi::c_int if you import the libc variant and then use it. best guess for a way to work around this bug is qualify the path everywhere.
1 parent 3f11965 commit 0300d05

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/allocs/c_alloc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ use {
1717
ptr::{self, NonNull},
1818
result::Result::{self, Err, Ok}
1919
},
20-
::libc::c_int
2120
};
2221

23-
fn null_q_dyn_or_errcode<F: Fn(Layout) -> (*mut c_void, c_int)>(
22+
fn null_q_dyn_or_errcode<F: Fn(Layout) -> (*mut c_void, ::libc::c_int)>(
2423
layout: Layout,
2524
f: F
2625
) -> Result<NonNull<u8>, Error> {
@@ -34,7 +33,7 @@ fn null_q_dyn_or_errcode<F: Fn(Layout) -> (*mut c_void, c_int)>(
3433
let (ptr, status) = f(layout);
3534
match status {
3635
0 => null_q_dyn(ptr, layout),
37-
code => Err(Error::AllocFailed(layout, Cause::OSErr(code as c_int)))
36+
code => Err(Error::AllocFailed(layout, Cause::OSErr(code as ::libc::c_int)))
3837
}
3938
}
4039
}

src/ffi/c_alloc.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
use {
66
crate::{allocs::c_alloc::CAlloc, traits::AllocDescriptor},
77
::core::ffi::c_void,
8-
::libc::c_int
98
};
109

1110
#[cfg(all(not(any(target_os = "horizon", target_os = "vita")), not(windows)))]
1211
#[cfg_attr(miri, track_caller)]
1312
#[inline(always)]
14-
pub(crate) unsafe fn c_alloc_spec(align: usize, size: usize) -> (*mut c_void, c_int) {
13+
pub(crate) unsafe fn c_alloc_spec(align: usize, size: usize) -> (*mut c_void, ::libc::c_int) {
1514
#[cfg(target_vendor = "apple")]
1615
{
1716
if align > (1 << 31) {
@@ -27,14 +26,14 @@ pub(crate) unsafe fn c_alloc_spec(align: usize, size: usize) -> (*mut c_void, c_
2726
#[cfg(windows)]
2827
#[cfg_attr(miri, track_caller)]
2928
#[inline(always)]
30-
pub(crate) unsafe fn c_alloc_spec(align: usize, size: usize) -> (*mut c_void, c_int) {
29+
pub(crate) unsafe fn c_alloc_spec(align: usize, size: usize) -> (*mut c_void, ::libc::c_int) {
3130
// SAFETY: requirements are passed onto the caller
3231
(unsafe { _aligned_malloc(size, align) }, 0)
3332
}
3433
#[cfg(any(target_os = "horizon", target_os = "vita"))]
3534
#[cfg_attr(miri, track_caller)]
3635
#[inline(always)]
37-
pub(crate) unsafe fn c_alloc_spec(layout: &Layout) -> (*mut c_void, c_int) {
36+
pub(crate) unsafe fn c_alloc_spec(layout: &Layout) -> (*mut c_void, ::libc::c_int) {
3837
// SAFETY: requirements are passed onto the caller
3938
(unsafe { memalign(layout.align(), layout.size()) }, 0)
4039
}
@@ -144,7 +143,7 @@ extern "C" {
144143
/// If successful, the returned pointer should be freed with [`free`].
145144
#[must_use = "on success this function produces an allocation; dropping the returned value \
146145
will leak memory"]
147-
pub fn posix_memalign(out: *mut *mut c_void, align: usize, size: usize) -> c_int;
146+
pub fn posix_memalign(out: *mut *mut c_void, align: usize, size: usize) -> ::libc::c_int;
148147

149148
#[cfg(all(not(windows), any(target_os = "horizon", target_os = "vita")))]
150149
/// Allocates `size` bytes aligned to `align`.

0 commit comments

Comments
 (0)