From cc0a023d906149db2f406d5596cd400e6a118ce2 Mon Sep 17 00:00:00 2001
From: Kostya Shishkov <kostya.shishkov@gmail.com>
Date: Wed, 17 Nov 2021 13:43:19 +0100
Subject: [PATCH] fix clippy warnings

---
 nihav-commonfmt/src/codecs/jpeg.rs        | 2 ++
 nihav-commonfmt/src/codecs/rawvideo.rs    | 4 ++--
 nihav-commonfmt/src/codecs/rawvideo_ms.rs | 6 +++---
 nihav-commonfmt/src/demuxers/y4m.rs       | 2 +-
 nihav-llaudio/src/demuxers/flac.rs        | 2 +-
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/nihav-commonfmt/src/codecs/jpeg.rs b/nihav-commonfmt/src/codecs/jpeg.rs
index 099aff9..693ead4 100644
--- a/nihav-commonfmt/src/codecs/jpeg.rs
+++ b/nihav-commonfmt/src/codecs/jpeg.rs
@@ -63,6 +63,7 @@ fn idct_row(row: &mut [i16]) {
 }
 
 #[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
 fn idct_col(blk: &mut [i16; 64], off: usize) {
     let in0 = ((i32::from(blk[off + 0*8])) << 8) + (1 << (COL_SHIFT - 1));
     let in1 =  (i32::from(blk[off + 4*8])) << 8;
@@ -236,6 +237,7 @@ impl JPEGDecoder {
         self.depth      = 0;
     }
 
+    #[allow(clippy::many_single_char_names)]
     fn parse_sof(&mut self, br: &mut ByteReader) -> DecoderResult<NABufferType> {
         validate!(self.width == 0);
 
diff --git a/nihav-commonfmt/src/codecs/rawvideo.rs b/nihav-commonfmt/src/codecs/rawvideo.rs
index 884f7c9..13bd187 100644
--- a/nihav-commonfmt/src/codecs/rawvideo.rs
+++ b/nihav-commonfmt/src/codecs/rawvideo.rs
@@ -57,7 +57,7 @@ impl NADecoder for RawDecoder {
                     }
                     validate!(off == src.len());
 
-                    NABufferType::Video(NAVideoBuffer::from_raw_parts(vinfo.clone(), src.clone(), offs, strides).into_ref())
+                    NABufferType::Video(NAVideoBuffer::from_raw_parts(*vinfo, src, offs, strides).into_ref())
                 } else {
                     let esize = vinfo.format.elem_size as usize;
                     let ychr = vinfo.format.get_chromaton(0).unwrap();
@@ -65,7 +65,7 @@ impl NADecoder for RawDecoder {
                     let stride = (width * esize + ystep - 1) / ystep;
                     let offs    = vec![0];
                     let strides = vec![stride];
-                    NABufferType::VideoPacked(NAVideoBuffer::from_raw_parts(vinfo.clone(), src.clone(), offs, strides).into_ref())
+                    NABufferType::VideoPacked(NAVideoBuffer::from_raw_parts(*vinfo, src, offs, strides).into_ref())
                 };
 
             let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), buf);
diff --git a/nihav-commonfmt/src/codecs/rawvideo_ms.rs b/nihav-commonfmt/src/codecs/rawvideo_ms.rs
index 0b35881..a445cfd 100644
--- a/nihav-commonfmt/src/codecs/rawvideo_ms.rs
+++ b/nihav-commonfmt/src/codecs/rawvideo_ms.rs
@@ -50,7 +50,7 @@ impl NADecoder for RawDecoder {
 
                         let sstride = (vinfo.width + 3) & !3;
 
-                        let buf = alloc_video_buffer(vinfo.clone(), 0)?;
+                        let buf = alloc_video_buffer(*vinfo, 0)?;
 
                         let mut frm = buf.get_vbuf().unwrap();
                         let dstride = frm.get_stride(0);
@@ -66,7 +66,7 @@ impl NADecoder for RawDecoder {
                     15 | 16 => {
                         let sstride = (vinfo.width * 2 + 3) & !3;
 
-                        let buf = alloc_video_buffer(vinfo.clone(), 0)?;
+                        let buf = alloc_video_buffer(*vinfo, 0)?;
 
                         let mut frm = buf.get_vbuf16().unwrap();
                         let dstride = frm.get_stride(0);
@@ -86,7 +86,7 @@ impl NADecoder for RawDecoder {
                         let offs    = vec![0; ncomp];
                         let mut strides = vec![0; ncomp];
                         strides[0] = sstride;
-                         NABufferType::VideoPacked(NAVideoBuffer::from_raw_parts(vinfo.clone(), src.clone(), offs, strides).into_ref())
+                         NABufferType::VideoPacked(NAVideoBuffer::from_raw_parts(*vinfo, src, offs, strides).into_ref())
                     },
                     _ => return Err(DecoderError::NotImplemented),
                 };
diff --git a/nihav-commonfmt/src/demuxers/y4m.rs b/nihav-commonfmt/src/demuxers/y4m.rs
index 093d444..f303060 100644
--- a/nihav-commonfmt/src/demuxers/y4m.rs
+++ b/nihav-commonfmt/src/demuxers/y4m.rs
@@ -20,7 +20,7 @@ impl<'a> DemuxCore<'a> for Y4MDemuxer<'a> {
         let vhdr = NAVideoInfo::new(self.width, self.height, false, format);
         let vci = NACodecTypeInfo::Video(vhdr);
         let vinfo = NACodecInfo::new("rawvideo", vci, None);
-        if let None = strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, self.fps_num, self.fps_den, 0)) {
+        if strmgr.add_stream(NAStream::new(StreamType::Video, 0, vinfo, self.fps_num, self.fps_den, 0)).is_none() {
             return Err(DemuxerError::MemoryError);
         }
 
diff --git a/nihav-llaudio/src/demuxers/flac.rs b/nihav-llaudio/src/demuxers/flac.rs
index c20bc3d..83208c4 100644
--- a/nihav-llaudio/src/demuxers/flac.rs
+++ b/nihav-llaudio/src/demuxers/flac.rs
@@ -89,7 +89,7 @@ impl<'a> FLACDemuxer<'a> {
                         1 => 192,
                         2..=5 => 576 << (bsz_id - 2),
                         6 => {
-                            validate!(idx + 1 <= buf.len());
+                            validate!(idx < buf.len());
                             u64::from(buf[idx]) + 1
                         },
                         7 => {
-- 
2.39.5