misc/cleanup: remove rust if <cond> ....

Cleanup the few instances of rust where if cond return true else false
exist

rg = ripgrep

rg -n -U '^\s*if .* \{\s*\n\s*return true;\s*\n\s*\}\s*\n\s*return false;' rust/src/ --glob '*.rs'

rg -n -U '^\s*if .* \{\s*\n\s*return false;\s*\n\s*\}\s*\n\s*return true;' rust/src/ --glob '*.rs'
pull/15080/head
Jeff Lucovsky 1 month ago committed by Victor Julien
parent 022a79fdd5
commit 98070a7ace

@ -78,11 +78,7 @@ pub fn conf_get(key: &str) -> Option<&str> {
// Return the value of key as a boolean. A value that is not set is
// the same as having it set to false.
pub fn conf_get_bool(key: &str) -> bool {
if let Some("1" | "yes" | "true" | "on") = conf_get(key) {
return true;
}
return false;
matches!(conf_get(key), Some("1" | "yes" | "true" | "on"))
}
/// Wrap a Suricata ConfNode and expose some of its methods with a
@ -161,10 +157,7 @@ impl ConfNode {
}
}
if vptr == 1 {
return true;
}
return false;
return vptr == 1;
}
}

@ -70,13 +70,7 @@ pub struct DetectIPRepData {
}
pub fn is_alphanumeric_or_slash(chr: char) -> bool {
if chr.is_ascii_alphanumeric() {
return true;
}
if chr == '_' || chr == '-' {
return true;
}
return false;
return chr.is_ascii_alphanumeric() || chr == '_' || chr == '-';
}
pub fn detect_parse_iprep(i: &str) -> IResult<&str, DetectIPRepData, RuleParseError<&str>> {

@ -62,10 +62,7 @@ impl DHCPLogger {
pub fn do_log(&self, tx: &DHCPTransaction) -> bool {
if !self.extended {
if let Some(DHCP_TYPE_ACK) = self.get_type(tx) {
return true;
}
return false;
return matches!(self.get_type(tx), Some(DHCP_TYPE_ACK));
}
return true;
}

@ -64,10 +64,7 @@ impl MessageCode {
#[inline]
fn is_not_lineend(b: u8) -> bool {
if b == 10 || b == 13 {
return false;
}
return true;
return b != 10 && b != 13;
}
//may leave \r at the end to be removed

Loading…
Cancel
Save