]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix clippy lints for clippy::assign_op_pattern
authorJason Ish <jason.ish@oisf.net>
Wed, 5 Oct 2022 14:52:44 +0000 (08:52 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Oct 2022 09:20:08 +0000 (11:20 +0200)
12 files changed:
rust/src/dcerpc/dcerpc.rs
rust/src/dcerpc/detect.rs
rust/src/http2/detect.rs
rust/src/mqtt/mqtt.rs
rust/src/mqtt/parser.rs
rust/src/pgsql/parser.rs
rust/src/pgsql/pgsql.rs
rust/src/quic/frames.rs
rust/src/smb/dcerpc.rs
rust/src/smb/smb.rs
rust/src/smb/smb2.rs
rust/src/smb/smb2_records.rs

index 5299c0e13321de97526f8bb4d7eaaec0e0a1492a..2d5bca371504fec26365be9a6957a32949becf98 100644 (file)
@@ -696,7 +696,7 @@ impl DCERPCState {
                     if retval == -1 {
                         return -1;
                     }
-                    idx = retval + idx;
+                    idx += retval;
                 }
                 let call_id = self.get_hdr_call_id().unwrap_or(0);
                 let mut tx = self.create_tx(call_id);
@@ -941,7 +941,7 @@ impl DCERPCState {
                     if consumed < 2 {
                         consumed = 0;
                     } else {
-                        consumed = consumed - 1;
+                        consumed -= 1;
                     }
                     SCLogDebug!("DCERPC record NOT found");
                     return AppLayerResult::incomplete(consumed as u32, 2);
index 662e2c20fd82e0e4a0ebdcebfe50b3911a55606c..5d616a66425fb23b658f0609f6b8e45ae4dc1b64 100644 (file)
@@ -79,7 +79,7 @@ fn match_backuuid(
                 }
             }
             let ctxid = tx.get_req_ctxid();
-            ret = ret & ((uuidentry.ctxid == ctxid) as u8);
+            ret &= (uuidentry.ctxid == ctxid) as u8;
             if ret == 0 {
                 SCLogDebug!("CTX IDs/UUIDs do not match");
                 continue;
index 910756d5f05c036b6245e327675c4b54df412907..7a1e68980698d999463babd749829b71db529bd0 100644 (file)
@@ -135,7 +135,7 @@ fn http2_tx_get_next_priority(
                     if pos == nb {
                         return prio.weight as i32;
                     } else {
-                        pos = pos + 1;
+                        pos += 1;
                     }
                 }
                 HTTP2FrameTypeData::HEADERS(hd) => {
@@ -143,7 +143,7 @@ fn http2_tx_get_next_priority(
                         if pos == nb {
                             return prio.weight as i32;
                         } else {
-                            pos = pos + 1;
+                            pos += 1;
                         }
                     }
                 }
@@ -157,7 +157,7 @@ fn http2_tx_get_next_priority(
                     if pos == nb {
                         return prio.weight as i32;
                     } else {
-                        pos = pos + 1;
+                        pos += 1;
                     }
                 }
                 HTTP2FrameTypeData::HEADERS(hd) => {
@@ -165,7 +165,7 @@ fn http2_tx_get_next_priority(
                         if pos == nb {
                             return prio.weight as i32;
                         } else {
-                            pos = pos + 1;
+                            pos += 1;
                         }
                     }
                 }
@@ -195,7 +195,7 @@ fn http2_tx_get_next_window(
                     if pos == nb {
                         return wu.sizeinc as i32;
                     } else {
-                        pos = pos + 1;
+                        pos += 1;
                     }
                 }
                 _ => {}
@@ -208,7 +208,7 @@ fn http2_tx_get_next_window(
                     if pos == nb {
                         return wu.sizeinc as i32;
                     } else {
-                        pos = pos + 1;
+                        pos += 1;
                     }
                 }
                 _ => {}
@@ -382,7 +382,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_header_name(
                         *buffer_len = value.len() as u32;
                         return 1;
                     } else {
-                        pos = pos + blocks.len() as u32;
+                        pos += blocks.len() as u32;
                     }
                 }
             }
@@ -396,7 +396,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_header_name(
                         *buffer_len = value.len() as u32;
                         return 1;
                     } else {
-                        pos = pos + blocks.len() as u32;
+                        pos += blocks.len() as u32;
                     }
                 }
             }
@@ -830,7 +830,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_header(
                         *buffer_len = value.len() as u32;
                         return 1;
                     } else {
-                        pos = pos + blocks.len() as u32;
+                        pos += blocks.len() as u32;
                     }
                 }
             }
@@ -847,7 +847,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_header(
                         *buffer_len = value.len() as u32;
                         return 1;
                     } else {
-                        pos = pos + blocks.len() as u32;
+                        pos += blocks.len() as u32;
                     }
                 }
             }
index 04691218d5b1ba0e26c2afb2ea852060396427d1..94b7956f7f1b2ae2958dcde6599465b743f2ae94 100644 (file)
@@ -185,7 +185,7 @@ impl MQTTState {
         if self.transactions.len() > unsafe { MQTT_MAX_TX } {
             let mut index = self.tx_index_completed;
             for tx_old in &mut self.transactions.range_mut(self.tx_index_completed..) {
-                index = index + 1;
+                index += 1;
                 if !tx_old.complete {
                     tx_old.complete = true;
                     MQTTState::set_event(tx_old, MQTTEvent::TooManyTransactions);
index f73c3b1127ffc6745a6e68b41d0c31c450ed8393..fb938fb9d5dca1582cb4be8e5a726d9216a99cbf 100644 (file)
@@ -51,10 +51,10 @@ fn convert_varint(continued: Vec<u8>, last: u8) -> u32 {
     let mut multiplier = 1u32;
     let mut value = 0u32;
     for val in &continued {
-        value = value + ((val & 127) as u32 * multiplier);
-        multiplier = multiplier * 128u32;
+        value += (val & 127) as u32 * multiplier;
+        multiplier *= 128u32;
     }
-    value = value + ((last & 127) as u32 * multiplier);
+    value += (last & 127) as u32 * multiplier;
     return value;
 }
 
index ab0b00d8752610fca76aa564ff911619632a9f49..70c091270c44d0b02f445c57f328c2d71fea3ad2 100644 (file)
@@ -903,7 +903,7 @@ fn add_up_data_size(columns: Vec<ColumnFieldValue>) -> u64 {
     for field in columns {
         // -1 value means data value is NULL, let's not add that up
         if field.value_length > 0 {
-            data_size = data_size + field.value_length as u64;
+            data_size += field.value_length as u64;
         }
     }
     data_size
index 9a19b01637063bfa6553be4824c08ad90b448da7..8fe69e6add292b64cd26f566b35b056530b3c8ff 100644 (file)
@@ -76,7 +76,7 @@ impl PgsqlTransaction {
     }
 
     pub fn incr_row_cnt(&mut self) {
-        self.data_row_cnt = self.data_row_cnt + 1;
+        self.data_row_cnt += 1;
     }
 
     pub fn get_row_cnt(&self) -> u16 {
@@ -84,7 +84,7 @@ impl PgsqlTransaction {
     }
 
     pub fn sum_data_size(&mut self, row_size: u64) {
-        self.data_size = self.data_size + row_size;
+        self.data_size += row_size;
     }
 }
 
@@ -194,7 +194,7 @@ impl PgsqlState {
             // to avoid quadratic complexity
             let mut index = self.tx_index_completed;
             for tx_old in &mut self.transactions.range_mut(self.tx_index_completed..) {
-                index = index + 1;
+                index += 1;
                 if tx_old.tx_state < PgsqlTransactionState::ResponseDone {
                     tx_old.tx_state = PgsqlTransactionState::FlushedOut;
                     //TODO set event
index c713dea42a17179ee1a00b428547c4375b880af2..b587d0411fe5cc96fbf37815ec67335ac93c5186 100644 (file)
@@ -167,7 +167,7 @@ fn parse_padding_frame(input: &[u8]) -> IResult<&[u8], Frame, QuicError> {
         if input[offset] != 0 {
             break;
         }
-        offset = offset + 1;
+        offset += 1;
     }
     return Ok((&input[offset..], Frame::Padding));
 }
index 33774f3e1d3a7c569f03463c66ad280c7296cca9..b21c016a1a731c5bb2464794fbcd7b6eb8dfde7d 100644 (file)
@@ -356,7 +356,7 @@ fn smb_dcerpc_response_bindack(
                             }
                             ifaces[i].ack_result = r.ack_result;
                             ifaces[i].acked = true;
-                            i = i + 1;
+                            i += 1;
                         }
                     },
                     _ => {},
index 9ff56979dd30c2e68ed3fc86ffaff433523744ca..35fb59bec293f32902fc68ddbf59bb24e81c36b0 100644 (file)
@@ -1386,7 +1386,7 @@ impl SMBState {
                         if consumed < 4 {
                             consumed = 0;
                         } else {
-                            consumed = consumed - 3;
+                            consumed -= 3;
                         }
                         SCLogDebug!("smb record NOT found");
                         return AppLayerResult::incomplete(consumed as u32, 8);
@@ -1718,7 +1718,7 @@ impl SMBState {
                         if consumed < 4 {
                             consumed = 0;
                         } else {
-                            consumed = consumed - 3;
+                            consumed -= 3;
                         }
                         SCLogDebug!("smb record NOT found");
                         return AppLayerResult::incomplete(consumed as u32, 8);
index 17389799e629036d2cc499687a80cfebe04a809c..28ff70a066fa7cf214ea1e4621efa401889c50a5 100644 (file)
@@ -439,7 +439,7 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
                                     if guid_key.msg_id == 0 {
                                         b"<unknown>".to_vec()
                                     } else {
-                                        guid_key.msg_id = guid_key.msg_id - 1;
+                                        guid_key.msg_id -= 1;
                                         match state.ssn2vec_map.get(&guid_key) {
                                             Some(n) => { n.to_vec() },
                                             None => { b"<unknown>".to_vec()},
index 63d0f07884eb83b1e7ee7ab9400231718c0cf0d8..4baa61e3359862c49bd07f1de74d627dfd9afe64 100644 (file)
@@ -606,7 +606,7 @@ fn smb_basic_search(d: &[u8]) -> usize {
         if window == needle {
             return r;
         }
-        r = r + 1;
+        r += 1;
     }
     return 0;
 }