From 5e830a85c8127e48f828c34725121e7231fcd800 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:11:49 -0400 Subject: [PATCH 1/9] ostree-ext: Fix clippy lints Signed-off-by: Colin Walters --- crates/ostree-ext/src/chunking.rs | 42 +++++++++---------- crates/ostree-ext/src/cli.rs | 14 +++---- .../ostree-ext/src/container/encapsulate.rs | 2 +- crates/ostree-ext/src/container/mod.rs | 4 +- crates/ostree-ext/src/container/store.rs | 8 ++-- .../ostree-ext/src/container/unencapsulate.rs | 2 +- crates/ostree-ext/src/diff.rs | 2 +- crates/ostree-ext/src/fixture.rs | 2 +- crates/ostree-ext/src/integrationtest.rs | 4 +- crates/ostree-ext/src/repair.rs | 2 +- crates/ostree-ext/src/tar/export.rs | 28 ++++++------- crates/ostree-ext/src/tar/import.rs | 8 ++-- crates/ostree-ext/src/tar/write.rs | 2 +- crates/ostree-ext/tests/it/main.rs | 12 ++---- 14 files changed, 61 insertions(+), 71 deletions(-) diff --git a/crates/ostree-ext/src/chunking.rs b/crates/ostree-ext/src/chunking.rs index ebde0916c..07366f06d 100644 --- a/crates/ostree-ext/src/chunking.rs +++ b/crates/ostree-ext/src/chunking.rs @@ -399,7 +399,7 @@ impl Chunking { let r = bin.iter().map(|v| &*v.meta.identifier).skip(1).fold( String::from(first_name), |mut acc, v| { - write!(acc, " and {}", v).unwrap(); + write!(acc, " and {v}").unwrap(); acc }, ); @@ -478,12 +478,12 @@ fn packing_size(packing: &[Vec<&ObjectSourceMetaSized>]) -> u64 { /// of (high, medium, low) size and (high,medium,low) using the following /// outlier detection methods: /// - Median and Median Absolute Deviation Method -/// Aggressively detects outliers in size and classifies them by -/// high, medium, low. The high size and low size are separate partitions -/// and deserve bins of their own +/// Aggressively detects outliers in size and classifies them by +/// high, medium, low. The high size and low size are separate partitions +/// and deserve bins of their own /// - Mean and Standard Deviation Method -/// The medium partition from the previous step is less aggressively -/// classified by using mean for both size and frequency +/// The medium partition from the previous step is less aggressively +/// classified by using mean for both size and frequency /// /// Note: Assumes components is sorted by descending size fn get_partitions_with_threshold<'a>( @@ -1075,9 +1075,9 @@ mod test { .iter() .map(|&(id, freq, size)| ObjectSourceMetaSized { meta: ObjectSourceMeta { - identifier: RcStr::from(format!("pkg{}.0", id)), - name: RcStr::from(format!("pkg{}", id)), - srcid: RcStr::from(format!("srcpkg{}", id)), + identifier: RcStr::from(format!("pkg{id}.0")), + name: RcStr::from(format!("pkg{id}")), + srcid: RcStr::from(format!("srcpkg{id}")), change_time_offset: 0, change_frequency: freq, }, @@ -1089,7 +1089,7 @@ mod test { let mut object_map = IndexMap::new(); for (i, component) in contentmeta.iter().enumerate() { - let checksum = format!("checksum_{}", i); + let checksum = format!("checksum_{i}"); object_map.insert(checksum, component.meta.identifier.clone()); } @@ -1109,12 +1109,12 @@ mod test { // Add fake objects to the remainder chunk if specified if let Some(num_objects) = num_fake_objects { for i in 0..num_objects { - let checksum = format!("checksum_{}", i); + let checksum = format!("checksum_{i}"); chunking.remainder.content.insert( RcStr::from(checksum), ( 1000, - vec![Utf8PathBuf::from(format!("/path/to/checksum_{}", i))], + vec![Utf8PathBuf::from(format!("/path/to/checksum_{i}"))], ), ); chunking.remainder.size += 1000; @@ -1329,7 +1329,7 @@ mod test { .iter() .map(|obj| { ( - Utf8PathBuf::from(format!("/path/to/{}", obj)), + Utf8PathBuf::from(format!("/path/to/{obj}")), obj.to_string(), ) }) @@ -1341,7 +1341,7 @@ mod test { .iter() .map(|obj| { ( - Utf8PathBuf::from(format!("/path/to/{}", obj)), + Utf8PathBuf::from(format!("/path/to/{obj}")), obj.to_string(), ) }) @@ -1356,7 +1356,7 @@ mod test { RcStr::from(checksum.as_str()), ( 1000, - vec![Utf8PathBuf::from(format!("/path/to/{}", checksum))], + vec![Utf8PathBuf::from(format!("/path/to/{checksum}"))], ), ); chunking.remainder.size += 1000; @@ -1394,8 +1394,7 @@ mod test { for obj in &pkg1_objects { assert!( specific_component_1_layer.content.contains_key(*obj), - "Specific component 1 layer should contain {}", - obj + "Specific component 1 layer should contain {obj}" ); } @@ -1407,8 +1406,7 @@ mod test { for obj in &pkg2_objects { assert!( specific_component_2_layer.content.contains_key(*obj), - "Specific component 2 layer should contain {}", - obj + "Specific component 2 layer should contain {obj}" ); } @@ -1434,8 +1432,7 @@ mod test { for obj in pkg1_objects.iter().chain(&pkg2_objects) { assert!( !regular_layer.content.contains_key(*obj), - "Regular package layer should NOT contain specific component object {}", - obj + "Regular package layer should NOT contain specific component object {obj}" ); } } @@ -1455,8 +1452,7 @@ mod test { { assert!( found_regular_objects.contains(*obj), - "Regular package object {} should be in some regular layer", - obj + "Regular package object {obj} should be in some regular layer" ); } diff --git a/crates/ostree-ext/src/cli.rs b/crates/ostree-ext/src/cli.rs index dfdd95fe7..e8160028d 100644 --- a/crates/ostree-ext/src/cli.rs +++ b/crates/ostree-ext/src/cli.rs @@ -586,7 +586,7 @@ async fn tar_import(opts: &ImportOpts) -> Result<()> { let stdin = tokio::io::stdin(); crate::tar::import_tar(&repo, stdin, None).await? }; - println!("Imported: {}", imported); + println!("Imported: {imported}"); Ok(()) } @@ -852,14 +852,14 @@ async fn container_export( ..Default::default() }; let pushed = crate::container::encapsulate(repo, rev, &config, Some(opts), imgref).await?; - println!("{}", pushed); + println!("{pushed}"); Ok(()) } /// Load metadata for a container image with an encapsulated ostree commit. async fn container_info(imgref: &OstreeImageReference) -> Result<()> { let (_, digest) = crate::container::fetch_manifest(imgref).await?; - println!("{} digest: {}", imgref, digest); + println!("{imgref} digest: {digest}"); Ok(()) } @@ -1050,7 +1050,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { Opt::Tar(TarOpts::Export(ref opt)) => tar_export(opt), Opt::Container(o) => match o { ContainerOpts::Info { imgref } => container_info(&imgref).await, - ContainerOpts::Commit {} => container_commit().await, + ContainerOpts::Commit => container_commit().await, ContainerOpts::Unencapsulate { repo, imgref, @@ -1103,7 +1103,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { ContainerImageOpts::List { repo } => { let repo = parse_repo(&repo)?; for image in crate::container::store::list_images(&repo)? { - println!("{}", image); + println!("{image}"); } Ok(()) } @@ -1253,7 +1253,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { contents.as_deref(), ) .await?; - println!("Pushed: {}", digest); + println!("Pushed: {digest}"); Ok(()) } ContainerImageOpts::Deploy { @@ -1344,7 +1344,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> { } if let Some(p) = write_commitid_to { std::fs::write(&p, state.merge_commit.as_bytes()) - .with_context(|| format!("Failed to write commitid to {}", p))?; + .with_context(|| format!("Failed to write commitid to {p}"))?; } Ok(()) } diff --git a/crates/ostree-ext/src/container/encapsulate.rs b/crates/ostree-ext/src/container/encapsulate.rs index 901650b4f..338dbaab4 100644 --- a/crates/ostree-ext/src/container/encapsulate.rs +++ b/crates/ostree-ext/src/container/encapsulate.rs @@ -273,7 +273,7 @@ fn build_oci( let mut annos = HashMap::new(); annos.insert(BLOB_OSTREE_ANNOTATION.to_string(), "true".to_string()); let description = if commit_subject.is_empty() { - Cow::Owned(format!("ostree export of commit {}", commit)) + Cow::Owned(format!("ostree export of commit {commit}")) } else { Cow::Borrowed(commit_subject) }; diff --git a/crates/ostree-ext/src/container/mod.rs b/crates/ostree-ext/src/container/mod.rs index 5b12a4327..f95bfd566 100644 --- a/crates/ostree-ext/src/container/mod.rs +++ b/crates/ostree-ext/src/container/mod.rs @@ -297,7 +297,7 @@ impl std::fmt::Display for OstreeImageReference { } } (sigverify, imgref) => { - write!(f, "{}:{}", sigverify, imgref) + write!(f, "{sigverify}:{imgref}") } } } @@ -524,7 +524,7 @@ mod tests { for &v in INVALID_IRS { if ImageReference::try_from(v).is_ok() { - panic!("Should fail to parse: {}", v) + panic!("Should fail to parse: {v}") } } struct Case { diff --git a/crates/ostree-ext/src/container/store.rs b/crates/ostree-ext/src/container/store.rs index 24fb1a2aa..b5c9ed9a8 100644 --- a/crates/ostree-ext/src/container/store.rs +++ b/crates/ostree-ext/src/container/store.rs @@ -511,7 +511,7 @@ impl ImageImporter { system_repo_journal_print( repo, libsystemd::logging::Priority::Info, - &format!("Fetching {}", imgref), + &format!("Fetching {imgref}"), ); let repo = repo.clone(); @@ -637,7 +637,7 @@ impl ImageImporter { let config_labels = super::labels_of(&config); if self.require_bootable { let bootable_key = ostree::METADATA_KEY_BOOTABLE; - let bootable = config_labels.map_or(false, |l| { + let bootable = config_labels.is_some_and(|l| { l.contains_key(bootable_key.as_str()) || l.contains_key(BOOTC_LABEL) }); if !bootable { @@ -1828,7 +1828,7 @@ fn compare_file_info(src: &gio::FileInfo, target: &gio::FileInfo) -> bool { fn inode_of_object(repo: &ostree::Repo, checksum: &str) -> Result { let repodir = Dir::reopen_dir(&repo.dfd_borrow())?; let (prefix, suffix) = checksum.split_at(2); - let objpath = format!("objects/{}/{}.file", prefix, suffix); + let objpath = format!("objects/{prefix}/{suffix}.file"); let metadata = repodir.symlink_metadata(objpath)?; Ok(metadata.ino()) } @@ -1870,7 +1870,7 @@ fn compare_commit_trees( let from_contents_checksum = from_child.tree_get_contents_checksum(); let to_contents_checksum = to_child.tree_get_contents_checksum(); if from_contents_checksum != to_contents_checksum { - let subpath = Utf8PathBuf::from(format!("{}/", path)); + let subpath = Utf8PathBuf::from(format!("{path}/")); compare_commit_trees( repo, &subpath, diff --git a/crates/ostree-ext/src/container/unencapsulate.rs b/crates/ostree-ext/src/container/unencapsulate.rs index 27efe7ea1..4c6249fb6 100644 --- a/crates/ostree-ext/src/container/unencapsulate.rs +++ b/crates/ostree-ext/src/container/unencapsulate.rs @@ -169,7 +169,7 @@ pub(crate) async fn join_fetch( tracing::trace!("Ignoring broken pipe failure from driver"); Err(worker) } else { - Err(worker.context(format!("proxy failure: {} and client error", text))) + Err(worker.context(format!("proxy failure: {text} and client error"))) } } (Ok(_), Err(driver)) => Err(driver), diff --git a/crates/ostree-ext/src/diff.rs b/crates/ostree-ext/src/diff.rs index 655adc382..aafdb2e70 100644 --- a/crates/ostree-ext/src/diff.rs +++ b/crates/ostree-ext/src/diff.rs @@ -104,7 +104,7 @@ fn diff_recurse( let from_contents_checksum = from_child.tree_get_contents_checksum(); let to_contents_checksum = to_child.tree_get_contents_checksum(); if from_contents_checksum != to_contents_checksum { - let subpath = format!("{}/", path); + let subpath = format!("{path}/"); diff_recurse(&subpath, diff, &from_child, &to_child)?; } let from_meta_checksum = from_child.tree_get_metadata_checksum(); diff --git a/crates/ostree-ext/src/fixture.rs b/crates/ostree-ext/src/fixture.rs index a79881cf4..9a31a7777 100644 --- a/crates/ostree-ext/src/fixture.rs +++ b/crates/ostree-ext/src/fixture.rs @@ -270,7 +270,7 @@ impl SeLabel { SeLabel::Boot } else if rootdir == "etc" { // Arbitrarily give some files in /etc some label and others another - if p.as_str().as_bytes().len() % 2 == 0 { + if p.as_str().len() % 2 == 0 { SeLabel::Etc } else { SeLabel::EtcSystemConf diff --git a/crates/ostree-ext/src/integrationtest.rs b/crates/ostree-ext/src/integrationtest.rs index 49e545279..d30e9b022 100644 --- a/crates/ostree-ext/src/integrationtest.rs +++ b/crates/ostree-ext/src/integrationtest.rs @@ -155,9 +155,9 @@ fn test_proxy_auth() -> Result<()> { pub(crate) async fn create_fixture() -> Result<()> { let fixture = crate::fixture::Fixture::new_v1()?; let imgref = fixture.export_container().await?.0; - println!("Wrote: {:?}", imgref); + println!("Wrote: {imgref:?}"); let path = fixture.into_tempdir().keep(); - println!("Wrote: {:?}", path); + println!("Wrote: {path:?}"); Ok(()) } diff --git a/crates/ostree-ext/src/repair.rs b/crates/ostree-ext/src/repair.rs index d15bdcefc..5f7ff85d3 100644 --- a/crates/ostree-ext/src/repair.rs +++ b/crates/ostree-ext/src/repair.rs @@ -171,7 +171,7 @@ pub fn analyze_for_repair(sysroot: &SysrootLock, verbose: bool) -> Result, b: impl AsRef Utf8Pa ostree::ObjectType::DirTree => "dirtree", ostree::ObjectType::DirMeta => "dirmeta", ostree::ObjectType::File => "file", - o => panic!("Unexpected object type: {:?}", o), + o => panic!("Unexpected object type: {o:?}"), }; let (first, rest) = checksum.split_at(2); - format!("{}/repo/objects/{}/{}.{}", OSTREEDIR, first, rest, suffix).into() + format!("{OSTREEDIR}/repo/objects/{first}/{rest}.{suffix}").into() } fn v1_xattrs_object_path(checksum: &str) -> Utf8PathBuf { let (first, rest) = checksum.split_at(2); - format!("{}/repo/objects/{}/{}.file-xattrs", OSTREEDIR, first, rest).into() + format!("{OSTREEDIR}/repo/objects/{first}/{rest}.file-xattrs").into() } fn v1_xattrs_link_object_path(checksum: &str) -> Utf8PathBuf { let (first, rest) = checksum.split_at(2); - format!( - "{}/repo/objects/{}/{}.file-xattrs-link", - OSTREEDIR, first, rest - ) - .into() + format!("{OSTREEDIR}/repo/objects/{first}/{rest}.file-xattrs-link").into() } /// Check for "denormal" symlinks which contain "//" @@ -247,7 +243,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { return Ok(()); } - let objdir: Utf8PathBuf = format!("{}/repo/objects", OSTREEDIR).into(); + let objdir: Utf8PathBuf = format!("{OSTREEDIR}/repo/objects").into(); // Add all parent directories let parent_dirs = { let mut parts: Vec<_> = objdir.ancestors().collect(); @@ -263,7 +259,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { } // Object subdirectories for d in 0..=0xFF { - let path: Utf8PathBuf = format!("{}/{:02x}", objdir, d).into(); + let path: Utf8PathBuf = format!("{objdir}/{d:02x}").into(); self.append_default_dir(&path)?; } // Standard repo subdirectories. @@ -278,13 +274,13 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { "tmp/cache", ]; for d in subdirs { - let path: Utf8PathBuf = format!("{}/repo/{}", OSTREEDIR, d).into(); + let path: Utf8PathBuf = format!("{OSTREEDIR}/repo/{d}").into(); self.append_default_dir(&path)?; } // Repository configuration file. { - let path = format!("{}/repo/config", OSTREEDIR); + let path = format!("{OSTREEDIR}/repo/config"); self.append_default_data(Utf8Path::new(&path), REPO_CONFIG.as_bytes())?; } @@ -363,7 +359,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { ostree::ObjectType::Commit | ostree::ObjectType::CommitMeta => None, ostree::ObjectType::DirTree => Some(&mut self.wrote_dirtree), ostree::ObjectType::DirMeta => Some(&mut self.wrote_dirmeta), - o => panic!("Unexpected object type: {:?}", o), + o => panic!("Unexpected object type: {o:?}"), }; if let Some(set) = set { if set.contains(checksum) { @@ -473,7 +469,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { let mut instream = BufReader::with_capacity(BUF_CAPACITY, instream.into_read()); self.out .append_data(&mut h, &path, &mut instream) - .with_context(|| format!("Writing regfile {}", checksum))?; + .with_context(|| format!("Writing regfile {checksum}"))?; } else { ensure!(meta.file_type() == gio::FileType::SymbolicLink); @@ -483,7 +479,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { let target = target .to_str() .ok_or_else(|| anyhow!("Invalid UTF-8 symlink target: {target:?}"))?; - let context = || format!("Writing content symlink: {}", checksum); + let context = || format!("Writing content symlink: {checksum}"); // Handle //chkconfig, see above if symlink_is_denormal(target) { h.set_link_name_literal(target).with_context(context)?; diff --git a/crates/ostree-ext/src/tar/import.rs b/crates/ostree-ext/src/tar/import.rs index 74ca02909..74fdeee64 100644 --- a/crates/ostree-ext/src/tar/import.rs +++ b/crates/ostree-ext/src/tar/import.rs @@ -126,6 +126,7 @@ fn parse_object_entry_path(path: &Utf8Path) -> Result<(&str, &Utf8Path, &str)> { .parent() .and_then(|p| p.file_name()) .ok_or_else(|| anyhow!("Invalid path (no parent) {}", path))?; + #[allow(clippy::needless_as_bytes)] if !(parentname.is_ascii() && parentname.as_bytes().len() == 2) { return Err(anyhow!("Invalid checksum parent {}", parentname)); } @@ -147,10 +148,11 @@ fn parse_checksum(parent: &str, name: &Utf8Path) -> Result { // Also take care of the double extension on `.file.xattrs`. let checksum_rest = checksum_rest.trim_end_matches(".file"); + #[allow(clippy::needless_as_bytes)] if !(checksum_rest.is_ascii() && checksum_rest.as_bytes().len() == 62) { return Err(anyhow!("Invalid checksum part {}", checksum_rest)); } - let reassembled = format!("{}{}", parent, checksum_rest); + let reassembled = format!("{parent}{checksum_rest}"); validate_sha256(reassembled) } @@ -864,11 +866,11 @@ mod tests { #[test] fn test_parse_metadata_entry() { let c = "a8/6d80a3e9ff77c2e3144c787b7769b300f91ffd770221aac27bab854960b964"; - let invalid = format!("{}.blah", c); + let invalid = format!("{c}.blah"); for &k in &["", "42", c, &invalid] { assert!(Importer::parse_metadata_entry(k.into()).is_err()) } - let valid = format!("{}.commit", c); + let valid = format!("{c}.commit"); let r = Importer::parse_metadata_entry(valid.as_str().into()).unwrap(); assert_eq!(r.0, c.replace('/', "")); assert_eq!(r.1, ostree::ObjectType::Commit); diff --git a/crates/ostree-ext/src/tar/write.rs b/crates/ostree-ext/src/tar/write.rs index 7d8087a84..a7deb31c2 100644 --- a/crates/ostree-ext/src/tar/write.rs +++ b/crates/ostree-ext/src/tar/write.rs @@ -567,7 +567,7 @@ mod tests { match normalize_validate_path(k.into(), imp_default).unwrap() { NormalizedPathResult::Filtered(_) => {} NormalizedPathResult::Normal(_) => { - panic!("{} should be filtered", k) + panic!("{k} should be filtered") } } } diff --git a/crates/ostree-ext/tests/it/main.rs b/crates/ostree-ext/tests/it/main.rs index 79e43b470..1b612b9c3 100644 --- a/crates/ostree-ext/tests/it/main.rs +++ b/crates/ostree-ext/tests/it/main.rs @@ -53,7 +53,7 @@ fn assert_err_contains(r: Result, s: impl AsRef) { let s = s.as_ref(); let msg = format!("{:#}", r.err().expect("Expecting an error")); if !msg.contains(s) { - panic!(r#"Error message "{}" did not contain "{}""#, msg, s); + panic!(r#"Error message "{msg}" did not contain "{s}""#); } } @@ -273,7 +273,7 @@ fn validate_tar_expected( } seen_paths.insert(entry_path.clone()); if let Some(exp) = expected.remove(entry_path.as_str()) { - assert_eq!(header.entry_type(), exp.etype, "{}", entry_path); + assert_eq!(header.entry_type(), exp.etype, "{entry_path}"); let expected_mode = exp.mode; let header_mode = header.mode().unwrap(); assert_eq!( @@ -301,11 +301,7 @@ fn validate_tar_expected( } } - assert!( - expected.is_empty(), - "Expected but not found:\n{:?}", - expected - ); + assert!(expected.is_empty(), "Expected but not found:\n{expected:?}"); Ok(()) } @@ -2009,7 +2005,7 @@ async fn test_container_import_export_registry() -> Result<()> { .context("Failed to resolve ref")?; let src_imgref = ImageReference { transport: Transport::Registry, - name: format!("{}/exampleos", tr), + name: format!("{tr}/exampleos"), }; let config = Config { cmd: Some(vec!["/bin/bash".to_string()]), From 3ee4479d2290c68043c76f02feda23c5eb5423a6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:14:59 -0400 Subject: [PATCH 2/9] crates/utils: Fix clippy lints Signed-off-by: Colin Walters --- crates/utils/src/iterators.rs | 7 +++---- crates/utils/src/path.rs | 2 +- crates/utils/src/timestamp.rs | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/utils/src/iterators.rs b/crates/utils/src/iterators.rs index df1d3c9af..ccecee599 100644 --- a/crates/utils/src/iterators.rs +++ b/crates/utils/src/iterators.rs @@ -22,11 +22,10 @@ where let mut items = Vec::with_capacity(max.get()); let mut it = it.peekable(); - if it.peek().is_none() { - return None; - } + // If there's nothing, just return + let _ = it.peek()?; - while let Some(next) = it.next() { + for next in it.by_ref() { items.push(next); // If we've reached max items, stop collecting diff --git a/crates/utils/src/path.rs b/crates/utils/src/path.rs index 2f7c0a447..5409fecd9 100644 --- a/crates/utils/src/path.rs +++ b/crates/utils/src/path.rs @@ -31,7 +31,7 @@ impl<'a> Display for PathQuotedDisplay<'a> { return f.write_str(&s); } // Should not happen really - return Err(std::fmt::Error); + Err(std::fmt::Error) } } diff --git a/crates/utils/src/timestamp.rs b/crates/utils/src/timestamp.rs index 82057084c..8ec8f2e19 100644 --- a/crates/utils/src/timestamp.rs +++ b/crates/utils/src/timestamp.rs @@ -1,5 +1,4 @@ use anyhow::Context; -use chrono; /// Try to parse an RFC 3339, warn on error. pub fn try_deserialize_timestamp(t: &str) -> Option> { From 950a03e09fb9cb9845fa8bbb1a2248351819ba63 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:16:06 -0400 Subject: [PATCH 3/9] crates/sysusers: Fix various clippy lints Signed-off-by: Colin Walters --- crates/sysusers/src/lib.rs | 22 +++++++++------------- crates/sysusers/src/nameservice/group.rs | 2 +- crates/sysusers/src/nameservice/passwd.rs | 2 +- crates/sysusers/src/nameservice/shadow.rs | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/crates/sysusers/src/lib.rs b/crates/sysusers/src/lib.rs index 2f9f847f6..77fb47561 100644 --- a/crates/sysusers/src/lib.rs +++ b/crates/sysusers/src/lib.rs @@ -61,7 +61,7 @@ impl FromStr for GroupReference { fn from_str(s: &str) -> std::result::Result { let r = if s.starts_with('/') { Self::Path(s.to_owned()) - } else if s.chars().all(|c| matches!(c, '0'..='9')) { + } else if s.chars().all(|c| c.is_ascii_digit()) { Self::Numeric(u32::from_str(s)?) } else { Self::Name(s.to_owned()) @@ -129,15 +129,11 @@ impl SysusersEntry { let s = s.trim_start(); let (first, rest) = match s.strip_prefix('"') { None => { - let idx = s - .find(|c: char| c.is_whitespace()) - .unwrap_or(s.as_bytes().len()); + let idx = s.find(|c: char| c.is_whitespace()).unwrap_or(s.len()); s.split_at(idx) } Some(rest) => { - let Some(end) = rest.find(|c: char| c == '"') else { - return None; - }; + let end = rest.find('"')?; (&rest[..end], &rest[end + 1..]) } }; @@ -164,10 +160,10 @@ impl SysusersEntry { pub(crate) fn parse(s: &str) -> Result> { let err = || Error::ParseFailure(s.to_owned()); - let (ftype, s) = Self::next_token(s).ok_or_else(err.clone())?; + let (ftype, s) = Self::next_token(s).ok_or_else(err)?; let r = match ftype { "u" | "u!" => { - let (name, s) = Self::next_token_owned(s).ok_or_else(err.clone())?; + let (name, s) = Self::next_token_owned(s).ok_or_else(err)?; let (id, s) = Self::next_optional_token(s).unwrap_or_default(); let (uid, pgid) = id .and_then(|v| v.split_once(':')) @@ -194,15 +190,15 @@ impl SysusersEntry { } } "g" => { - let (name, s) = Self::next_token_owned(s).ok_or_else(err.clone())?; + let (name, s) = Self::next_token_owned(s).ok_or_else(err)?; let (id, _) = Self::next_optional_token(s).unwrap_or_default(); let id = id.map(|id| id.parse()).transpose().map_err(|_| err())?; SysusersEntry::Group { name, id } } "r" => { - let (_, s) = Self::next_optional_token(s).ok_or_else(err.clone())?; - let (range, _) = Self::next_token(s).ok_or_else(err.clone())?; - let (start, end) = range.split_once('-').ok_or_else(err.clone())?; + let (_, s) = Self::next_optional_token(s).ok_or_else(err)?; + let (range, _) = Self::next_token(s).ok_or_else(err)?; + let (start, end) = range.split_once('-').ok_or_else(err)?; let start: u32 = start.parse().map_err(|_| err())?; let end: u32 = end.parse().map_err(|_| err())?; SysusersEntry::Range { start, end } diff --git a/crates/sysusers/src/nameservice/group.rs b/crates/sysusers/src/nameservice/group.rs index 5c34ba9f4..3ea1f2622 100644 --- a/crates/sysusers/src/nameservice/group.rs +++ b/crates/sysusers/src/nameservice/group.rs @@ -49,7 +49,7 @@ pub(crate) fn parse_group_content(content: impl BufRead) -> Result Result Result, std::num::ParseIntError> { fn number_or_empty(value: Option) -> String { if let Some(number) = value { - format!("{}", number) + format!("{number}") } else { "".to_string() } From bb8444dfe62ab89347fa59b48f1d20dcd0a1a8c6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:20:10 -0400 Subject: [PATCH 4/9] crates/tmpfiles: Fix various clippy lints Signed-off-by: Colin Walters --- crates/tmpfiles/src/lib.rs | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/crates/tmpfiles/src/lib.rs b/crates/tmpfiles/src/lib.rs index 277b009a6..2222f32f3 100644 --- a/crates/tmpfiles/src/lib.rs +++ b/crates/tmpfiles/src/lib.rs @@ -82,7 +82,7 @@ fn escape_path(path: &Path, out: &mut W) -> std::fmt::Result return Err(std::fmt::Error); } - if let Some(s) = path.as_os_str().as_str().ok() { + if let Ok(s) = path.as_os_str().as_str() { if s.chars().all(|c| c.is_ascii_alphanumeric() || c == '/') { return write!(out, "{s}"); } @@ -99,7 +99,7 @@ fn escape_path(path: &Path, out: &mut W) -> std::fmt::Result b'\n' => out.write_str(r"\n")?, b'\t' => out.write_str(r"\t")?, b'\r' => out.write_str(r"\r")?, - o => write!(out, "\\x{:02x}", o)?, + o => write!(out, "\\x{o:02x}")?, } } } @@ -137,16 +137,8 @@ where b't' => b'\t', b'x' => { let mut s = String::new(); - s.push( - src.next() - .ok_or_else(|| Error::MalformedTmpfilesPath)? - .into(), - ); - s.push( - src.next() - .ok_or_else(|| Error::MalformedTmpfilesPath)? - .into(), - ); + s.push(src.next().ok_or(Error::MalformedTmpfilesPath)?.into()); + s.push(src.next().ok_or(Error::MalformedTmpfilesPath)?.into()); u8::from_str_radix(&s, 16).map_err(|_| Error::MalformedTmpfilesPath)? } @@ -162,7 +154,7 @@ where I: Iterator, { let mut r = Vec::new(); - if let Some(_) = src.next_if_eq(&b'"') { + if src.next_if_eq(&b'"').is_some() { impl_unescape_path_until(src, &mut r, true)?; } else { impl_unescape_path_until(src, &mut r, false)?; @@ -221,7 +213,7 @@ pub(crate) fn translate_to_tmpfiles_d( FileMeta::Directory(_) => 'd', FileMeta::Symlink(_) => 'L', }; - write!(bufwr, "{} ", filetype_char)?; + write!(bufwr, "{filetype_char} ")?; canonicalize_escape_path(abs_path, &mut bufwr)?; match meta { @@ -356,7 +348,7 @@ fn convert_path_to_tmpfiles_d_recurse( let gid = meta.gid(); let user = users .get_user_by_uid(meta.uid()) - .ok_or_else(|| Error::UserNotFound(uid))?; + .ok_or(Error::UserNotFound(uid))?; let username = user.name(); let username: &str = username.to_str().ok_or_else(|| Error::NonUtf8User { uid, @@ -364,7 +356,7 @@ fn convert_path_to_tmpfiles_d_recurse( })?; let group = groups .get_group_by_gid(gid) - .ok_or_else(|| Error::GroupNotFound(gid))?; + .ok_or(Error::GroupNotFound(gid))?; let groupname = group.name(); let groupname: &str = groupname.to_str().ok_or_else(|| Error::NonUtf8Group { gid, @@ -499,17 +491,17 @@ fn tmpfiles_entry_get_path(line: &str) -> Result { let err = || Error::MalformedTmpfilesEntry(line.to_string()); let mut it = line.as_bytes().iter().copied().peekable(); // Skip leading whitespace - while let Some(_) = it.next_if(|c| c.is_ascii_whitespace()) {} + while it.next_if(|c| c.is_ascii_whitespace()).is_some() {} // Skip the file type let mut found_ftype = false; - while let Some(_) = it.next_if(|c| !c.is_ascii_whitespace()) { + while it.next_if(|c| !c.is_ascii_whitespace()).is_some() { found_ftype = true } if !found_ftype { return Err(err()); } // Skip trailing whitespace - while let Some(_) = it.next_if(|c| c.is_ascii_whitespace()) {} + while it.next_if(|c| c.is_ascii_whitespace()).is_some() {} unescape_path(&mut it) } From a3fe7b2abc0cef7fa7e764e50adebd6ffc6be005 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:20:38 -0400 Subject: [PATCH 5/9] crates/blockdev: Fix various clippy lints Signed-off-by: Colin Walters --- crates/blockdev/src/blockdev.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/blockdev/src/blockdev.rs b/crates/blockdev/src/blockdev.rs index d46d6b81f..ceed18d9b 100644 --- a/crates/blockdev/src/blockdev.rs +++ b/crates/blockdev/src/blockdev.rs @@ -49,7 +49,7 @@ impl Device { #[allow(dead_code)] pub fn has_children(&self) -> bool { - self.children.as_ref().map_or(false, |v| !v.is_empty()) + self.children.as_ref().is_some_and(|v| !v.is_empty()) } // The "start" parameter was only added in a version of util-linux that's only @@ -451,7 +451,7 @@ mod test { #[test] fn test_parse_lsblk() { let fixture = include_str!("../tests/fixtures/lsblk.json"); - let devs: DevicesOutput = serde_json::from_str(&fixture).unwrap(); + let devs: DevicesOutput = serde_json::from_str(fixture).unwrap(); let dev = devs.blockdevices.into_iter().next().unwrap(); let children = dev.children.as_deref().unwrap(); assert_eq!(children.len(), 3); @@ -498,7 +498,7 @@ mod test { } } "# }; - let table: SfDiskOutput = serde_json::from_str(&fixture).unwrap(); + let table: SfDiskOutput = serde_json::from_str(fixture).unwrap(); assert_eq!( table.partitiontable.find("/dev/loop0p2").unwrap().size, 20961247 From 56ed02d8ee7171960b7e36b25f8e0f69bf29d33d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:21:08 -0400 Subject: [PATCH 6/9] crates/system-reinstall-bootc: Fix various clippy lints Signed-off-by: Colin Walters --- crates/system-reinstall-bootc/src/podman.rs | 6 +++--- crates/system-reinstall-bootc/src/users.rs | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/system-reinstall-bootc/src/podman.rs b/crates/system-reinstall-bootc/src/podman.rs index 8ee1005bd..af89a67d4 100644 --- a/crates/system-reinstall-bootc/src/podman.rs +++ b/crates/system-reinstall-bootc/src/podman.rs @@ -112,14 +112,14 @@ pub(crate) fn pull_if_not_present(image: &str) -> Result<()> { let result = image_exists_command(image).status()?; if result.success() { - println!("Image {} is already present locally, skipping pull.", image); + println!("Image {image} is already present locally, skipping pull."); return Ok(()); } else { - println!("Image {} is not present locally, pulling it now.", image); + println!("Image {image} is not present locally, pulling it now."); println!(); pull_image_command(image) .run_inherited_with_cmd_context() - .context(format!("pulling image {}", image))?; + .context(format!("pulling image {image}"))?; } Ok(()) diff --git a/crates/system-reinstall-bootc/src/users.rs b/crates/system-reinstall-bootc/src/users.rs index f3ec8200a..f5823eba2 100644 --- a/crates/system-reinstall-bootc/src/users.rs +++ b/crates/system-reinstall-bootc/src/users.rs @@ -172,15 +172,14 @@ fn get_keys_from_files(user: &uzers::User, keyfiles: &Vec<&str>) -> Result Result> { let user_config = uzers::get_user_by_name(command_user).context(format!( - "authorized_keys_command_user {} not found", - command_user + "authorized_keys_command_user {command_user} not found" ))?; let mut cmd = Command::new(command); cmd.uid(user_config.uid()); let output = cmd .run_get_output() - .context(format!("running authorized_keys_command {}", command))?; + .context(format!("running authorized_keys_command {command}"))?; let keys = PublicKey::read_keys(output)?; Ok(keys) } @@ -201,7 +200,7 @@ pub(crate) fn get_all_users_keys() -> Result> { for user_name in loginctl_user_names { let user_info = uzers::get_user_by_name(user_name.as_str()) - .context(format!("user {} not found", user_name))?; + .context(format!("user {user_name} not found"))?; let mut user_authorized_keys: Vec = Vec::new(); if !sshd_config.authorized_keys_files.is_empty() { From c681354563f567a039235dfc81a935a82de77ef0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:21:54 -0400 Subject: [PATCH 7/9] crates/xtask: Fix various clippy lints Signed-off-by: Colin Walters --- crates/xtask/src/xtask.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/xtask/src/xtask.rs b/crates/xtask/src/xtask.rs index a676ed31a..831356964 100644 --- a/crates/xtask/src/xtask.rs +++ b/crates/xtask/src/xtask.rs @@ -374,7 +374,7 @@ fn update_spec(sh: &Shell) -> Result { } else if line.starts_with("Source1") { writeln!(o, "Source1: {src_vendorpath}")?; } else { - writeln!(o, "{}", line)?; + writeln!(o, "{line}")?; } } } @@ -419,7 +419,7 @@ fn impl_srpm(sh: &Shell) -> Result { writeln!(o, "# Replaced by cargo xtask package-srpm")?; writeln!(o, "Version: {v}")?; } else { - writeln!(o, "{}", line)?; + writeln!(o, "{line}")?; } } } From d028fc80b6fbeb720bb02a8eda92572a25ade8d6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:22:48 -0400 Subject: [PATCH 8/9] crates/test-integration: Fix clippy lints Signed-off-by: Colin Walters --- crates/tests-integration/src/system_reinstall.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/tests-integration/src/system_reinstall.rs b/crates/tests-integration/src/system_reinstall.rs index d7227d773..70bb3edc6 100644 --- a/crates/tests-integration/src/system_reinstall.rs +++ b/crates/tests-integration/src/system_reinstall.rs @@ -41,7 +41,7 @@ fn get_deployment_dir() -> Result { .to_str() .ok_or_else(|| anyhow!("Deployment directory name {:?} is not valid UTF-8", hash))?; - println!("Using deployment directory: {}", hash_str); + println!("Using deployment directory: {hash_str}"); Ok(base_path.join(hash_str)) } From adab6b0cc44a93c4ff4f95eee3a2cc365b16c6bb Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Aug 2025 08:23:23 -0400 Subject: [PATCH 9/9] crates/lib: Fix various clippy lints Signed-off-by: Colin Walters --- crates/lib/src/cfsctl.rs | 5 +---- crates/lib/src/cli.rs | 12 ++---------- crates/lib/src/deploy.rs | 2 +- crates/lib/src/fsck.rs | 1 - crates/lib/src/install.rs | 2 +- crates/lib/src/lints.rs | 22 +++++++++++----------- crates/lib/src/podstorage.rs | 3 +-- crates/lib/src/progress_jsonl.rs | 4 ++-- crates/lib/src/spec.rs | 22 ++++++++++------------ crates/lib/src/status.rs | 2 +- crates/lib/src/store/mod.rs | 2 -- crates/lib/src/utils.rs | 2 +- 12 files changed, 31 insertions(+), 48 deletions(-) diff --git a/crates/lib/src/cfsctl.rs b/crates/lib/src/cfsctl.rs index 0e562e91f..d4fa75387 100644 --- a/crates/lib/src/cfsctl.rs +++ b/crates/lib/src/cfsctl.rs @@ -148,10 +148,7 @@ enum Command { } fn verity_opt(opt: &Option) -> Result> { - Ok(opt - .as_ref() - .map(|value| FsVerityHashValue::from_hex(value)) - .transpose()?) + Ok(opt.as_ref().map(FsVerityHashValue::from_hex).transpose()?) } pub(crate) async fn run_from_iter(system_store: &crate::store::Storage, args: I) -> Result<()> diff --git a/crates/lib/src/cli.rs b/crates/lib/src/cli.rs index 1b762c389..7c31cca8d 100644 --- a/crates/lib/src/cli.rs +++ b/crates/lib/src/cli.rs @@ -921,17 +921,9 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { // If there's no specified image, let's be nice and check if the booted system is using rpm-ostree if imgref.is_none() { - let booted_incompatible = host - .status - .booted - .as_ref() - .map_or(false, |b| b.incompatible); + let booted_incompatible = host.status.booted.as_ref().is_some_and(|b| b.incompatible); - let staged_incompatible = host - .status - .staged - .as_ref() - .map_or(false, |b| b.incompatible); + let staged_incompatible = host.status.staged.as_ref().is_some_and(|b| b.incompatible); if booted_incompatible || staged_incompatible { return Err(anyhow::anyhow!( diff --git a/crates/lib/src/deploy.rs b/crates/lib/src/deploy.rs index e10500ab9..69f00da6c 100644 --- a/crates/lib/src/deploy.rs +++ b/crates/lib/src/deploy.rs @@ -201,7 +201,7 @@ async fn handle_layer_progress_print( subtask = SubTaskBytes { subtask: layer_type.into(), description: format!("{layer_type}: {short_digest}").clone().into(), - id: format!("{short_digest}").clone().into(), + id: short_digest.to_string().clone().into(), bytes_cached: 0, bytes: 0, bytes_total: layer_size, diff --git a/crates/lib/src/fsck.rs b/crates/lib/src/fsck.rs index 973923e79..94755e9ad 100644 --- a/crates/lib/src/fsck.rs +++ b/crates/lib/src/fsck.rs @@ -213,7 +213,6 @@ async fn verity_state_of_all_objects( .map_err(|_| anyhow::anyhow!("Invalid UTF-8"))?; let objdir = ent.open_dir()?; - let expected = expected.clone(); joinset.spawn_blocking(move || verity_state_of_objects(&objdir, name.as_str(), expected)); } diff --git a/crates/lib/src/install.rs b/crates/lib/src/install.rs index b5cca4a6e..a7f421902 100644 --- a/crates/lib/src/install.rs +++ b/crates/lib/src/install.rs @@ -1447,7 +1447,7 @@ async fn install_to_filesystem_impl( if matches!(cleanup, Cleanup::TriggerOnNextBoot) { let sysroot_dir = crate::utils::sysroot_dir(ostree)?; tracing::debug!("Writing {DESTRUCTIVE_CLEANUP}"); - sysroot_dir.atomic_write(format!("etc/{}", DESTRUCTIVE_CLEANUP), b"")?; + sysroot_dir.atomic_write(format!("etc/{DESTRUCTIVE_CLEANUP}"), b"")?; } // We must drop the sysroot here in order to close any open file diff --git a/crates/lib/src/lints.rs b/crates/lib/src/lints.rs index ad326b0cc..0e4a0416a 100644 --- a/crates/lib/src/lints.rs +++ b/crates/lib/src/lints.rs @@ -155,10 +155,10 @@ impl Lint { f: LintFn, ) -> Self { Lint { - name: name, + name, ty: LintType::Fatal, f: LintFnTy::Regular(f), - description: description, + description, root_type: None, } } @@ -169,10 +169,10 @@ impl Lint { f: LintFn, ) -> Self { Lint { - name: name, + name, ty: LintType::Warning, f: LintFnTy::Regular(f), - description: description, + description, root_type: None, } } @@ -290,7 +290,7 @@ fn lint_inner<'skip>( results.push((lint, f(&root, &config))); } - let mut recursive_lints = BTreeSet::from_iter(recursive_lints.into_iter()); + let mut recursive_lints = BTreeSet::from_iter(recursive_lints); let mut recursive_errors = BTreeMap::new(); root.walk( &WalkConfiguration::default() @@ -327,7 +327,7 @@ fn lint_inner<'skip>( }, )?; // Extend our overall result set with the recursive-lint errors. - results.extend(recursive_errors.into_iter().map(|(lint, e)| (lint, e))); + results.extend(recursive_errors); // Any recursive lint still in this list succeeded. results.extend(recursive_lints.into_iter().map(|lint| (lint, lint_ok()))); for (lint, r) in results { @@ -511,7 +511,7 @@ fn check_utf8(e: &WalkComponent, _config: &LintExecutionConfig) -> LintRecursive if e.file_type.is_symlink() { let target = e.dir.read_link_contents(filename)?; - if !target.to_str().is_some() { + if target.to_str().is_none() { return lint_err(format!( "{}: Found non-utf8 symlink target", PathQuotedDisplay::new(&path) @@ -754,7 +754,7 @@ Any content here in the container image will be masked at runtime. ); fn check_boot(root: &Dir, config: &LintExecutionConfig) -> LintResult { let Some(d) = root.open_dir_optional("boot")? else { - return lint_err(format!("Missing /boot directory")); + return lint_err("Missing /boot directory"); }; // First collect all entries to determine if the directory is empty @@ -1161,7 +1161,7 @@ mod tests { output_str.clear(); // Test case 2: Iterator with one item - let items_one = vec!["item1"]; + let items_one = ["item1"]; format_items(&config, header, items_one.iter(), &mut output_str)?; assert_eq!(output_str, "Test Header:\n item1\n"); output_str.clear(); @@ -1194,7 +1194,7 @@ mod tests { output_str.clear(); // Test case 2: Iterator with fewer items than DEFAULT_TRUNCATED_OUTPUT - let items_few = vec!["item1", "item2"]; + let items_few = ["item1", "item2"]; format_items(&config, header, items_few.iter(), &mut output_str)?; assert_eq!(output_str, "Test Header:\n item1\n item2\n"); output_str.clear(); @@ -1246,7 +1246,7 @@ mod tests { let header = "Numbers"; let mut output_str = String::new(); - let items_numbers = vec![1, 2, 3]; + let items_numbers = [1, 2, 3]; format_items(&config, header, items_numbers.iter(), &mut output_str)?; similar_asserts::assert_eq!(output_str, "Numbers:\n 1\n 2\n 3\n"); diff --git a/crates/lib/src/podstorage.rs b/crates/lib/src/podstorage.rs index ec68923cb..6ac8b0a5b 100644 --- a/crates/lib/src/podstorage.rs +++ b/crates/lib/src/podstorage.rs @@ -122,7 +122,7 @@ fn bind_storage_roots(cmd: &mut Command, storage_root: &Dir, run_root: &Dir) -> fn new_podman_cmd_in(storage_root: &Dir, run_root: &Dir) -> Result { let mut cmd = Command::new("podman"); bind_storage_roots(&mut cmd, storage_root, run_root)?; - let run_root = format!("/proc/self/fd/{}", STORAGE_RUN_FD); + let run_root = format!("/proc/self/fd/{STORAGE_RUN_FD}"); cmd.args(["--root", STORAGE_ALIAS_DIR, "--runroot", run_root.as_str()]); Ok(cmd) } @@ -288,7 +288,6 @@ impl CStorage { Ok(r) }) .await? - .map_err(Into::into) } #[context("Pruning")] diff --git a/crates/lib/src/progress_jsonl.rs b/crates/lib/src/progress_jsonl.rs index 4b719b170..b697a245c 100644 --- a/crates/lib/src/progress_jsonl.rs +++ b/crates/lib/src/progress_jsonl.rs @@ -248,7 +248,7 @@ impl ProgressWriter { /// Send an event. pub(crate) async fn send(&self, event: Event<'_>) { if let Err(e) = self.send_impl(event, true).await { - eprintln!("Failed to write to jsonl: {}", e); + eprintln!("Failed to write to jsonl: {e}"); // Stop writing to fd but let process continue // SAFETY: Propagating panics from the mutex here is intentional let _ = self.inner.lock().await.take(); @@ -258,7 +258,7 @@ impl ProgressWriter { /// Send an event that can be dropped. pub(crate) async fn send_lossy(&self, event: Event<'_>) { if let Err(e) = self.send_impl(event, false).await { - eprintln!("Failed to write to jsonl: {}", e); + eprintln!("Failed to write to jsonl: {e}"); // Stop writing to fd but let process continue // SAFETY: Propagating panics from the mutex here is intentional let _ = self.inner.lock().await.take(); diff --git a/crates/lib/src/spec.rs b/crates/lib/src/spec.rs index 2d8593fde..2fc4e5884 100644 --- a/crates/lib/src/spec.rs +++ b/crates/lib/src/spec.rs @@ -95,9 +95,7 @@ pub struct ImageReference { /// If the reference is in :tag@digest form, strip the tag. fn canonicalize_reference(reference: Reference) -> Option { // No tag? Just pass through. - if reference.tag().is_none() { - return None; - } + reference.tag()?; // No digest? Also pass through. let Some(digest) = reference.digest() else { @@ -126,7 +124,7 @@ impl ImageReference { transport: self.transport.clone(), signature: self.signature.clone(), }; - return Ok(r); + Ok(r) } _ => { // For other transports, we don't do any canonicalization @@ -349,14 +347,14 @@ mod tests { let test_cases = [ // When both a tag and digest are present, the digest should be used ( - format!("quay.io/example/someimage:latest@{}", sample_digest), - format!("quay.io/example/someimage@{}", sample_digest), + format!("quay.io/example/someimage:latest@{sample_digest}"), + format!("quay.io/example/someimage@{sample_digest}"), "registry", ), // When only a digest is present, it should be used ( - format!("quay.io/example/someimage@{}", sample_digest), - format!("quay.io/example/someimage@{}", sample_digest), + format!("quay.io/example/someimage@{sample_digest}"), + format!("quay.io/example/someimage@{sample_digest}"), "registry", ), // When only a tag is present, it should be preserved @@ -385,13 +383,13 @@ mod tests { ), // Other cases are not canonicalized ( - format!("quay.io/example/someimage:latest@{}", sample_digest), - format!("quay.io/example/someimage:latest@{}", sample_digest), + format!("quay.io/example/someimage:latest@{sample_digest}"), + format!("quay.io/example/someimage:latest@{sample_digest}"), "containers-storage", ), ( - format!("/path/to/dir:latest"), - format!("/path/to/dir:latest"), + "/path/to/dir:latest".to_string(), + "/path/to/dir:latest".to_string(), "oci", ), ( diff --git a/crates/lib/src/status.rs b/crates/lib/src/status.rs index d9b33e431..4b0be123f 100644 --- a/crates/lib/src/status.rs +++ b/crates/lib/src/status.rs @@ -526,7 +526,7 @@ fn human_render_slot( write_row_name(&mut out, "Signature", prefix_len)?; match signature { crate::spec::ImageSignature::OstreeRemote(remote) => { - writeln!(out, "ostree-remote:{}", remote)?; + writeln!(out, "ostree-remote:{remote}")?; } crate::spec::ImageSignature::ContainerPolicy => { writeln!(out, "container-policy")?; diff --git a/crates/lib/src/store/mod.rs b/crates/lib/src/store/mod.rs index ada6bb249..cab4167e2 100644 --- a/crates/lib/src/store/mod.rs +++ b/crates/lib/src/store/mod.rs @@ -25,7 +25,6 @@ use cap_std_ext::cap_std::fs::{Dir, DirBuilder, DirBuilderExt as _}; use cap_std_ext::dirext::CapStdExtDirExt; use fn_error_context::context; -use composefs; use ostree_ext::ostree; use ostree_ext::sysroot::SysrootLock; use rustix::fs::Mode; @@ -175,6 +174,5 @@ impl Storage { sysroot_dir .update_timestamps(std::path::Path::new(BOOTC_ROOT)) .context("update_timestamps") - .map_err(Into::into) } } diff --git a/crates/lib/src/utils.rs b/crates/lib/src/utils.rs index 39adc5ef8..e2d6a8024 100644 --- a/crates/lib/src/utils.rs +++ b/crates/lib/src/utils.rs @@ -160,7 +160,7 @@ where // We need to handle the case where we aren't connected to // a tty, so indicatif would show nothing by default. if pb.is_hidden() { - print!("{}...", msg); + print!("{msg}..."); std::io::stdout().flush().unwrap(); } let r = f.await;