mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
rust: enable clippy::ptr_cast_constness
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
3a1c694d74
commit
5df3fe062f
7 changed files with 7 additions and 9 deletions
|
@ -74,8 +74,6 @@ Supported tools
|
||||||
QEMU supports rustc version 1.63.0 and newer. Notably, the following features
|
QEMU supports rustc version 1.63.0 and newer. Notably, the following features
|
||||||
are missing:
|
are missing:
|
||||||
|
|
||||||
* ``cast_mut()``/``cast_const()`` (1.65.0). Use ``as`` instead.
|
|
||||||
|
|
||||||
* Generic Associated Types (1.65.0)
|
* Generic Associated Types (1.65.0)
|
||||||
|
|
||||||
* ``CStr::from_bytes_with_nul()`` as a ``const`` function (1.72.0).
|
* ``CStr::from_bytes_with_nul()`` as a ``const`` function (1.72.0).
|
||||||
|
|
|
@ -71,6 +71,7 @@ no_effect_underscore_binding = "deny"
|
||||||
option_option = "deny"
|
option_option = "deny"
|
||||||
or_fun_call = "deny"
|
or_fun_call = "deny"
|
||||||
ptr_as_ptr = "deny"
|
ptr_as_ptr = "deny"
|
||||||
|
ptr_cast_constness = "deny"
|
||||||
pub_underscore_fields = "deny"
|
pub_underscore_fields = "deny"
|
||||||
redundant_clone = "deny"
|
redundant_clone = "deny"
|
||||||
redundant_closure_for_method_calls = "deny"
|
redundant_closure_for_method_calls = "deny"
|
||||||
|
@ -92,7 +93,6 @@ used_underscore_binding = "deny"
|
||||||
|
|
||||||
# nice to have, but cannot be enabled yet
|
# nice to have, but cannot be enabled yet
|
||||||
#wildcard_imports = "deny" # still have many bindings::* imports
|
#wildcard_imports = "deny" # still have many bindings::* imports
|
||||||
#ptr_cast_constness = "deny" # needs 1.65.0 for cast_mut()/cast_const()
|
|
||||||
|
|
||||||
# these may have false positives
|
# these may have false positives
|
||||||
#option_if_let_else = "deny"
|
#option_if_let_else = "deny"
|
||||||
|
|
|
@ -219,7 +219,7 @@ impl HPETTimer {
|
||||||
// SAFETY: the HPETTimer will only be used after the timer
|
// SAFETY: the HPETTimer will only be used after the timer
|
||||||
// is initialized below.
|
// is initialized below.
|
||||||
qemu_timer: unsafe { Timer::new() },
|
qemu_timer: unsafe { Timer::new() },
|
||||||
state: NonNull::new(state as *const _ as *mut _).unwrap(),
|
state: NonNull::new((state as *const HPETState).cast_mut()).unwrap(),
|
||||||
config: 0,
|
config: 0,
|
||||||
cmp: 0,
|
cmp: 0,
|
||||||
fsb: 0,
|
fsb: 0,
|
||||||
|
|
|
@ -1016,7 +1016,7 @@ impl<T> Opaque<T> {
|
||||||
|
|
||||||
/// Returns a raw pointer to the opaque data.
|
/// Returns a raw pointer to the opaque data.
|
||||||
pub const fn as_ptr(&self) -> *const T {
|
pub const fn as_ptr(&self) -> *const T {
|
||||||
self.as_mut_ptr() as *const _
|
self.as_mut_ptr().cast_const()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a raw pointer to the opaque data that can be passed to a
|
/// Returns a raw pointer to the opaque data that can be passed to a
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl CharBackend {
|
||||||
receive_cb,
|
receive_cb,
|
||||||
event_cb,
|
event_cb,
|
||||||
None,
|
None,
|
||||||
(owner as *const T as *mut T).cast::<c_void>(),
|
(owner as *const T).cast_mut().cast::<c_void>(),
|
||||||
core::ptr::null_mut(),
|
core::ptr::null_mut(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -388,7 +388,7 @@ where
|
||||||
{
|
{
|
||||||
#[allow(clippy::as_ptr_cast_mut)]
|
#[allow(clippy::as_ptr_cast_mut)]
|
||||||
{
|
{
|
||||||
self.as_ptr::<U>() as *mut _
|
self.as_ptr::<U>().cast_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ impl<T: ObjectType> Owned<T> {
|
||||||
// SAFETY NOTE: while NonNull requires a mutable pointer, only
|
// SAFETY NOTE: while NonNull requires a mutable pointer, only
|
||||||
// Deref is implemented so the pointer passed to from_raw
|
// Deref is implemented so the pointer passed to from_raw
|
||||||
// remains const
|
// remains const
|
||||||
Owned(NonNull::new(ptr as *mut T).unwrap())
|
Owned(NonNull::new(ptr.cast_mut()).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Obtain a raw C pointer from a reference. `src` is consumed
|
/// Obtain a raw C pointer from a reference. `src` is consumed
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl Timer {
|
||||||
scale as c_int,
|
scale as c_int,
|
||||||
attributes as c_int,
|
attributes as c_int,
|
||||||
Some(timer_cb),
|
Some(timer_cb),
|
||||||
(opaque as *const T).cast::<c_void>() as *mut c_void,
|
(opaque as *const T).cast::<c_void>().cast_mut(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue