diff --git a/Cargo.toml b/Cargo.toml index 5c3ebdf0..7ae3f44b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,7 +126,7 @@ trait_duplication_in_bounds = "warn" type_repetition_in_bounds = "warn" checked_conversions = "warn" get_unwrap = "warn" -# TODO: similar_names = "warn" # Reduce risk of confusing similar names together, and protects against typos when variable shadowing was intended. +similar_names = "warn" # Reduce risk of confusing similar names together, and protects against typos when variable shadowing was intended. str_to_string = "warn" string_to_string = "warn" # TODO: std_instead_of_alloc = "warn" diff --git a/crates/ironrdp-dvc/src/lib.rs b/crates/ironrdp-dvc/src/lib.rs index a3c56f57..de9c7c54 100644 --- a/crates/ironrdp-dvc/src/lib.rs +++ b/crates/ironrdp-dvc/src/lib.rs @@ -77,8 +77,8 @@ pub fn encode_dvc_messages( while off < total_length { let first = off == 0; - let rem = total_length.checked_sub(off).unwrap(); - let size = core::cmp::min(rem, DrdynvcDataPdu::MAX_DATA_SIZE); + let remaining_length = total_length.checked_sub(off).unwrap(); + let size = core::cmp::min(remaining_length, DrdynvcDataPdu::MAX_DATA_SIZE); let end = off .checked_add(size) .ok_or_else(|| other_err!("encode_dvc_messages", "overflow occurred"))?; diff --git a/crates/ironrdp-graphics/src/color_conversion.rs b/crates/ironrdp-graphics/src/color_conversion.rs index 4c1d4d08..09141659 100644 --- a/crates/ironrdp-graphics/src/color_conversion.rs +++ b/crates/ironrdp-graphics/src/color_conversion.rs @@ -231,6 +231,8 @@ pub struct Rgb { impl From for Rgb { fn from(YCbCr { y, cb, cr }: YCbCr) -> Self { + #![allow(clippy::similar_names)] // It’s hard to find better names here. + // We scale the factors by << 16 into 32-bit integers in order to // avoid slower floating point multiplications. Since the final // result needs to be scaled by >> 5 we will extract only the @@ -259,6 +261,8 @@ impl From for Rgb { impl From for YCbCr { fn from(Rgb { r, g, b }: Rgb) -> Self { + #![allow(clippy::similar_names)] // It’s hard to find better names here. + // We scale the factors by << 15 into 32-bit integers in order // to avoid slower floating point multiplications. Since the // terms need to be scaled by << 5 we simply scale the final diff --git a/crates/ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs b/crates/ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs index 8f5f8894..e25d9b2f 100644 --- a/crates/ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs +++ b/crates/ironrdp-graphics/src/rdp6/bitmap_stream/decoder.rs @@ -163,6 +163,7 @@ impl<'a> BitmapStreamDecoderImpl<'a> { } fn write_aycocg_planes_to_rgb24(&self, params: AYCoCgParams, planes: &[u8], dst: &mut Vec) { + #![allow(clippy::similar_names)] // It’s hard to find better names for co, cg, etc. let sample_shift = params.chroma_subsampling as usize; let (y_offset, co_offset, cg_offset) = ( @@ -225,6 +226,8 @@ impl<'a> BitmapStreamDecoderImpl<'a> { /// Perform YCoCg -> RGB conversion with color loss reduction (CLL) correction. fn ycocg_with_cll_to_rgb(cll: u8, y: u8, co: u8, cg: u8) -> Rgb { + #![allow(clippy::similar_names)] // It’s hard to find better names for co, cg, etc. + // We decrease CLL by 1 to skip division by 2 for co & cg components during computation of // the following color conversion matrix: // |R| |1 1/2 -1/2| |Y | diff --git a/crates/ironrdp-pdu/src/codecs/rfx/data_messages.rs b/crates/ironrdp-pdu/src/codecs/rfx/data_messages.rs index 635dc1e2..cec6c4da 100644 --- a/crates/ironrdp-pdu/src/codecs/rfx/data_messages.rs +++ b/crates/ironrdp-pdu/src/codecs/rfx/data_messages.rs @@ -488,6 +488,8 @@ impl PduBufferParsing<'_> for Quant { type Error = RfxError; fn from_buffer_consume(buffer: &mut &[u8]) -> Result { + #![allow(clippy::similar_names)] // It’s hard to do better than ll3, lh3, etc without going overly verbose. + let level3 = buffer.read_u16::()?; let ll3 = level3.get_bits(0..4) as u8; let lh3 = level3.get_bits(4..8) as u8; @@ -565,6 +567,8 @@ impl<'a> PduBufferParsing<'a> for Tile<'a> { type Error = RfxError; fn from_buffer_consume(buffer: &mut &'a [u8]) -> Result { + #![allow(clippy::similar_names)] // It’s hard to find better names for cr, cb, etc. + let header = BlockHeader::from_buffer_consume_with_expected_type(buffer, BlockType::Tile)?; let mut buffer = buffer.split_to(header.data_length); diff --git a/crates/ironrdp-server/src/encoder/rfx.rs b/crates/ironrdp-server/src/encoder/rfx.rs index 6324f9e9..4e8c66a6 100644 --- a/crates/ironrdp-server/src/encoder/rfx.rs +++ b/crates/ironrdp-server/src/encoder/rfx.rs @@ -23,6 +23,7 @@ impl RfxEncoder { } // FIXME: rewrite to use WriteCursor + #[allow(clippy::similar_names)] // It’s hard to find better names for cr, cb, etc. pub(crate) fn encode(&mut self, bitmap: &BitmapUpdate) -> EncodeResult> { let width = bitmap.width.get(); let height = bitmap.height.get();