Skip to content

Commit

Permalink
rust-analyzer: Enable check all targets on save
Browse files Browse the repository at this point in the history
This switches off the panic_handler in ebpf code using conditional
compilation... and fixes a lot of suppressed lints.

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Oct 13, 2022
1 parent 6de6633 commit cfd7226
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy"
}
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy"
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
# ebpf crates
"bpf/aya-bpf", "bpf/aya-bpf-bindings", "bpf/aya-log-ebpf", "test/integration-ebpf"
]
default-members = ["aya", "aya-tool", "aya-log", "aya-bpf-macros", "aya-log-ebpf-macros"]
default-members = ["aya", "aya-common", "aya-tool", "aya-log", "aya-bpf-macros", "aya-log-ebpf-macros"]

[profile.dev]
panic = "abort"
Expand Down
1 change: 0 additions & 1 deletion aya-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ mod test {
use super::*;
use aya_log_common::{write_record_header, WriteToBuf};
use log::logger;
use testing_logger;

fn new_log(args: usize) -> Result<(usize, Vec<u8>), ()> {
let mut buf = vec![0; 8192];
Expand Down
5 changes: 0 additions & 5 deletions aya/src/obj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,6 @@ mod tests {
map_flags: 5,
id: 0,
pinning: PinningType::None,
..Default::default()
};

assert_eq!(
Expand All @@ -1507,7 +1506,6 @@ mod tests {
map_flags: 5,
id: 6,
pinning: PinningType::ByName,
..Default::default()
};

assert_eq!(parse_map_def("foo", bytes_of(&def)).unwrap(), def);
Expand All @@ -1523,7 +1521,6 @@ mod tests {
map_flags: 5,
id: 6,
pinning: PinningType::ByName,
..Default::default()
};
let mut buf = [0u8; 128];
unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) };
Expand Down Expand Up @@ -1554,7 +1551,6 @@ mod tests {
map_flags: 5,
id: 0,
pinning: PinningType::None,
..Default::default()
})
),
"foo"
Expand Down Expand Up @@ -2223,7 +2219,6 @@ mod tests {
map_flags: BPF_F_RDONLY_PROG,
id: 1,
pinning: PinningType::None,
..Default::default()
},
section_index: 1,
symbol_index: 1,
Expand Down
7 changes: 5 additions & 2 deletions bpf/aya-bpf/src/programs/usdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use aya_common::{
};

use crate::{
args::FromPtRegs,
helpers::{bpf_probe_read_kernel, bpf_probe_read_user},
macros::map,
maps::{Array, HashMap},
Expand All @@ -18,6 +17,9 @@ use crate::bindings::pt_regs;
#[cfg(bpf_target_arch = "aarch64")]
use crate::bindings::user_pt_regs as pt_regs;

#[cfg(not(feature = "cookie"))]
use crate::args::FromPtRegs;

#[map(name = "__bpf_usdt_specs")]
static USDT_SPECS: Array<UsdtSpec> = Array::with_max_entries(USDT_MAX_SPEC_COUNT, 0);

Expand Down Expand Up @@ -46,6 +48,7 @@ impl UsdtContext {
}

/// Access the register that holds the next instruction pointer.
#[cfg(not(feature = "cookie"))]
#[inline(always)]
fn ip<T: FromPtRegs>(&self) -> Option<T> {
T::from_ip(unsafe { &*self.regs })
Expand Down Expand Up @@ -80,7 +83,7 @@ impl UsdtContext {
if n > USDT_MAX_ARG_COUNT {
return Err(UsdtError::MaxArgCount);
}
let spec_id = self.spec_id()?;
let spec_id = self.spec_id().map_err(|_| UsdtError::SpecIdNotFound)?;
let spec = USDT_SPECS.get(spec_id).ok_or(UsdtError::SpecIdNotFound)?;

if n > (spec.arg_count as usize) {
Expand Down
1 change: 1 addition & 0 deletions test/integration-ebpf/src/map_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS)
}

#[cfg(target_arch = "bpf")]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
Expand Down
1 change: 1 addition & 0 deletions test/integration-ebpf/src/name_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS)
}

#[cfg(target_arch = "bpf")]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
Expand Down
1 change: 1 addition & 0 deletions test/integration-ebpf/src/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS)
}

#[cfg(target_arch = "bpf")]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
Expand Down
1 change: 1 addition & 0 deletions test/integration-ebpf/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS)
}

#[cfg(target_arch = "bpf")]
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
Expand Down

0 comments on commit cfd7226

Please sign in to comment.