From 07348168adf109c8e4deb88387a8c301c3c58553 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Sun, 16 Oct 2022 11:54:03 -0500 Subject: [PATCH] warning cleanup --- src/aztec/encoder/simple_token.rs | 2 +- src/common/mod.rs | 22 +++++++++++----------- src/lib.rs | 2 +- src/maxicode/decoder/bit_matrix_parser.rs | 2 +- src/qrcode/decoder/data_block.rs | 4 ++-- src/qrcode/decoder/decoder.rs | 4 ++-- src/qrcode/decoder/format_information.rs | 2 +- src/qrcode/encoder/encoder.rs | 2 +- src/qrcode/encoder/matrix_util.rs | 4 ++-- src/qrcode/encoder/minimal_encoder.rs | 10 +++++----- src/qrcode/qr_code_writer.rs | 6 +++--- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/aztec/encoder/simple_token.rs b/src/aztec/encoder/simple_token.rs index ce8d7c8..97b1fde 100644 --- a/src/aztec/encoder/simple_token.rs +++ b/src/aztec/encoder/simple_token.rs @@ -33,7 +33,7 @@ impl SimpleToken { } } - pub fn appendTo(&self, bit_array: &mut BitArray, text: &[u8]) { + pub fn appendTo(&self, bit_array: &mut BitArray, _text: &[u8]) { bit_array .appendBits(self.value as u32, self.bit_count as usize) .expect("append should never fail"); diff --git a/src/common/mod.rs b/src/common/mod.rs index 4d61b2c..7a77628 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -474,7 +474,7 @@ impl BitArray { */ pub fn setRange(&mut self, start: usize, end: usize) -> Result<(), Exceptions> { let mut end = end; - if end < start || start < 0 || end > self.size { + if end < start || end > self.size { return Err(Exceptions::IllegalArgumentException( "end < start || start < 0 || end > self.size".to_owned(), )); @@ -518,7 +518,7 @@ impl BitArray { */ pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result { let mut end = end; - if end < start || start < 0 || end > self.size { + if end < start || end > self.size { return Err(Exceptions::IllegalArgumentException( "end < start || start < 0 || end > self.size".to_owned(), )); @@ -1035,11 +1035,11 @@ impl BitMatrix { width: u32, height: u32, ) -> Result<(), Exceptions> { - if top < 0 || left < 0 { - return Err(Exceptions::IllegalArgumentException( - "Left and top must be nonnegative".to_owned(), - )); - } + // if top < 0 || left < 0 { + // return Err(Exceptions::IllegalArgumentException( + // "Left and top must be nonnegative".to_owned(), + // )); + // } if height < 1 || width < 1 { return Err(Exceptions::IllegalArgumentException( "Height and width must be at least 1".to_owned(), @@ -1133,7 +1133,7 @@ impl BitMatrix { pub fn rotate180(&mut self) { let mut topRow = BitArray::with_size(self.width as usize); let mut bottomRow = BitArray::with_size(self.width as usize); - let mut maxHeight = (self.height + 1) / 2; + let maxHeight = (self.height + 1) / 2; for i in 0..maxHeight { //for (int i = 0; i < maxHeight; i++) { topRow = self.getRow(i, &topRow); @@ -1150,9 +1150,9 @@ impl BitMatrix { * Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise */ pub fn rotate90(&mut self) { - let mut newWidth = self.height; - let mut newHeight = self.width; - let mut newRowSize = (newWidth + 31) / 32; + let newWidth = self.height; + let newHeight = self.width; + let newRowSize = (newWidth + 31) / 32; let mut newBits = vec![0; (newRowSize * newHeight).try_into().unwrap()]; for y in 0..self.height { diff --git a/src/lib.rs b/src/lib.rs index 9540ae5..0d4119a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1213,7 +1213,7 @@ pub mod result_point_utils { ); let mut pointA; //: &RXingResultPoint; - let mut pointB; //: &RXingResultPoint; + let pointB; //: &RXingResultPoint; let mut pointC; //: &RXingResultPoint; // Assume one closest to other two is B; A and C will just be guesses at first if oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance { diff --git a/src/maxicode/decoder/bit_matrix_parser.rs b/src/maxicode/decoder/bit_matrix_parser.rs index 757585a..3ce6cda 100644 --- a/src/maxicode/decoder/bit_matrix_parser.rs +++ b/src/maxicode/decoder/bit_matrix_parser.rs @@ -78,7 +78,7 @@ impl BitMatrixParser { // for (int x = 0; x < width; x++) { let bit = bitnrRow[x]; if bit >= 0 && self.0.get(x as u32, y as u32) { - result[bit as usize / 6] |= (1 << (5 - (bit % 6))); + result[bit as usize / 6] |= 1 << (5 - (bit % 6)); } } } diff --git a/src/qrcode/decoder/data_block.rs b/src/qrcode/decoder/data_block.rs index d2ab921..d7d3901 100755 --- a/src/qrcode/decoder/data_block.rs +++ b/src/qrcode/decoder/data_block.rs @@ -64,11 +64,11 @@ impl DataBlock { let ecBlocks = version.getECBlocksForLevel(ecLevel); // First count the total number of data blocks - let mut totalBlocks = 0; + let mut _totalBlocks = 0; let ecBlockArray = ecBlocks.getECBlocks(); for ecBlock in ecBlockArray { // for (Version.ECB ecBlock : ecBlockArray) { - totalBlocks += ecBlock.getCount(); + _totalBlocks += ecBlock.getCount(); } // Now establish DataBlocks of the appropriate size and number of data codewords diff --git a/src/qrcode/decoder/decoder.rs b/src/qrcode/decoder/decoder.rs index f260d11..f210f66 100644 --- a/src/qrcode/decoder/decoder.rs +++ b/src/qrcode/decoder/decoder.rs @@ -36,7 +36,7 @@ use super::{decoded_bit_stream_parser, BitMatrixParser, DataBlock, QRCodeDecoder lazy_static! { //rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); - static ref rsDecoder : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256)); + static ref RS_DECODER : ReedSolomonDecoder = ReedSolomonDecoder::new(get_predefined_genericgf(PredefinedGenericGF::QrCodeField256)); } pub fn decode_bool_array(image: &Vec>) -> Result { @@ -200,7 +200,7 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<() let mut sending_code_words : Vec = codewordsInts.iter().map(|x| *x as i32).collect(); - if let Err(e) = rsDecoder.decode( + if let Err(e) = RS_DECODER.decode( &mut sending_code_words, (codewordBytes.len() - numDataCodewords) as i32, ) { diff --git a/src/qrcode/decoder/format_information.rs b/src/qrcode/decoder/format_information.rs index 2a1b08b..3d91c2f 100644 --- a/src/qrcode/decoder/format_information.rs +++ b/src/qrcode/decoder/format_information.rs @@ -134,7 +134,7 @@ impl FormatInformation { if masked_format_info1 != masked_format_info2 { // also try the other option bits_difference = Self::numBitsDiffering(masked_format_info2, targetInfo); - if (bits_difference < best_difference) { + if bits_difference < best_difference { best_format_info = decodeInfo[1] as u8; best_difference = bits_difference; } diff --git a/src/qrcode/encoder/encoder.rs b/src/qrcode/encoder/encoder.rs index 7ac2212..6ea5427 100644 --- a/src/qrcode/encoder/encoder.rs +++ b/src/qrcode/encoder/encoder.rs @@ -155,7 +155,7 @@ pub fn encode_with_hints( let encoding = if encoding.is_some() { encoding.unwrap() } else { - if let Ok(encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){ + if let Ok(_encs) = DEFAULT_BYTE_MODE_ENCODING.encode(content, encoding::EncoderTrap::Strict){ DEFAULT_BYTE_MODE_ENCODING }else { has_encoding_hint = true; diff --git a/src/qrcode/encoder/matrix_util.rs b/src/qrcode/encoder/matrix_util.rs index 867b3c6..fe4f307 100644 --- a/src/qrcode/encoder/matrix_util.rs +++ b/src/qrcode/encoder/matrix_util.rs @@ -169,7 +169,7 @@ pub fn embedTypeInfo( matrix: &mut ByteMatrix, ) -> Result<(), Exceptions> { let mut typeInfoBits = BitArray::new(); - makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits); + makeTypeInfoBits(ecLevel, maskPattern as u32, &mut typeInfoBits)?; for i in 0..typeInfoBits.getSize() { // for (int i = 0; i < typeInfoBits.getSize(); ++i) { @@ -363,7 +363,7 @@ pub fn makeTypeInfoBits( let mut maskBits = BitArray::new(); maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15)?; - bits.xor(&maskBits); + bits.xor(&maskBits)?; if bits.getSize() != 15 { // Just in case. diff --git a/src/qrcode/encoder/minimal_encoder.rs b/src/qrcode/encoder/minimal_encoder.rs index 7f2acd9..f461d35 100644 --- a/src/qrcode/encoder/minimal_encoder.rs +++ b/src/qrcode/encoder/minimal_encoder.rs @@ -943,7 +943,7 @@ impl RXingResultList { */ pub fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> { for resultNode in &self.list { - resultNode.getBits(bits); + resultNode.getBits(bits)?; } Ok(()) } @@ -1078,19 +1078,19 @@ impl RXingResultNode { * appends the bits */ fn getBits(&self, bits: &mut BitArray) -> Result<(), Exceptions> { - bits.appendBits(self.mode.getBits() as u32, 4); + bits.appendBits(self.mode.getBits() as u32, 4)?; if self.characterLength > 0 { let length = self.getCharacterCountIndicator(); bits.appendBits( length, self.mode.getCharacterCountBits(self.version) as usize, - ); + )?; } if self.mode == Mode::ECI { bits.appendBits( self.encoders.getECIValue(self.charsetEncoderIndex as usize), 8, - ); + )?; } else if self.characterLength > 0 { // append data encoder::appendBytes( @@ -1100,7 +1100,7 @@ impl RXingResultNode { self.mode, bits, self.encoders.getCharset(self.charsetEncoderIndex as usize), - ); + )?; } Ok(()) } diff --git a/src/qrcode/qr_code_writer.rs b/src/qrcode/qr_code_writer.rs index 5e31473..ebebf88 100644 --- a/src/qrcode/qr_code_writer.rs +++ b/src/qrcode/qr_code_writer.rs @@ -56,7 +56,7 @@ impl Writer for QRCodeWriter { height: i32, hints: &crate::EncodingHintDictionary, ) -> Result { - if (contents.is_empty()) { + if contents.is_empty() { return Err(Exceptions::IllegalArgumentException( "Found empty contents".to_owned(), )); @@ -71,7 +71,7 @@ impl Writer for QRCodeWriter { // throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format); } - if (width < 0 || height < 0) { + if width < 0 || height < 0 { return Err(Exceptions::IllegalArgumentException(format!( "Requested dimensions are too small: {}x{}", width, height @@ -158,7 +158,7 @@ impl QRCodeWriter { outputY as u32, multiple as u32, multiple as u32, - ); + )?; } inputX += 1;