From edae5cd6769c7eb825c5d0be9a432986b736a144 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 6 Apr 2025 10:25:56 -0400 Subject: [PATCH] test-distro: reduce indentation --- test-distro/src/depmod.rs | 49 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/test-distro/src/depmod.rs b/test-distro/src/depmod.rs index 1d5e64aa..c4dca8c5 100644 --- a/test-distro/src/depmod.rs +++ b/test-distro/src/depmod.rs @@ -41,36 +41,35 @@ fn main() -> anyhow::Result<()> { let mut output = BufWriter::new(&f); for entry in WalkDir::new(modules_dir) { let entry = entry.context("failed to read entry in walkdir")?; - if entry.file_type().is_file() { - let path = entry.path(); + if !entry.file_type().is_file() { + continue; + } + let path = entry.path(); - let module_name = path - .file_name() - .ok_or_else(|| anyhow!("{} does not have a file name", path.display()))? - .to_str() - .ok_or_else(|| anyhow!("{} is not valid utf-8", path.display()))?; + let module_name = path + .file_name() + .ok_or_else(|| anyhow!("{} does not have a file name", path.display()))? + .to_str() + .ok_or_else(|| anyhow!("{} is not valid utf-8", path.display()))?; - let (module_name, compressed) = - if let Some(module_name) = module_name.strip_suffix(".xz") { - (module_name, true) - } else { - (module_name, false) - }; + let (module_name, compressed) = if let Some(module_name) = module_name.strip_suffix(".xz") { + (module_name, true) + } else { + (module_name, false) + }; - let module_name = if let Some(module_name) = module_name.strip_suffix(".ko") { - module_name - } else { - // Not a kernel module - continue; - }; + let module_name = if let Some(module_name) = module_name.strip_suffix(".ko") { + module_name + } else { + // Not a kernel module + continue; + }; - let contents = read_to_end(path, compressed) - .with_context(|| format!("read_to_end({})", path.display()))?; + let contents = read_to_end(path, compressed) + .with_context(|| format!("read_to_end({})", path.display()))?; - read_aliases_from_module(&contents, module_name, &mut output).with_context(|| { - format!("failed to read aliases from module {}", path.display()) - })?; - } + read_aliases_from_module(&contents, module_name, &mut output) + .with_context(|| format!("failed to read aliases from module {}", path.display()))?; } Ok(()) }