Skip to content

Commit

Permalink
build(deps): update thiserror requirement in the cargo-crates group
Browse files Browse the repository at this point in the history
Updates the requirements on [thiserror](https://github.com/dtolnay/thiserror) to permit the latest version.

Updates `thiserror` to 1.0.69
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](dtolnay/thiserror@1.0.0...1.0.69)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  dependency-group: cargo-crates
...

This removes the fake std module in aya-obj which is no longer needed as
thiserror now properly supports no_std.

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
  • Loading branch information
dependabot[bot] authored and tamird committed Nov 11, 2024
1 parent fbbc2ec commit a89947f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 39 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ bytes = { version = "1", default-features = false }
cargo_metadata = { version = "0.18.0", default-features = false }
clap = { version = "4", default-features = false }
const-assert = { version = "1.0.1", default-features = false }
core-error = { version = "0.0.0", default-features = false }
dialoguer = { version = "0.11", default-features = false }
diff = { version = "0.1.13", default-features = false }
env_logger = { version = "0.11", default-features = false }
Expand Down Expand Up @@ -92,7 +91,7 @@ tempfile = { version = "3", default-features = false }
test-case = { version = "3.1.0", default-features = false }
test-log = { version = "0.2.13", default-features = false }
testing_logger = { version = "0.1.1", default-features = false }
thiserror = { version = "1", default-features = false }
thiserror = { version = "2", default-features = false }
tokio = { version = "1.24.0", default-features = false }
which = { version = "7.0.0", default-features = false }
xdpilone = { version = "1.0.5", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions aya-obj/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ edition.workspace = true

[dependencies]
bytes = { workspace = true }
core-error = { workspace = true, default-features = true }
hashbrown = { workspace = true, default-features = true }
log = { workspace = true }
object = { workspace = true, features = ["elf", "read_core"] }
Expand All @@ -24,4 +23,4 @@ assert_matches = { workspace = true }
rbpf = { workspace = true }

[features]
std = []
std = ["thiserror/std"]
14 changes: 6 additions & 8 deletions aya-obj/src/btf/btf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use bytes::BufMut;
use log::debug;
use object::{Endianness, SectionIndex};

#[cfg(not(feature = "std"))]
use crate::std;
use crate::{
btf::{
info::{FuncSecInfo, LineSecInfo},
Expand Down Expand Up @@ -282,7 +280,7 @@ impl Btf {

/// Adds a string to BTF metadata, returning an offset
pub fn add_string(&mut self, name: &str) -> u32 {
let str = name.bytes().chain(std::iter::once(0));
let str = name.bytes().chain(core::iter::once(0));
let name_offset = self.strings.len();
self.strings.extend(str);
self.header.str_len = self.strings.len() as u32;
Expand Down Expand Up @@ -532,7 +530,7 @@ impl Btf {
name_offset = self.add_string(&fixed_name);
}

let entries = std::mem::take(&mut d.entries);
let entries = core::mem::take(&mut d.entries);

let members = entries
.iter()
Expand Down Expand Up @@ -788,7 +786,7 @@ impl BtfExt {
pub hdr_len: u32,
}

if data.len() < std::mem::size_of::<MinimalHeader>() {
if data.len() < core::mem::size_of::<MinimalHeader>() {
return Err(BtfError::InvalidHeader);
}

Expand All @@ -809,18 +807,18 @@ impl BtfExt {
// forwards compatibility: if newer headers are bigger
// than the pre-generated btf_ext_header we should only
// read up to btf_ext_header
let len_to_read = len_to_read.min(std::mem::size_of::<btf_ext_header>());
let len_to_read = len_to_read.min(core::mem::size_of::<btf_ext_header>());

// now create our full-fledge header; but start with it
// zeroed out so unavailable fields stay as zero on older
// BTF.ext sections
let mut header = std::mem::MaybeUninit::<btf_ext_header>::zeroed();
let mut header = core::mem::MaybeUninit::<btf_ext_header>::zeroed();
// Safety: we have checked that len_to_read is less than
// size_of::<btf_ext_header> and less than
// data.len(). Additionally, we know that the header has
// been initialized so it's safe to call for assume_init.
unsafe {
std::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read);
core::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read);
header.assume_init()
}
};
Expand Down
2 changes: 0 additions & 2 deletions aya-obj/src/btf/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use core::{mem, ops::Bound::Included, ptr};

use object::SectionIndex;

#[cfg(not(feature = "std"))]
use crate::std;
use crate::{
btf::{
fields_are_compatible, types_are_compatible, Array, Btf, BtfError, BtfMember, BtfType,
Expand Down
19 changes: 3 additions & 16 deletions aya-obj/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,6 @@
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
#[cfg(not(feature = "std"))]
mod std {
pub mod error {
pub use core_error::Error;
}
pub use core::*;

pub mod os {
pub mod fd {
pub type RawFd = core::ffi::c_int;
}
}
}

pub mod btf;
pub mod generated;
Expand All @@ -109,15 +96,15 @@ impl VerifierLog {
}
}

impl std::fmt::Debug for VerifierLog {
impl core::fmt::Debug for VerifierLog {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let Self(log) = self;
f.write_str(log)
}
}

impl std::fmt::Display for VerifierLog {
impl core::fmt::Display for VerifierLog {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
<Self as std::fmt::Debug>::fmt(self, f)
<Self as core::fmt::Debug>::fmt(self, f)
}
}
2 changes: 0 additions & 2 deletions aya-obj/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use alloc::vec::Vec;
use core::mem;

#[cfg(not(feature = "std"))]
use crate::std;
use crate::{EbpfSectionKind, InvalidTypeBinding};

impl TryFrom<u32> for crate::generated::bpf_map_type {
Expand Down
2 changes: 0 additions & 2 deletions aya-obj/src/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ use object::{
SymbolKind,
};

#[cfg(not(feature = "std"))]
use crate::std;
use crate::{
btf::{
Array, Btf, BtfError, BtfExt, BtfFeatures, BtfType, DataSecEntry, FuncSecInfo, LineSecInfo,
Expand Down
13 changes: 8 additions & 5 deletions aya-obj/src/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use core::mem;
use log::debug;
use object::{SectionIndex, SymbolKind};

#[cfg(not(feature = "std"))]
use crate::std;
use crate::{
generated::{
bpf_insn, BPF_CALL, BPF_JMP, BPF_K, BPF_PSEUDO_CALL, BPF_PSEUDO_FUNC, BPF_PSEUDO_MAP_FD,
Expand All @@ -19,6 +17,11 @@ use crate::{
EbpfSectionKind,
};

#[cfg(feature = "std")]
type RawFd = std::os::fd::RawFd;
#[cfg(not(feature = "std"))]
type RawFd = core::ffi::c_int;

pub(crate) const INS_SIZE: usize = mem::size_of::<bpf_insn>();

/// The error type returned by [`Object::relocate_maps`] and [`Object::relocate_calls`]
Expand Down Expand Up @@ -104,7 +107,7 @@ pub(crate) struct Symbol {

impl Object {
/// Relocates the map references
pub fn relocate_maps<'a, I: Iterator<Item = (&'a str, std::os::fd::RawFd, &'a Map)>>(
pub fn relocate_maps<'a, I: Iterator<Item = (&'a str, RawFd, &'a Map)>>(
&mut self,
maps: I,
text_sections: &HashSet<usize>,
Expand Down Expand Up @@ -179,8 +182,8 @@ impl Object {
fn relocate_maps<'a, I: Iterator<Item = &'a Relocation>>(
fun: &mut Function,
relocations: I,
maps_by_section: &HashMap<usize, (&str, std::os::fd::RawFd, &Map)>,
maps_by_symbol: &HashMap<usize, (&str, std::os::fd::RawFd, &Map)>,
maps_by_section: &HashMap<usize, (&str, RawFd, &Map)>,
maps_by_symbol: &HashMap<usize, (&str, RawFd, &Map)>,
symbol_table: &HashMap<usize, Symbol>,
text_sections: &HashSet<usize>,
) -> Result<(), RelocationError> {
Expand Down

0 comments on commit a89947f

Please sign in to comment.