agent: Fix .enumerate errors during make check

Running `make check` in the `src/agent` directory gives:

```
error: you seem to use `.enumerate()` and immediately discard the index
   --> rustjail/src/mount.rs:572:27
    |
572 |     for (_index, line) in reader.lines().enumerate() {
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
    = note: `-D clippy::unused-enumerate-index` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unused_enumerate_index)]`
help: remove the `.enumerate()` call
    |
572 |     for line in reader.lines() {
    |         ~~~~    ~~~~~~~~~~~~~~

    Checking tokio-native-tls v0.3.1
    Checking hyper-tls v0.5.0
    Checking reqwest v0.11.18
error: could not compile `rustjail` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
make: *** [../../utils.mk:177: standard_rust_check] Error 101
```

Fixes: #9342

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
Christophe de Dinechin 2024-03-25 16:48:28 +01:00
parent e1068da1a0
commit bfb55312be
2 changed files with 3 additions and 3 deletions

View File

@ -569,7 +569,7 @@ pub fn parse_mount_table(mountinfo_path: &str) -> Result<Vec<Info>> {
let reader = BufReader::new(file);
let mut infos = Vec::new();
for (_index, line) in reader.lines().enumerate() {
for line in reader.lines() {
let line = line?;
//Example mountinfo format:

View File

@ -180,7 +180,7 @@ pub fn get_mount_fs_type_from_file(mount_file: &str, mount_point: &str) -> Resul
let re = Regex::new(format!("device .+ mounted on {} with fstype (.+)", mount_point).as_str())?;
// Read the file line by line using the lines() iterator from std::io::BufRead.
for (_index, line) in content.lines().enumerate() {
for line in content.lines() {
if let Some(capes) = re.captures(line) {
if capes.len() > 1 {
return Ok(capes[1].to_string());
@ -225,7 +225,7 @@ pub fn get_cgroup_mounts(
// #subsys_name hierarchy num_cgroups enabled
// fields[0] fields[1] fields[2] fields[3]
'outer: for (_, line) in reader.lines().enumerate() {
'outer: for line in reader.lines() {
let line = line?;
let fields: Vec<&str> = line.split('\t').collect();