Skip to content

Commit

Permalink
clippy: ledger-tool lints (solana-labs#34640)
Browse files Browse the repository at this point in the history
warning: `flatten()` will run forever if the iterator repeatedly produces an `Err`
    --> ledger-tool/src/main.rs:2649:39
     |
2649 |                 for line in f.lines().flatten() {
     |                                       ^^^^^^^^^ help: replace with: `map_while(Result::ok)`
     |
note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error
    --> ledger-tool/src/main.rs:2649:29
     |
2649 |                 for line in f.lines().flatten() {
     |                             ^^^^^^^^^
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok
     = note: `#[warn(clippy::lines_filter_map_ok)]` on by default

warning: `solana-ledger-tool` (bin "solana-ledger-tool" test) generated 1 warning
  • Loading branch information
steviez authored Jan 3, 2024
1 parent 8330dee commit 1d93732
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ fn main() {
let log_file = PathBuf::from(value_t_or_exit!(arg_matches, "log_path", String));
let f = BufReader::new(File::open(log_file).unwrap());
println!("Reading log file");
for line in f.lines().flatten() {
for line in f.lines().map_while(Result::ok) {
let parse_results = {
if let Some(slot_string) = frozen_regex.captures_iter(&line).next() {
Some((slot_string, &mut frozen))
Expand Down

0 comments on commit 1d93732

Please sign in to comment.