gpu: nova-core: simplify and_then with condition to filter
Subsystems (4)
PATCH 1/1 gpu: nova-core: simplify and_then with condition to filter
This code is more simply expressed using Option::filter instead of the and_then with conditional.
--- drivers/gpu/nova-core/firmware.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/nova-core/firmware.rs +1 -7
@@ -388,13 +388,7 @@ fn new(fw: &'a firmware::Firmware) -> Result<Self> {// Extract header. .and_then(BinHdr::from_bytes_copy)// Validate header. - .and_then (|hdr| { -if hdr.bin_magic ==BIN_MAGIC { -Some (hdr) - }else { -None - } - }) + .filter (|hdr| hdr.bin_magic ==BIN_MAGIC ) .map (|hdr|Self { hdr, fw }) .ok_or (EINVAL ) }
---
base-commit: a7a080bb4236ebe577b6776d940d1717912ff6dd
change-id: 20260423-fix-filter-9a96711b734c
Best regards,
Signature · 1 line
Eliot Courtney <[email protected]>
Quoted 4 lines · Eliot Courtney
This code is more simply expressed using
Option::filterinstead of theand_thenwith conditional.Signed-off-by Eliot Courtney <[email protected]>
Quoted 3 lines
--- drivers/gpu/nova-core/firmware.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
Quoted 5 lines · Eliot Courtney
This code is more simply expressed using
Option::filterinstead of theand_thenwith conditional.Signed-off-by Eliot Courtney <[email protected]>
Quoted 4 lines · Eliot Courtney
This code is more simply expressed using
Option::filterinstead of theand_thenwith conditional.Signed-off-by Eliot Courtney <[email protected]>
Quoted 4 lines · Eliot Courtney
This code is more simply expressed using
Option::filterinstead of theand_thenwith conditional.Signed-off-by Eliot Courtney <[email protected]>
Applied to drm-rust, thanks!
I modified the commit message to quote the clippy warning fixed by this commit and added Fixes:/Cc: stable tags.
Alice