Fix clippy errors

These are causing the clippy pre-upload hook to fail for me.

BUG=none
TEST=bin/clippy

Change-Id: Ifa5b6b008ca1e930ba203034234ce3da56830b11
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2574584
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
Chirantan Ekbote 2020-12-07 14:38:01 +09:00 committed by Commit Bot
parent 173289dd48
commit 8ed71d1049
4 changed files with 14 additions and 19 deletions

View file

@ -246,7 +246,7 @@ pub struct crosvm {
socket: UnixDatagram,
request_buffer: Vec<u8>,
response_buffer: Vec<u8>,
vcpus: Arc<Vec<crosvm_vcpu>>,
vcpus: Arc<[crosvm_vcpu]>,
}
impl crosvm {
@ -256,7 +256,7 @@ impl crosvm {
socket,
request_buffer: Vec::new(),
response_buffer: vec![0; MAX_DATAGRAM_SIZE],
vcpus: Default::default(),
vcpus: Arc::new([]),
};
crosvm.load_all_vcpus()?;
Ok(crosvm)
@ -265,7 +265,7 @@ impl crosvm {
fn new(
id_allocator: Arc<IdAllocator>,
socket: UnixDatagram,
vcpus: Arc<Vec<crosvm_vcpu>>,
vcpus: Arc<[crosvm_vcpu]>,
) -> crosvm {
crosvm {
id_allocator,
@ -350,10 +350,7 @@ impl crosvm {
let read_pipe = files.remove(0);
vcpus.push(crosvm_vcpu::new(fd_cast(read_pipe), fd_cast(write_pipe)));
}
// Only called once by the `from_connection` constructor, which makes a new unique
// `self.vcpus`.
let self_vcpus = Arc::get_mut(&mut self.vcpus).unwrap();
*self_vcpus = vcpus;
self.vcpus = Arc::from(vcpus);
Ok(())
}

View file

@ -184,7 +184,7 @@ impl<'a> Encoder for &'a LibvdaEncoder {
let input_format = match config
.src_params
.format
.ok_or_else(|| EncoderError::InvalidArgument)?
.ok_or(EncoderError::InvalidArgument)?
{
Format::NV12 => libvda::PixelFormat::NV12,
Format::YUV420 => libvda::PixelFormat::YV12,

View file

@ -138,13 +138,11 @@ impl<T: EncoderSession> Stream<T> {
.map_err(|_| VideoError::InvalidArgument)?;
// `format` is an Option since for the decoder, it is not populated until decoding has
// started. for encoder, format should always be populated.
let dest_format = dst_params
.format
.ok_or_else(|| VideoError::InvalidArgument)?;
let dest_format = dst_params.format.ok_or(VideoError::InvalidArgument)?;
let dst_profile = cros_capabilities
.get_default_profile(&dest_format)
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
let dst_h264_level = if dest_format == Format::H264 {
Some(Level::H264_1_0)
@ -999,14 +997,14 @@ impl<T: Encoder> EncoderDevice<T> {
let new_format = stream
.dst_params
.format
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
// If the selected profile no longer corresponds to the selected coded format,
// reset it.
stream.dst_profile = self
.cros_capabilities
.get_default_profile(&new_format)
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
if new_format == Format::H264 {
stream.dst_h264_level = Some(Level::H264_1_0);
@ -1083,7 +1081,7 @@ impl<T: Encoder> EncoderDevice<T> {
let format = stream
.dst_params
.format
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
match format {
Format::H264 => CtrlVal::Level(stream.dst_h264_level.ok_or_else(|| {
error!("H264 level not set");
@ -1135,7 +1133,7 @@ impl<T: Encoder> EncoderDevice<T> {
let format = stream
.dst_params
.format
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
if format != profile.to_format() {
error!(
"specified profile does not correspond to the selected format ({})",
@ -1156,7 +1154,7 @@ impl<T: Encoder> EncoderDevice<T> {
let format = stream
.dst_params
.format
.ok_or_else(|| VideoError::InvalidArgument)?;
.ok_or(VideoError::InvalidArgument)?;
if format != Format::H264 {
error!(
"set control called for level but format is not H264 ({})",

View file

@ -110,7 +110,7 @@ impl MemoryRegion {
/// fd of the underlying memory regions.
#[derive(Clone)]
pub struct GuestMemory {
regions: Arc<Vec<MemoryRegion>>,
regions: Arc<[MemoryRegion]>,
memfd: Arc<SharedMemory>,
}
@ -192,7 +192,7 @@ impl GuestMemory {
}
Ok(GuestMemory {
regions: Arc::new(regions),
regions: Arc::from(regions),
memfd: Arc::new(memfd),
})
}