vmm_vhost: fix type complexity clippy warning

Change-Id: I0522ac1143f35f9045af6f9489d77ca6e47a19b1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066130
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
This commit is contained in:
Frederick Mayle 2023-11-27 17:38:45 -08:00 committed by crosvm LUCI
parent 50cbe0cade
commit d63f9eea7c

View file

@ -332,11 +332,11 @@ impl<R: Req> Endpoint<R> {
/// * - PartialMessage: received a partial message.
/// * - InvalidMessage: received a invalid message.
/// * - backend specific errors
pub fn recv_body<T: Sized + AsBytes + FromBytes + Default + VhostUserMsgValidator>(
pub fn recv_body<T: AsBytes + FromBytes + VhostUserMsgValidator>(
&self,
) -> Result<(VhostUserMsgHeader<R>, T, Option<Vec<File>>)> {
let mut hdr = VhostUserMsgHeader::default();
let mut body: T = Default::default();
let mut body = T::new_zeroed();
let mut slices = [hdr.as_bytes_mut(), body.as_bytes_mut()];
let files = self.recv_into_bufs_all(&mut slices)?;
@ -356,10 +356,7 @@ impl<R: Req> Endpoint<R> {
/// * - PartialMessage: received a partial message.
/// * - InvalidMessage: received a invalid message.
/// * - backend specific errors
#[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))]
pub fn recv_payload_into_buf<
T: Sized + AsBytes + FromBytes + Default + VhostUserMsgValidator,
>(
pub fn recv_payload_into_buf<T: AsBytes + FromBytes + VhostUserMsgValidator>(
&self,
) -> Result<(VhostUserMsgHeader<R>, T, Vec<u8>, Option<Vec<File>>)> {
let mut hdr = VhostUserMsgHeader::default();
@ -370,7 +367,7 @@ impl<R: Req> Endpoint<R> {
return Err(Error::InvalidMessage);
}
let mut body: T = Default::default();
let mut body = T::new_zeroed();
let payload_size = hdr.get_size() as usize - mem::size_of::<T>();
let mut buf: Vec<u8> = vec![0; payload_size];
let mut slices = [body.as_bytes_mut(), buf.as_bytes_mut()];