From 7c293ff68fa47c811371a83cc05cffafca3bd58f Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Mon, 28 Nov 2022 16:38:40 -0600 Subject: [PATCH] rust/clippy: fix lint: never_loop --- rust/src/dns/log.rs | 3 +-- rust/src/dns/lua.rs | 4 ++-- rust/src/lib.rs | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/rust/src/dns/log.rs b/rust/src/dns/log.rs index 0e131796ab..9ae13be571 100644 --- a/rust/src/dns/log.rs +++ b/rust/src/dns/log.rs @@ -512,10 +512,9 @@ fn dns_log_json_answer(js: &mut JsonBuilder, response: &DNSResponse, flags: u64) js.set_bool("z", true)?; } - for query in &response.queries { + if let Some(query) = response.queries.first() { js.set_string_from_bytes("rrname", &query.name)?; js.set_string("rrtype", &dns_rrtype_string(query.rrtype))?; - break; } js.set_string("rcode", &dns_rcode_string(header.flags))?; diff --git a/rust/src/dns/lua.rs b/rust/src/dns/lua.rs index 29746231a3..c72c85aa6b 100644 --- a/rust/src/dns/lua.rs +++ b/rust/src/dns/lua.rs @@ -42,12 +42,12 @@ pub extern "C" fn rs_dns_lua_get_rrname(clua: &mut CLuaState, }; if let &Some(ref request) = &tx.request { - for query in &request.queries { + if let Some(query) = request.queries.first() { lua.pushstring(&String::from_utf8_lossy(&query.name)); return 1; } } else if let &Some(ref response) = &tx.response { - for query in &response.queries { + if let Some(query) = response.queries.first() { lua.pushstring(&String::from_utf8_lossy(&query.name)); return 1; } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 53b078dd5a..41c811bb89 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -34,7 +34,6 @@ #![allow(clippy::manual_find)] #![allow(clippy::match_like_matches_macro)] #![allow(clippy::module_inception)] -#![allow(clippy::never_loop)] #![allow(clippy::new_without_default)] #![allow(clippy::redundant_pattern_matching)] #![allow(clippy::result_unit_err)]