rust: fix clippy lints for clippy::bool_comparison

pull/8073/head
Jason Ish 2 years ago committed by Victor Julien
parent e373d9f5e0
commit 6b71d69356

@ -268,7 +268,7 @@ impl AppLayerResult {
impl From<bool> for AppLayerResult {
fn from(v: bool) -> Self {
if v == false {
if !v {
Self::err()
} else {
Self::ok()

@ -565,7 +565,7 @@ impl DCERPCState {
SCLogDebug!("post_gap_housekeeping: done");
break;
}
if tx.req_done == false {
if !tx.req_done {
tx.req_lost = true;
}
tx.req_done = true;
@ -579,10 +579,10 @@ impl DCERPCState {
SCLogDebug!("post_gap_housekeeping: done");
break;
}
if tx.req_done == false {
if !tx.req_done {
tx.req_lost = true;
}
if tx.resp_done == false {
if !tx.resp_done {
tx.resp_lost = true;
}
tx.req_done = true;
@ -1080,7 +1080,7 @@ impl DCERPCState {
self.bytes_consumed += retval;
// If the query has been completed, clean the buffer and reset the direction
if self.query_completed == true {
if self.query_completed {
self.clean_buffer(direction);
self.reset_direction(direction);
}

@ -23,7 +23,7 @@ use crate::jsonbuilder::{JsonBuilder, JsonError};
fn log_dcerpc_header_tcp(
jsb: &mut JsonBuilder, state: &DCERPCState, tx: &DCERPCTransaction,
) -> Result<(), JsonError> {
if tx.req_done == true && tx.req_lost == false {
if tx.req_done && !tx.req_lost {
jsb.set_string("request", &dcerpc_type_string(tx.req_cmd))?;
match tx.req_cmd {
DCERPC_TYPE_REQUEST => {
@ -56,7 +56,7 @@ fn log_dcerpc_header_tcp(
jsb.set_string("request", "REQUEST_LOST")?;
}
if tx.resp_done == true && tx.resp_lost == false {
if tx.resp_done && !tx.resp_lost {
jsb.set_string("response", &dcerpc_type_string(tx.resp_cmd))?;
match tx.resp_cmd {
DCERPC_TYPE_RESPONSE => {
@ -83,7 +83,7 @@ fn log_dcerpc_header_tcp(
fn log_dcerpc_header_udp(
jsb: &mut JsonBuilder, _state: &DCERPCUDPState, tx: &DCERPCTransaction,
) -> Result<(), JsonError> {
if tx.req_done == true && tx.req_lost == false {
if tx.req_done && !tx.req_lost {
jsb.set_string("request", &dcerpc_type_string(tx.req_cmd))?;
match tx.req_cmd {
DCERPC_TYPE_REQUEST => {
@ -99,7 +99,7 @@ fn log_dcerpc_header_udp(
jsb.set_string("request", "REQUEST_LOST")?;
}
if tx.resp_done == true && tx.resp_lost == false {
if tx.resp_done && !tx.resp_lost {
jsb.set_string("response", &dcerpc_type_string(tx.resp_cmd))?;
match tx.resp_cmd {
DCERPC_TYPE_RESPONSE => {

@ -79,7 +79,7 @@ impl FileTransferTracker {
}
pub fn is_done(&self) -> bool {
self.file_open == false
!self.file_open
}
fn open(&mut self, config: &'static SuricataFileContext,
@ -112,7 +112,7 @@ impl FileTransferTracker {
}
pub fn create(&mut self, _name: &[u8], _file_size: u64) {
if self.file_open == true { panic!("close existing file first"); }
if self.file_open { panic!("close existing file first"); }
SCLogDebug!("CREATE: name {:?} file_size {}", _name, _file_size);
}
@ -146,13 +146,13 @@ impl FileTransferTracker {
self.fill_bytes = fill_bytes;
self.chunk_is_last = is_last;
if self.file_open == false {
if !self.file_open {
SCLogDebug!("NEW CHUNK: FILE OPEN");
self.track_id = *xid;
self.open(config, files, flags, name);
}
if self.file_open == true {
if self.file_open {
let res = self.update(files, flags, data, 0);
SCLogDebug!("NEW CHUNK: update res {:?}", res);
return res;
@ -173,7 +173,7 @@ impl FileTransferTracker {
if self.chunk_left == 0 && self.fill_bytes == 0 {
//SCLogDebug!("UPDATE: nothing to do");
if self.chunk_is_last == true {
if self.chunk_is_last {
SCLogDebug!("last empty chunk, closing");
self.close(files, flags);
self.chunk_is_last = false;
@ -199,7 +199,7 @@ impl FileTransferTracker {
if self.chunk_left <= data.len() as u32 {
let d = &data[0..self.chunk_left as usize];
if self.chunk_is_ooo == false {
if !self.chunk_is_ooo {
let res = files.file_append(&self.track_id, d, is_gap);
match res {
0 => { },
@ -246,7 +246,7 @@ impl FileTransferTracker {
} else {
self.chunk_left = 0;
if self.chunk_is_ooo == false {
if !self.chunk_is_ooo {
loop {
let _offset = self.tracked;
match self.chunks.remove(&self.tracked) {
@ -283,7 +283,7 @@ impl FileTransferTracker {
self.cur_ooo_chunk_offset = 0;
}
}
if self.chunk_is_last == true {
if self.chunk_is_last {
SCLogDebug!("last chunk, closing");
self.close(files, flags);
self.chunk_is_last = false;
@ -292,7 +292,7 @@ impl FileTransferTracker {
}
} else {
if self.chunk_is_ooo == false {
if !self.chunk_is_ooo {
let res = files.file_append(&self.track_id, data, is_gap);
match res {
0 => { },

@ -1984,7 +1984,7 @@ pub unsafe extern "C" fn rs_nfs_register_parser() {
ALPROTO_NFS = alproto;
let midstream = conf_get_bool("stream.midstream");
if midstream == true {
if midstream {
if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_TCP as u8,
parser.name, ALPROTO_NFS, 0, NFS_MIN_FRAME_LEN,
rs_nfs_probe_ms, rs_nfs_probe_ms) == 0 {

@ -194,7 +194,7 @@ pub fn smb_write_dcerpc_record<'b>(state: &mut SMBState,
/* if this isn't the first frag, simply update the existing
* tx with the additional stub data */
if dcer.packet_type == DCERPC_TYPE_REQUEST && dcer.first_frag == false {
if dcer.packet_type == DCERPC_TYPE_REQUEST && !dcer.first_frag {
SCLogDebug!("NOT the first frag. Need to find an existing TX");
match parse_dcerpc_request_record(dcer.data, dcer.frag_len, dcer.little_endian) {
Ok((_, recr)) => {
@ -258,7 +258,7 @@ pub fn smb_write_dcerpc_record<'b>(state: &mut SMBState,
}
},
DCERPC_TYPE_BIND => {
let brec = if dcer.little_endian == true {
let brec = if dcer.little_endian {
parse_dcerpc_bind_record(dcer.data)
} else {
parse_dcerpc_bind_record_big(dcer.data)
@ -271,7 +271,7 @@ pub fn smb_write_dcerpc_record<'b>(state: &mut SMBState,
if !bindr.ifaces.is_empty() {
let mut ifaces: Vec<DCERPCIface> = Vec::new();
for i in bindr.ifaces {
let x = if dcer.little_endian == true {
let x = if dcer.little_endian {
vec![i.iface[3], i.iface[2], i.iface[1], i.iface[0],
i.iface[5], i.iface[4], i.iface[7], i.iface[6],
i.iface[8], i.iface[9], i.iface[10], i.iface[11],

@ -199,7 +199,7 @@ pub fn smb2_read_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
if share_name.is_empty() && !is_pipe {
SCLogDebug!("SMBv2/READ: no tree connect seen, we don't know if we are a pipe");
if smb_dcerpc_probe(rd.data) == true {
if smb_dcerpc_probe(rd.data) {
SCLogDebug!("SMBv2/READ: looks like dcerpc");
// insert fake tree to assist in follow up lookups
let tree = SMBTree::new(b"suricata::dcerpc".to_vec(), true);
@ -339,7 +339,7 @@ pub fn smb2_write_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
if share_name.is_empty() && !is_pipe {
SCLogDebug!("SMBv2/WRITE: no tree connect seen, we don't know if we are a pipe");
if smb_dcerpc_probe(wr.data) == true {
if smb_dcerpc_probe(wr.data) {
SCLogDebug!("SMBv2/WRITE: looks like we have dcerpc");
let tree = SMBTree::new(b"suricata::dcerpc".to_vec(), true);

Loading…
Cancel
Save