Skip to content

Commit

Permalink
Fix clippy warnings and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnurou committed Apr 8, 2023
1 parent 1f9153a commit 97ce2da
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
1 change: 0 additions & 1 deletion lib/src/decoder/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl<S: io::Read> PatternSplitter<S> {

// The stream must begin by our header, or it is invalid.
let stream_start = (0..pattern.len())
.into_iter()
.map(|_| stream.next().unwrap_or(Ok(0)).unwrap_or(0))
.collect::<Vec<_>>();

Expand Down
1 change: 0 additions & 1 deletion lib/src/device/queue/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ mod tests {
assert_eq!(buffer_stats.num_queued(), 0);

let buffers = (0..NUM_BUFFERS)
.into_iter()
.map(|i| {
let querybuf = ioctl::QueryBuffer {
index: i,
Expand Down
2 changes: 0 additions & 2 deletions lib/src/device/queue/qbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ impl<P: PrimitiveBufferHandles, Q: BufferHandles + From<P>> CaptureQueueable<Q>
// that it matches with P.

let mut planes: Vec<_> = (0..self.num_expected_planes())
.into_iter()
.map(|_| ioctl::QBufPlane::new(0))
.collect();
for (index, plane) in planes.iter_mut().enumerate() {
Expand Down Expand Up @@ -275,7 +274,6 @@ where
{
pub fn queue(self) -> Result<(), ioctl::QBufError> {
let planes: Vec<_> = (0..self.num_expected_planes())
.into_iter()
.map(|_| ioctl::QBufPlane::new(0))
.collect();

Expand Down
4 changes: 2 additions & 2 deletions lib/src/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod dqbuf;
mod encoder_cmd;
mod enum_fmt;
mod expbuf;
mod framesizes;
mod g_ext_ctrls;
mod g_fmt;
mod g_input;
Expand All @@ -25,13 +26,13 @@ mod reqbufs;
mod request;
mod streamon;
mod subscribe_event;
mod framesizes;

pub use decoder_cmd::*;
pub use dqbuf::*;
pub use encoder_cmd::*;
pub use enum_fmt::*;
pub use expbuf::*;
pub use framesizes::*;
pub use g_ext_ctrls::*;
pub use g_fmt::*;
pub use g_input::*;
Expand All @@ -46,7 +47,6 @@ pub use reqbufs::*;
pub use request::*;
pub use streamon::*;
pub use subscribe_event::*;
pub use framesizes::*;

use std::fmt::Debug;

Expand Down
22 changes: 11 additions & 11 deletions lib/src/ioctl/framesizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ mod ioctl {
nix::ioctl_readwrite!(vidioc_enum_framesizes, b'V', 74, v4l2_frmsizeenum);
}


#[derive(Debug, Error)]
pub enum FrameSizeError {
#[error("Unexpected ioctl error: {0}")]
IoctlError(nix::Error),
}

pub fn enum_frame_sizes<T: FrameSize>(fd: &impl AsRawFd, index: u32, pixel_format: PixelFormat) -> Result<T, FrameSizeError>{
pub fn enum_frame_sizes<T: FrameSize>(
fd: &impl AsRawFd,
index: u32,
pixel_format: PixelFormat,
) -> Result<T, FrameSizeError> {
let mut frame_size = bindings::v4l2_frmsizeenum {
index,
pixel_format: pixel_format.into(),
..unsafe {std::mem::zeroed()}
..unsafe { std::mem::zeroed() }
};

match unsafe {
ioctl::vidioc_enum_framesizes(fd.as_raw_fd(), &mut frame_size)
} {
Ok(_) => Ok(T::from(frame_size)),
Err(e) => Err(FrameSizeError::IoctlError(e))
}

}
match unsafe { ioctl::vidioc_enum_framesizes(fd.as_raw_fd(), &mut frame_size) } {
Ok(_) => Ok(T::from(frame_size)),
Err(e) => Err(FrameSizeError::IoctlError(e)),
}
}
1 change: 0 additions & 1 deletion utils/src/dmabuf_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub fn export_dmabufs(format: &Format, nb_buffers: usize) -> Result<Vec<Vec<DmaB
let heap = DmaBufHeap::new(DmaBufHeapType::System).unwrap();

let fds: Vec<Vec<DmaBufHandle<File>>> = (0..nb_buffers)
.into_iter()
.map(|_| {
format
.plane_fmt
Expand Down

0 comments on commit 97ce2da

Please sign in to comment.