From a438dee9df24384adad27683e20cb946dc599556 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein <tamird@gmail.com> Date: Tue, 1 Oct 2024 14:42:31 -0400 Subject: [PATCH] Replace `Arc` with `&'static` --- aya/src/programs/uprobe.rs | 12 +++++------- xtask/public-api/aya.txt | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/aya/src/programs/uprobe.rs b/aya/src/programs/uprobe.rs index 2e63e39e..737166ba 100644 --- a/aya/src/programs/uprobe.rs +++ b/aya/src/programs/uprobe.rs @@ -8,7 +8,7 @@ use std::{ mem, os::{fd::AsFd as _, raw::c_char, unix::ffi::OsStrExt}, path::{Path, PathBuf}, - sync::{Arc, LazyLock}, + sync::LazyLock, }; use libc::pid_t; @@ -29,8 +29,8 @@ use crate::{ const LD_SO_CACHE_FILE: &str = "/etc/ld.so.cache"; -static LD_SO_CACHE: LazyLock<Result<LdSoCache, Arc<io::Error>>> = - LazyLock::new(|| LdSoCache::load(LD_SO_CACHE_FILE).map_err(Arc::new)); +static LD_SO_CACHE: LazyLock<Result<LdSoCache, io::Error>> = + LazyLock::new(|| LdSoCache::load(LD_SO_CACHE_FILE)); const LD_SO_CACHE_HEADER_OLD: &str = "ld.so-1.7.0\0"; const LD_SO_CACHE_HEADER_NEW: &str = "glibc-ld.so.cache1.1"; @@ -140,9 +140,7 @@ fn resolve_attach_path(target: &Path, pid: Option<pid_t>) -> Result<Cow<'_, Path .or_else(|| { LD_SO_CACHE .as_ref() - .map_err(|error| UProbeError::InvalidLdSoCache { - io_error: error.clone(), - }) + .map_err(|io_error| UProbeError::InvalidLdSoCache { io_error }) .map(|cache| cache.resolve(target).map(Cow::Borrowed)) .transpose() }) @@ -215,7 +213,7 @@ pub enum UProbeError { InvalidLdSoCache { /// the original [`io::Error`] #[source] - io_error: Arc<io::Error>, + io_error: &'static io::Error, }, /// The target program could not be found. diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt index 4cf53afa..68eb4f9f 100644 --- a/xtask/public-api/aya.txt +++ b/xtask/public-api/aya.txt @@ -6067,7 +6067,7 @@ pub aya::programs::uprobe::UProbeError::FileError pub aya::programs::uprobe::UProbeError::FileError::filename: std::path::PathBuf pub aya::programs::uprobe::UProbeError::FileError::io_error: std::io::error::Error pub aya::programs::uprobe::UProbeError::InvalidLdSoCache -pub aya::programs::uprobe::UProbeError::InvalidLdSoCache::io_error: alloc::sync::Arc<std::io::error::Error> +pub aya::programs::uprobe::UProbeError::InvalidLdSoCache::io_error: &'static std::io::error::Error pub aya::programs::uprobe::UProbeError::InvalidTarget pub aya::programs::uprobe::UProbeError::InvalidTarget::path: std::path::PathBuf pub aya::programs::uprobe::UProbeError::SymbolError @@ -7343,7 +7343,7 @@ pub aya::programs::UProbeError::FileError pub aya::programs::UProbeError::FileError::filename: std::path::PathBuf pub aya::programs::UProbeError::FileError::io_error: std::io::error::Error pub aya::programs::UProbeError::InvalidLdSoCache -pub aya::programs::UProbeError::InvalidLdSoCache::io_error: alloc::sync::Arc<std::io::error::Error> +pub aya::programs::UProbeError::InvalidLdSoCache::io_error: &'static std::io::error::Error pub aya::programs::UProbeError::InvalidTarget pub aya::programs::UProbeError::InvalidTarget::path: std::path::PathBuf pub aya::programs::UProbeError::SymbolError