From 10150e95ad0c6aa9e5af6f39f709e87b3b3b0ba9 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 27 Jun 2025 09:20:56 +0200 Subject: [PATCH] rust: allow collapsible_else_if for debug logs see https://github.com/rust-lang/rust-clippy/issues/15158 --- rust/src/smb/smb.rs | 8 ++++++++ rust/src/smb/smb2_ioctl.rs | 2 ++ rust/src/ssh/ssh.rs | 2 ++ 3 files changed, 12 insertions(+) diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 663f54ff59..e28d2627ee 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -1789,6 +1789,8 @@ impl SMBState { Ok((_, ref smb_record)) => { let pdu_frame = self.add_smb1_tc_pdu_frame(flow, stream_slice, nbss_hdr.data, nbss_hdr.length as i64); self.add_smb1_tc_hdr_data_frames(flow, stream_slice, nbss_hdr.data, nbss_hdr.length as i64); + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if smb_record.is_response() { smb1_response_record(self, smb_record); } else { @@ -1812,6 +1814,8 @@ impl SMBState { let record_len = (nbss_data.len() - nbss_data_rem.len()) as i64; let pdu_frame = self.add_smb2_tc_pdu_frame(flow, stream_slice, nbss_data, record_len); self.add_smb2_tc_hdr_data_frames(flow, stream_slice, nbss_data, record_len, smb_record.header_len as i64); + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if smb_record.is_response() { smb2_response_record(self, smb_record); } else { @@ -2094,6 +2098,8 @@ fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, be if smb.version == 0xff_u8 { // SMB1 SCLogDebug!("SMBv1 record"); if let Ok((_, ref smb_record)) = parse_smb_record(data) { + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if smb_record.flags & 0x80 != 0 { SCLogDebug!("RESPONSE {:02x}", smb_record.flags); if direction == Direction::ToServer { @@ -2110,6 +2116,8 @@ fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, be } else if smb.version == 0xfe_u8 { // SMB2 SCLogDebug!("SMB2 record"); if let Ok((_, ref smb_record)) = parse_smb2_record_direction(data) { + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if direction == Direction::ToServer { SCLogDebug!("direction Direction::ToServer smb_record {:?}", smb_record); if !smb_record.request { diff --git a/rust/src/smb/smb2_ioctl.rs b/rust/src/smb/smb2_ioctl.rs index 73687aa556..ff85a5fefb 100644 --- a/rust/src/smb/smb2_ioctl.rs +++ b/rust/src/smb/smb2_ioctl.rs @@ -98,6 +98,8 @@ pub fn smb2_ioctl_response_record(state: &mut SMBState, r: &Smb2Record) } else { false }; + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if is_dcerpc { SCLogDebug!("IOCTL response data is_pipe. Calling smb_read_dcerpc_record"); let vercmd = SMBVerCmdStat::new2_with_ntstatus(SMB2_COMMAND_IOCTL, r.nt_status); diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index f3e652ff1a..c50ae1459c 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -404,6 +404,8 @@ impl SSHState { return r; } Err(Err::Incomplete(_)) => { + // see https://github.com/rust-lang/rust-clippy/issues/15158 + #[allow(clippy::collapsible_else_if)] if input.len() < SSH_MAX_BANNER_LEN { //0 consumed, needs at least one more byte return AppLayerResult::incomplete(0_u32, (input.len() + 1) as u32);