]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: cargo clippy --all-features --fix --allow-no-vcs
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 4 Nov 2022 08:38:51 +0000 (09:38 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 8 Nov 2022 04:44:02 +0000 (06:44 +0200)
24 files changed:
rust/src/applayer.rs
rust/src/bittorrent_dht/bittorrent_dht.rs
rust/src/conf.rs
rust/src/dcerpc/dcerpc.rs
rust/src/dcerpc/dcerpc_udp.rs
rust/src/dns/log.rs
rust/src/http2/detect.rs
rust/src/mqtt/mqtt.rs
rust/src/mqtt/parser.rs
rust/src/nfs/log.rs
rust/src/nfs/nfs.rs
rust/src/nfs/nfs3_records.rs
rust/src/nfs/nfs4.rs
rust/src/nfs/rpc_records.rs
rust/src/pgsql/parser.rs
rust/src/pgsql/pgsql.rs
rust/src/smb/dcerpc.rs
rust/src/smb/log.rs
rust/src/smb/smb.rs
rust/src/smb/smb1_records.rs
rust/src/smb/smb2.rs
rust/src/snmp/detect.rs
rust/src/ssh/ssh.rs
rust/src/tftp/tftp.rs

index dbebdb53872ef142b5e686a11c3f2a665e077118..9a3687b56adfad1ffa3e927f6f69f5ab9719d681 100644 (file)
@@ -167,7 +167,7 @@ impl AppLayerTxData {
     }
 
     pub fn set_event(&mut self, event: u8) {
-        core::sc_app_layer_decoder_events_set_event_raw(&mut self.events, event as u8);
+        core::sc_app_layer_decoder_events_set_event_raw(&mut self.events, event);
     }
 
     pub fn update_file_flags(&mut self, state_flags: u16) {
@@ -583,7 +583,7 @@ pub unsafe fn get_event_info_by_id<T: AppLayerEvent>(
     event_name: *mut *const std::os::raw::c_char,
     event_type: *mut core::AppLayerEventType,
 ) -> i8 {
-    if let Some(e) = T::from_id(event_id as i32) {
+    if let Some(e) = T::from_id(event_id) {
         *event_name = e.to_cstring().as_ptr() as *const std::os::raw::c_char;
         *event_type = core::APP_LAYER_EVENT_TYPE_TRANSACTION;
         return 0;
index 0e0d77fd87a6525bbcccb5d34db202d0adca938a..1a788ae6e10649cfbd7121b6b2196c0d0010ba5f 100644 (file)
@@ -281,7 +281,7 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() {
         }
 
         if AppLayerProtoDetectPMRegisterPatternCS(
-            IPPROTO_UDP as u8,
+            IPPROTO_UDP,
             ALPROTO_BITTORRENT_DHT,
             BITTORRENT_DHT_PAYLOAD_PREFIX.as_ptr() as *const c_char,
             BITTORRENT_DHT_PAYLOAD_PREFIX.len() as u16 - 1,
@@ -292,7 +292,7 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() {
             SCLogDebug!("Failed to register protocol detection pattern for direction TOSERVER");
         };
         if AppLayerProtoDetectPMRegisterPatternCS(
-            IPPROTO_UDP as u8,
+            IPPROTO_UDP,
             ALPROTO_BITTORRENT_DHT,
             BITTORRENT_DHT_PAYLOAD_PREFIX.as_ptr() as *const c_char,
             BITTORRENT_DHT_PAYLOAD_PREFIX.len() as u16 - 1,
index 94a868566d51f472ce9de9f0fc89865c26f6ae75..0dae7a013a64914a1ecb075c5dfe03378d18d599 100644 (file)
@@ -181,7 +181,7 @@ pub fn get_memval(arg: &str) -> Result<u64, &'static str> {
     if unit.is_empty() {
         unit = "B";
     }
-    let unit = get_memunit(unit) as u64;
+    let unit = get_memunit(unit);
     if unit == 0 {
         return Err("Invalid memory unit");
     }
index 93ff5116214f032f347090c4db25b9009fd1065e..40609bda9f786cf2aacbefe2fefc438f496536e1 100644 (file)
@@ -362,7 +362,7 @@ impl DCERPCState {
         let mut index = 0;
         for i in 0..len {
             let tx = &self.transactions[i];
-            if tx.id as u64 == tx_id { //+ 1 {
+            if tx.id == tx_id { //+ 1 {
                 found = true;
                 index = i;
                 SCLogDebug!("tx {} progress {}/{}", tx.id, tx.req_done, tx.resp_done);
@@ -839,7 +839,7 @@ impl DCERPCState {
     /// * Failure: -1 in case fragment length defined by header mismatches the data.
     pub fn handle_common_stub(&mut self, input: &[u8], bytes_consumed: u16, dir: Direction) -> i32 {
         let fraglen = self.get_hdr_fraglen().unwrap_or(0);
-        if fraglen < bytes_consumed as u16 + DCERPC_HDR_LEN {
+        if fraglen < bytes_consumed + DCERPC_HDR_LEN {
             return -1;
         }
         self.padleft = fraglen - DCERPC_HDR_LEN - bytes_consumed;
@@ -1189,7 +1189,7 @@ pub extern "C" fn rs_dcerpc_state_free(state: *mut std::os::raw::c_void) {
 #[no_mangle]
 pub unsafe extern "C" fn rs_dcerpc_state_transaction_free(state: *mut std::os::raw::c_void, tx_id: u64) {
     let dce_state = cast_pointer!(state, DCERPCState);
-    SCLogDebug!("freeing tx {}", tx_id as u64);
+    SCLogDebug!("freeing tx {}", tx_id);
     dce_state.free_tx(tx_id);
 }
 
@@ -1321,13 +1321,13 @@ pub unsafe extern "C" fn rs_dcerpc_probe_tcp(_f: *const core::Flow, direction: u
 
 fn register_pattern_probe() -> i8 {
     unsafe {
-        if AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_DCERPC,
+        if AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_DCERPC,
                                                      b"|05 00|\0".as_ptr() as *const std::os::raw::c_char, 2, 0,
                                                      Direction::ToServer.into(), rs_dcerpc_probe_tcp, 0, 0) < 0 {
             SCLogDebug!("TOSERVER => AppLayerProtoDetectPMRegisterPatternCSwPP FAILED");
             return -1;
         }
-        if AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_DCERPC,
+        if AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_DCERPC,
                                                      b"|05 00|\0".as_ptr() as *const std::os::raw::c_char, 2, 0,
                                                      Direction::ToClient.into(), rs_dcerpc_probe_tcp, 0, 0) < 0 {
             SCLogDebug!("TOCLIENT => AppLayerProtoDetectPMRegisterPatternCSwPP FAILED");
index 85618ac200d0e7a3b2fd31591a476d8b4f066c97..b9ac7fe71fddc49da280614250158e413a0d00e1 100644 (file)
@@ -92,7 +92,7 @@ impl DCERPCUDPState {
         let mut index = 0;
         for i in 0..len {
             let tx = &self.transactions[i];
-            if tx.id as u64 == tx_id { //+ 1 {
+            if tx.id == tx_id { //+ 1 {
                 found = true;
                 index = i;
                 SCLogDebug!("tx {} progress {}/{}", tx.id, tx.req_done, tx.resp_done);
@@ -244,7 +244,7 @@ pub unsafe extern "C" fn rs_dcerpc_udp_state_transaction_free(
     state: *mut std::os::raw::c_void, tx_id: u64,
 ) {
     let dce_state = cast_pointer!(state, DCERPCUDPState);
-    SCLogDebug!("freeing tx {}", tx_id as u64);
+    SCLogDebug!("freeing tx {}", tx_id);
     dce_state.free_tx(tx_id);
 }
 
@@ -319,7 +319,7 @@ pub unsafe extern "C" fn rs_dcerpc_probe_udp(_f: *const core::Flow, direction: u
 
 fn register_pattern_probe() -> i8 {
     unsafe {
-        if AppLayerProtoDetectPMRegisterPatternCSwPP(core::IPPROTO_UDP as u8, ALPROTO_DCERPC,
+        if AppLayerProtoDetectPMRegisterPatternCSwPP(core::IPPROTO_UDP, ALPROTO_DCERPC,
                                                      b"|04 00|\0".as_ptr() as *const std::os::raw::c_char, 2, 0,
                                                      Direction::ToServer.into(), rs_dcerpc_probe_udp, 0, 0) < 0 {
             SCLogDebug!("TOSERVER => AppLayerProtoDetectPMRegisterPatternCSwPP FAILED");
index 262a3c202fe7f3361d7794df6ccec44812ee7284..0e131796ab0351ba420bdb2ac78029f1faf898ac 100644 (file)
@@ -670,7 +670,7 @@ pub extern "C" fn rs_dns_log_json_answer(tx: &mut DNSTransaction,
     if let &Some(ref response) = &tx.response {
         for query in &response.queries {
             if dns_log_rrtype_enabled(query.rrtype, flags) {
-                return dns_log_json_answer(js, response, flags as u64).is_ok();
+                return dns_log_json_answer(js, response, flags).is_ok();
             }
         }
     }
index 515c9f471edcdc7ca51c34f88637473b9ae8ea26..59169aab26e69aecd1fd1674eb6ef0a4af94c458 100644 (file)
@@ -29,13 +29,13 @@ fn http2_tx_has_frametype(
 ) -> std::os::raw::c_int {
     if direction == Direction::ToServer {
         for i in 0..tx.frames_ts.len() {
-            if tx.frames_ts[i].header.ftype as u8 == value {
+            if tx.frames_ts[i].header.ftype == value {
                 return 1;
             }
         }
     } else {
         for i in 0..tx.frames_tc.len() {
-            if tx.frames_tc[i].header.ftype as u8 == value {
+            if tx.frames_tc[i].header.ftype == value {
                 return 1;
             }
         }
@@ -87,12 +87,12 @@ fn http2_tx_has_errorcode(
         for i in 0..tx.frames_tc.len() {
             match tx.frames_tc[i].data {
                 HTTP2FrameTypeData::GOAWAY(goaway) => {
-                    if goaway.errorcode as u32 == code {
+                    if goaway.errorcode == code {
                         return 1;
                     }
                 }
                 HTTP2FrameTypeData::RSTSTREAM(rst) => {
-                    if rst.errorcode as u32 == code {
+                    if rst.errorcode == code {
                         return 1;
                     }
                 }
index 0f85b2765373c2e8ac08a10f3447f0839c32c756..b55e8d29520a2fe2f8e8f7390eef2a9ac121f448 100644 (file)
@@ -526,7 +526,7 @@ impl MQTTState {
 
         while !current.is_empty() {
             SCLogDebug!("response: handling {}", current.len());
-            match parse_message(current, self.protocol_version, self.max_msg_len as usize) {
+            match parse_message(current, self.protocol_version, self.max_msg_len) {
                 Ok((rem, msg)) => {
                     SCLogDebug!("response msg {:?}", msg);
                     if let MQTTOperation::TRUNCATED(ref trunc) = msg.op {
index 190f88d2c47d00def85bca1cb8ead38cb8722eff..26984be118a1a759e4ff2bf5e593771c08262216 100644 (file)
@@ -166,7 +166,7 @@ pub fn parse_fixed_header(i: &[u8]) -> IResult<&[u8], FixedHeader> {
         FixedHeader {
             message_type: parse_message_type(flags.0),
             dup_flag: flags.1 != 0,
-            qos_level: flags.2 as u8,
+            qos_level: flags.2,
             retain: flags.3 != 0,
             remaining_length,
         },
@@ -207,7 +207,7 @@ fn parse_connect(i: &[u8]) -> IResult<&[u8], MQTTConnectData> {
             username_flag: flags.0 != 0,
             password_flag: flags.1 != 0,
             will_retain: flags.2 != 0,
-            will_qos: flags.3 as u8,
+            will_qos: flags.3,
             will_flag: flags.4 != 0,
             clean_session: flags.5 != 0,
             keepalive,
index edcb21d833c21107c9a8953bb1abfe44e717c576..f6fdc8f5828a057170395edecb726bae3b969ef5 100644 (file)
@@ -105,7 +105,7 @@ fn nfs_common_header(state: &NFSState, tx: &NFSTransaction, js: &mut JsonBuilder
         let s = format!("{:x}", c);
         js.set_string("hhash", &s)?;
     }
-    js.set_uint("id", tx.id as u64)?;
+    js.set_uint("id", tx.id)?;
     js.set_bool("file_tx", tx.is_file_tx)?;
     Ok(())
 }
index 9ca0fcf4feb8c6f39c2848fd877f5e01120b5ba1..8335fe744a9fa8c7ea482d025f5550193e6d16c3 100644 (file)
@@ -1569,7 +1569,7 @@ pub extern "C" fn rs_nfs_parse_request_tcp_gap(
                                         input_len: u32)
                                         -> AppLayerResult
 {
-    state.parse_tcp_data_ts_gap(input_len as u32)
+    state.parse_tcp_data_ts_gap(input_len)
 }
 
 #[no_mangle]
@@ -1598,7 +1598,7 @@ pub extern "C" fn rs_nfs_parse_response_tcp_gap(
                                         input_len: u32)
                                         -> AppLayerResult
 {
-    state.parse_tcp_data_tc_gap(input_len as u32)
+    state.parse_tcp_data_tc_gap(input_len)
 }
 
 /// C binding to parse an NFS/UDP request. Returns 1 on success, -1 on failure.
@@ -1701,7 +1701,7 @@ pub unsafe extern "C" fn rs_nfs_tx_get_procedures(tx: &mut NFSTransaction,
                                            -> u8
 {
     if i == 0 {
-        *procedure = tx.procedure as u32;
+        *procedure = tx.procedure;
         return 1;
     }
 
@@ -1715,7 +1715,7 @@ pub unsafe extern "C" fn rs_nfs_tx_get_procedures(tx: &mut NFSTransaction,
         let idx = i as usize - 1;
         if idx < tdf.file_additional_procs.len() {
             let p = tdf.file_additional_procs[idx];
-            *procedure = p as u32;
+            *procedure = p;
             return 1;
         }
     }
@@ -1985,20 +1985,20 @@ pub unsafe extern "C" fn rs_nfs_register_parser() {
 
         let midstream = conf_get_bool("stream.midstream");
         if midstream {
-            if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_TCP as u8,
+            if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_TCP,
                     parser.name, ALPROTO_NFS, 0, NFS_MIN_FRAME_LEN,
                     rs_nfs_probe_ms, rs_nfs_probe_ms) == 0 {
                 SCLogDebug!("No NFSTCP app-layer configuration, enabling NFSTCP
                             detection TCP detection on port {:?}.",
                             default_port);
                 /* register 'midstream' probing parsers if midstream is enabled. */
-                AppLayerProtoDetectPPRegister(IPPROTO_TCP as u8,
+                AppLayerProtoDetectPPRegister(IPPROTO_TCP,
                     default_port.as_ptr(), ALPROTO_NFS, 0,
                     NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
                     rs_nfs_probe_ms, rs_nfs_probe_ms);
             }
         } else {
-            AppLayerProtoDetectPPRegister(IPPROTO_TCP as u8,
+            AppLayerProtoDetectPPRegister(IPPROTO_TCP,
                 default_port.as_ptr(), ALPROTO_NFS, 0,
                 NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
                 rs_nfs_probe, rs_nfs_probe);
@@ -2062,13 +2062,13 @@ pub unsafe extern "C" fn rs_nfs_udp_register_parser() {
         let alproto = AppLayerRegisterProtocolDetection(&parser, 1);
         ALPROTO_NFS = alproto;
 
-        if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_UDP as u8,
+        if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_UDP,
                 parser.name, ALPROTO_NFS, 0, NFS_MIN_FRAME_LEN,
                 rs_nfs_probe_udp_ts, rs_nfs_probe_udp_tc) == 0 {
             SCLogDebug!("No NFSUDP app-layer configuration, enabling NFSUDP
                         detection UDP detection on port {:?}.",
                         default_port);
-            AppLayerProtoDetectPPRegister(IPPROTO_UDP as u8,
+            AppLayerProtoDetectPPRegister(IPPROTO_UDP,
                 default_port.as_ptr(), ALPROTO_NFS, 0,
                 NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
                 rs_nfs_probe_udp_ts, rs_nfs_probe_udp_tc);
index 8348ea7102d27c5266877ed7418f28943b469930..a4d90e4ae0ee6bc939c17f1319293ef9be29ef83 100644 (file)
@@ -341,15 +341,15 @@ pub struct Nfs3RequestWrite<'a> {
 
 /// Complete data expected
 fn parse_nfs3_data_complete(i: &[u8], file_len: usize, fill_bytes: usize) -> IResult<&[u8], &[u8]> {
-    let (i, file_data) = take(file_len as usize)(i)?;
+    let (i, file_data) = take(file_len)(i)?;
     let (i, _) = cond(fill_bytes > 0, take(fill_bytes))(i)?;
     Ok((i, file_data))
 }
 
 /// Partial data. We have all file_len, but need to consider fill_bytes
 fn parse_nfs3_data_partial(i: &[u8], file_len: usize, fill_bytes: usize) -> IResult<&[u8], &[u8]> {
-    let (i, file_data) = take(file_len as usize)(i)?;
-    let fill_bytes = cmp::min(fill_bytes as usize, i.len());
+    let (i, file_data) = take(file_len)(i)?;
+    let fill_bytes = cmp::min(fill_bytes, i.len());
     let (i, _) = cond(fill_bytes > 0, take(fill_bytes))(i)?;
     Ok((i, file_data))
 }
index 96ba21459e7d0c75912d062f2f487c1db49af516..bcfcb00532ee0b4bcf3878f488fa2a237a8703a8 100644 (file)
@@ -104,7 +104,7 @@ impl NFSState {
         }
         self.ts_chunk_xid = r.hdr.xid;
         debug_validate_bug_on!(w.data.len() as u32 > w.write_len);
-        self.ts_chunk_left = w.write_len as u32 - w.data.len()  as u32;
+        self.ts_chunk_left = w.write_len - w.data.len()  as u32;
     }
 
     fn close_v4<'b>(&mut self, r: &RpcPacket<'b>, fh: &'b [u8]) {
index 66075fd82d92b420ab87873c1cfc1d3973f62516..d373ae936ed61fc0ffbdf2f6fe22ccafc151b831 100644 (file)
@@ -242,11 +242,11 @@ pub fn parse_rpc(start_i: &[u8], complete: bool) -> IResult<&[u8], RpcPacket> {
     let (i, verifier) = take(verifier_len as usize)(i)?;
 
     let consumed = start_i.len() - i.len();
-    if consumed > rec_size as usize {
+    if consumed > rec_size {
         return Err(Err::Error(make_error(i, ErrorKind::LengthValue)));
     }
 
-    let data_size : u32 = (rec_size as usize - consumed) as u32;
+    let data_size : u32 = (rec_size - consumed) as u32;
     let (i, prog_data) = if !complete {
         rest(i)?
     } else {
index 14be325c71bcc8eed1ec905b0aab4ef3bde19568..e4fffa5fa44409b0ca8f0b588b4ca5e78e581a58 100644 (file)
@@ -564,7 +564,7 @@ pub fn pgsql_parse_startup_parameters(i: &[u8]) -> IResult<&[u8], PgsqlStartupPa
             }
         }
         params.remove(index);
-        if user.value.len() == 0 {
+        if user.value.is_empty() {
             return Err(Err::Error(make_error(i, ErrorKind::Tag)));
         }
         return Ok((i, PgsqlStartupParameters{
index b6ed75b31c1627682f6f26ac31706e85648ed391..0a0eaaaf4b7fe58ea0f0151be7344d5e1ae572c1 100644 (file)
@@ -757,7 +757,7 @@ pub unsafe extern "C" fn rs_pgsql_register_parser() {
                     SCLogError!("Invalid depth value");
                 }
             }
-            AppLayerParserSetStreamDepth(IPPROTO_TCP as u8, ALPROTO_PGSQL, stream_depth)
+            AppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_PGSQL, stream_depth)
         }
         if let Some(val) = conf_get("app-layer.protocols.pgsql.max-tx") {
             if let Ok(v) = val.parse::<usize>() {
index 25fec7d12aa6396a6bc3081b32907cc1dcb8c48d..eea9f64d37cf42a1a2adaa8f816a9accfa0bfd16 100644 (file)
@@ -36,7 +36,7 @@ impl SMBCommonHdr {
         match vercmd.get_version() {
             2 => {
                 let (_, cmd2) = vercmd.get_smb2_cmd();
-                let x = match cmd2 as u16 {
+                let x = match cmd2 {
                     SMB2_COMMAND_READ => { 0 },
                     SMB2_COMMAND_WRITE => { 0 },
                     SMB2_COMMAND_IOCTL => { self.msg_id },
@@ -459,7 +459,7 @@ pub fn smb_read_dcerpc_record<'b>(state: &mut SMBState,
     SCLogDebug!("lets first see if we have prior data");
     // msg_id 0 as this data crosses cmd/reply pairs
     let ehdr = SMBHashKeyHdrGuid::new(SMBCommonHdr::new(SMBHDR_TYPE_TRANS_FRAG,
-            hdr.ssn_id as u64, hdr.tree_id as u32, 0_u64), guid.to_vec());
+            hdr.ssn_id, hdr.tree_id, 0_u64), guid.to_vec());
     let mut prevdata = match state.ssnguid2vec_map.remove(&ehdr) {
         Some(s) => s,
         None => Vec::new(),
index 747606ed06bb065bda81b54f5a32e1b153dd6568..9149b8c0764a19979f288e69805dd3ef6573aca3 100644 (file)
@@ -67,7 +67,7 @@ fn guid_to_string(guid: &Vec<u8>) -> String {
 
 fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransaction) -> Result<(), JsonError>
 {
-    jsb.set_uint("id", tx.id as u64)?;
+    jsb.set_uint("id", tx.id)?;
 
     if state.dialect != 0 {
         let dialect = &smb2_dialect_string(state.dialect);
@@ -136,7 +136,7 @@ fn smb_common_header(jsb: &mut JsonBuilder, state: &SMBState, tx: &SMBTransactio
     }
 
 
-    jsb.set_uint("session_id", tx.hdr.ssn_id as u64)?;
+    jsb.set_uint("session_id", tx.hdr.ssn_id)?;
     jsb.set_uint("tree_id", tx.hdr.tree_id as u64)?;
 
     debug_add_progress(jsb, tx)?;
index ac1c266ce85b91a63d85a78ce01afc80481b1bd3..195d4efd557abf7d2b77636da7a41ea8fe0a0920 100644 (file)
@@ -578,7 +578,7 @@ impl SMBCommonHdr {
         };
         let msg_id = match rec_type {
             SMBHDR_TYPE_TRANS_FRAG | SMBHDR_TYPE_SHARE => { 0 },
-            _ => { r.message_id as u64 },
+            _ => { r.message_id },
         };
 
         SMBCommonHdr {
@@ -597,7 +597,7 @@ impl SMBCommonHdr {
         // cf https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/ea4560b7-90da-4803-82b5-344754b92a79
         let msg_id = match rec_type {
             SMBHDR_TYPE_TRANS_FRAG | SMBHDR_TYPE_SHARE => { 0 },
-            _ => { r.message_id as u64 },
+            _ => { r.message_id },
         };
 
         SMBCommonHdr {
@@ -1209,7 +1209,7 @@ impl SMBState {
         let _smb1_hdr = Frame::new(flow, stream_slice, input, 32_i64, SMBFrameType::SMB1Hdr as u8);
         SCLogDebug!("SMBv1 HDR frame {:?}", _smb1_hdr);
         if input.len() > 32 {
-            let _smb1_data = Frame::new(flow, stream_slice, &input[32..], (nbss_len - 32) as i64, SMBFrameType::SMB1Data as u8);
+            let _smb1_data = Frame::new(flow, stream_slice, &input[32..], nbss_len - 32, SMBFrameType::SMB1Data as u8);
             SCLogDebug!("SMBv1 DATA frame {:?}", _smb1_data);
         }
     }
@@ -1237,7 +1237,7 @@ impl SMBState {
         let _smb3_hdr = Frame::new(flow, stream_slice, input, 52_i64, SMBFrameType::SMB3Hdr as u8);
         SCLogDebug!("SMBv3 HDR frame {:?}", _smb3_hdr);
         if input.len() > 52 {
-            let _smb3_data = Frame::new(flow, stream_slice, &input[52..], (nbss_len - 52) as i64, SMBFrameType::SMB3Data as u8);
+            let _smb3_data = Frame::new(flow, stream_slice, &input[52..], nbss_len - 52, SMBFrameType::SMB3Data as u8);
             SCLogDebug!("SMBv3 DATA frame {:?}", _smb3_data);
         }
     }
@@ -1385,7 +1385,7 @@ impl SMBState {
                             consumed -= 3;
                         }
                         SCLogDebug!("smb record NOT found");
-                        return AppLayerResult::incomplete(consumed as u32, 8);
+                        return AppLayerResult::incomplete(consumed, 8);
                     },
                 }
             }
@@ -1508,7 +1508,7 @@ impl SMBState {
                             SCLogDebug!("setting consumed {} need {} needed {:?} total input {}",
                                     total_consumed, n, needed, stream_slice.len());
                             let need = n;
-                            return AppLayerResult::incomplete(total_consumed as u32, need as u32);
+                            return AppLayerResult::incomplete(total_consumed, need as u32);
                         }
                         // tracking a write record, which we don't need to
                         // queue up at the stream level, but can feed to us
@@ -1553,7 +1553,7 @@ impl SMBState {
         let _smb1_hdr = Frame::new(flow, stream_slice, input, SMB1_HEADER_SIZE as i64, SMBFrameType::SMB1Hdr as u8);
         SCLogDebug!("SMBv1 HDR frame {:?}", _smb1_hdr);
         if input.len() > SMB1_HEADER_SIZE {
-            let _smb1_data = Frame::new(flow, stream_slice, &input[SMB1_HEADER_SIZE..], (nbss_len - SMB1_HEADER_SIZE as i64) as i64,
+            let _smb1_data = Frame::new(flow, stream_slice, &input[SMB1_HEADER_SIZE..], nbss_len - SMB1_HEADER_SIZE as i64,
                     SMBFrameType::SMB1Data as u8);
             SCLogDebug!("SMBv1 DATA frame {:?}", _smb1_data);
         }
@@ -1581,7 +1581,7 @@ impl SMBState {
         let _smb3_hdr = Frame::new(flow, stream_slice, input, 52_i64, SMBFrameType::SMB3Hdr as u8);
         SCLogDebug!("SMBv3 HDR frame {:?}", _smb3_hdr);
         if input.len() > 52 {
-            let _smb3_data = Frame::new(flow, stream_slice, &input[52..], (nbss_len - 52) as i64, SMBFrameType::SMB3Data as u8);
+            let _smb3_data = Frame::new(flow, stream_slice, &input[52..], nbss_len - 52, SMBFrameType::SMB3Data as u8);
             SCLogDebug!("SMBv3 DATA frame {:?}", _smb3_data);
         }
     }
@@ -1717,7 +1717,7 @@ impl SMBState {
                             consumed -= 3;
                         }
                         SCLogDebug!("smb record NOT found");
-                        return AppLayerResult::incomplete(consumed as u32, 8);
+                        return AppLayerResult::incomplete(consumed, 8);
                     },
                 }
             }
@@ -1829,7 +1829,7 @@ impl SMBState {
                             SCLogDebug!("setting consumed {} need {} needed {:?} total input {}",
                                     total_consumed, n, needed, stream_slice.len());
                             let need = n;
-                            return AppLayerResult::incomplete(total_consumed as u32, need as u32);
+                            return AppLayerResult::incomplete(total_consumed, need as u32);
                         }
                         // tracking a read record, which we don't need to
                         // queue up at the stream level, but can feed to us
@@ -1973,7 +1973,7 @@ pub extern "C" fn rs_smb_parse_request_tcp_gap(
                                         input_len: u32)
                                         -> AppLayerResult
 {
-    state.parse_tcp_data_ts_gap(input_len as u32)
+    state.parse_tcp_data_ts_gap(input_len)
 }
 
 
@@ -2008,7 +2008,7 @@ pub extern "C" fn rs_smb_parse_response_tcp_gap(
                                         input_len: u32)
                                         -> AppLayerResult
 {
-    state.parse_tcp_data_tc_gap(input_len as u32)
+    state.parse_tcp_data_tc_gap(input_len)
 }
 
 fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, begins: bool) -> i8
@@ -2182,7 +2182,7 @@ pub unsafe extern "C" fn rs_smb_state_tx_free(state: *mut ffi::c_void,
                                        tx_id: u64)
 {
     let state = cast_pointer!(state, SMBState);
-    SCLogDebug!("freeing tx {}", tx_id as u64);
+    SCLogDebug!("freeing tx {}", tx_id);
     state.free_tx(tx_id);
 }
 
@@ -2279,24 +2279,24 @@ fn register_pattern_probe() -> i8 {
     let mut r = 0;
     unsafe {
         // SMB1
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|ff|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToServer as u8, rs_smb_probe_begins_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|ff|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToClient as u8, rs_smb_probe_begins_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
         // SMB2/3
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|fe|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToServer as u8, rs_smb_probe_begins_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|fe|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToClient as u8, rs_smb_probe_begins_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
         // SMB3 encrypted records
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|fd|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToServer as u8, smb3_probe_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
-        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP as u8, ALPROTO_SMB,
+        r |= AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_SMB,
                                                      b"|fd|SMB\0".as_ptr() as *const std::os::raw::c_char, 8, 4,
                                                      Direction::ToClient as u8, smb3_probe_tcp, MIN_REC_SIZE, MIN_REC_SIZE);
     }
@@ -2362,11 +2362,11 @@ pub unsafe extern "C" fn rs_smb_register_parser() {
         }
 
         let have_cfg = AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(),
-                    IPPROTO_TCP as u8, parser.name, ALPROTO_SMB, 0,
+                    IPPROTO_TCP, parser.name, ALPROTO_SMB, 0,
                     MIN_REC_SIZE, rs_smb_probe_tcp, rs_smb_probe_tcp);
 
         if have_cfg == 0 {
-            AppLayerProtoDetectPPRegister(IPPROTO_TCP as u8, default_port.as_ptr(), ALPROTO_SMB,
+            AppLayerProtoDetectPPRegister(IPPROTO_TCP, default_port.as_ptr(), ALPROTO_SMB,
                                           0, MIN_REC_SIZE, Direction::ToServer as u8, rs_smb_probe_tcp, rs_smb_probe_tcp);
         }
 
@@ -2385,7 +2385,7 @@ pub unsafe extern "C" fn rs_smb_register_parser() {
                 Err(_) => { SCLogError!("Invalid depth value"); }
             }
         }
-        AppLayerParserSetStreamDepth(IPPROTO_TCP as u8, ALPROTO_SMB, stream_depth);
+        AppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_SMB, stream_depth);
         let retval = conf_get("app-layer.protocols.smb.max-read-size");
         if let Some(val) = retval {
             match get_memval(val) {
index 7eb245c3c5eb6430c1ae2443f765d3eb70105b3d..569c7dfd947df65f78ddd6c785481e245c50bc8e 100644 (file)
@@ -115,7 +115,7 @@ pub fn parse_smb1_write_andx_request_record(i : &[u8], andx_offset: usize) -> IR
     let (i, file_data) = rest(i)?;
     let record = Smb1WriteRequestRecord {
         offset: high_offset.map(|ho| (ho as u64) << 32 | offset as u64).unwrap_or(0),
-        len: (((data_len_high as u32) << 16) as u32)|(data_len_low as u32),
+        len: ((data_len_high as u32) << 16)|(data_len_low as u32),
         fid,
         data: file_data,
     };
@@ -547,7 +547,7 @@ pub fn parse_smb_read_andx_response_record(i: &[u8]) -> IResult<&[u8], SmbRespon
     let (i, file_data) = rest(i)?;
 
     let record = SmbResponseReadAndXRecord {
-        len: (((data_len_high as u32) << 16)|data_len_low as u32),
+        len: ((data_len_high << 16)|data_len_low as u32),
         data: file_data,
    };
     Ok((i, record))
index 741f053b34ca664861d01c8496ef3525ca8643f1..dc0aeb5417c7757c81974989ad15e2276263e864 100644 (file)
@@ -105,7 +105,7 @@ fn smb2_read_response_record_generic<'b>(state: &mut SMBState, r: &Smb2Record<'b
 {
     if smb2_create_new_tx(r.command) {
         let tx_hdr = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
-        let tx = state.get_generic_tx(2, r.command as u16, &tx_hdr);
+        let tx = state.get_generic_tx(2, r.command, &tx_hdr);
         if let Some(tx) = tx {
             tx.set_status(r.nt_status, false);
             tx.response_done = true;
@@ -786,7 +786,7 @@ pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
                                 if let Some(SMBTransactionTypeData::TREECONNECT(ref mut tdn)) = tx.type_data {
                                     tdn.share_type = tr.share_type;
                                     tdn.is_pipe = is_pipe;
-                                    tdn.tree_id = r.tree_id as u32;
+                                    tdn.tree_id = r.tree_id;
                                     share_name = tdn.share_name.to_vec();
                                 }
                                 // update hdr now that we have a tree_id
index 75f6f05c71e57b0a4d368a90d3ebd1ef27f395c1..88e6432b23c84b1c1c80ce2af438a577cc56f90c 100644 (file)
@@ -22,7 +22,7 @@ use crate::snmp::snmp::SNMPTransaction;
 #[no_mangle]
 pub unsafe extern "C" fn rs_snmp_tx_get_version(tx: &mut SNMPTransaction, version: *mut u32) {
     debug_assert!(tx.version != 0, "SNMP version is 0");
-    *version = tx.version as u32;
+    *version = tx.version;
 }
 
 #[no_mangle]
@@ -42,7 +42,7 @@ pub unsafe extern "C" fn rs_snmp_tx_get_community(
 pub unsafe extern "C" fn rs_snmp_tx_get_pdu_type(tx: &mut SNMPTransaction, pdu_type: *mut u32) {
     match tx.info {
         Some(ref info) => {
-            *pdu_type = info.pdu_type.0 as u32;
+            *pdu_type = info.pdu_type.0;
         }
         None => {
             *pdu_type = 0xffffffff;
index 1f261b1dcddfb8e117e6b9e78e95300f6283c503..21c4d1ad3e9f8ef5711ee778d5d8e5c95ef82d68 100644 (file)
@@ -201,7 +201,7 @@ impl SSHState {
                                         hdr.record_left_msg = parser::MessageCode::Kexinit;
                                         return AppLayerResult::incomplete(
                                             (il - rem.len()) as u32,
-                                            (head.pkt_len - 2) as u32
+                                            head.pkt_len - 2
                                         );
                                     }
                                     else {
index b5453c2d339c9ab8f41b3897920b65129d38694b..a75a3cae0931f09b51d49ba5019866b70c45185a 100644 (file)
@@ -115,7 +115,7 @@ pub extern "C" fn rs_tftp_get_tx(state: &mut TFTPState,
 
 #[no_mangle]
 pub extern "C" fn rs_tftp_get_tx_cnt(state: &mut TFTPState) -> u64 {
-    return state.tx_id as u64;
+    return state.tx_id;
 }
 
 fn getstr(i: &[u8]) -> IResult<&[u8], &str> {