Actions
Task #9518
open
SB
PA
rust: enable clippy::unnecessary_wraps lint
Task #9518:
rust: enable clippy::unnecessary_wraps lint
Effort:
Difficulty:
Label:
Description
Requested by: @Philippe Antoine
Proposal: enable the clippy lint unnecessary_wraps (pedantic, so off by default) in the Rust code, e.g. #![deny(clippy::unnecessary_wraps)] in rust/src/lib.rs.
The lint flags private functions that always return Some(..) / Ok(..), so the Option/Result wrapper is useless and callers carry dead None/Err branches.
Example: https://github.com/OISF/suricata/pull/16836/changes/dbff0992492f28a265f27d756525ae8f93014716 — http2_frame_header_static() always returned Some, and its callers had unreachable None handling.
Current state¶
cargo clippy --workspace --all-features --all-targets -- --cap-lints warn -W clippy::unnecessary_wraps on main (d622b4f69, clippy 1.93.1) reports 30 sites:
suricata crate (7):
src/http2/parser.rs:http2_frame_header_static(fixed by the PR above)src/nfs/nfs4_records.rs:nfs4_req_getfh,nfs4_req_savefh,nfs4_req_putrootfhsrc/nfs/rpc_records.rs:parse_rpc_request_creds_unknownsrc/quic/frames.rs:parse_padding_framesrc/telnet/telnet.rs:probe
htp crate (23):
connection_parser.rs:finalize;request.rs:request_receiver_set;response.rs:response_receiver_set- 20 test callbacks in
htp/src/test/{common,hybrid,main}.rs
Notes¶
- The nom-style parsers (nfs, rpc, quic, telnet) keep the
IResultsignature for consistency with their sibling parsers in the samematchdispatch. They can be simplified (callers use?) or get a local#[allow(clippy::unnecessary_wraps)]; to be decided case by case. - The htp test callbacks must match the callback type, so they also need an allow (or the lint only enabled for non-test code).
- htp has
#![deny(warnings)], so enabling the lint there makes it a hard error.
PA Updated by Philippe Antoine 3 days ago
- Status changed from New to Assigned
Actions