rust-analyzer: Enable check all targets on save

This switches off the panic_handler in ebpf code using conditional
compilation... and fixes a lot of suppressed lints.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/329/head
Dave Tucker 2 years ago
parent 0a5ac655de
commit dfd26f9071

@ -1,4 +1,3 @@
{ {
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy" "rust-analyzer.checkOnSave.command": "clippy"
} }

@ -1,4 +1,3 @@
{ {
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.command": "clippy" "rust-analyzer.checkOnSave.command": "clippy"
} }

@ -6,7 +6,7 @@ members = [
# ebpf crates # ebpf crates
"bpf/aya-bpf", "bpf/aya-bpf-bindings", "bpf/aya-log-ebpf", "test/integration-ebpf" "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] [profile.dev]
panic = "abort" panic = "abort"

@ -480,7 +480,6 @@ mod test {
use super::*; use super::*;
use aya_log_common::{write_record_header, WriteToBuf}; use aya_log_common::{write_record_header, WriteToBuf};
use log::logger; use log::logger;
use testing_logger;
fn new_log(args: usize) -> Result<(usize, Vec<u8>), ()> { fn new_log(args: usize) -> Result<(usize, Vec<u8>), ()> {
let mut buf = vec![0; 8192]; let mut buf = vec![0; 8192];

@ -1488,7 +1488,6 @@ mod tests {
map_flags: 5, map_flags: 5,
id: 0, id: 0,
pinning: PinningType::None, pinning: PinningType::None,
..Default::default()
}; };
assert_eq!( assert_eq!(
@ -1507,7 +1506,6 @@ mod tests {
map_flags: 5, map_flags: 5,
id: 6, id: 6,
pinning: PinningType::ByName, pinning: PinningType::ByName,
..Default::default()
}; };
assert_eq!(parse_map_def("foo", bytes_of(&def)).unwrap(), def); assert_eq!(parse_map_def("foo", bytes_of(&def)).unwrap(), def);
@ -1523,7 +1521,6 @@ mod tests {
map_flags: 5, map_flags: 5,
id: 6, id: 6,
pinning: PinningType::ByName, pinning: PinningType::ByName,
..Default::default()
}; };
let mut buf = [0u8; 128]; let mut buf = [0u8; 128];
unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) }; unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) };
@ -1554,7 +1551,6 @@ mod tests {
map_flags: 5, map_flags: 5,
id: 0, id: 0,
pinning: PinningType::None, pinning: PinningType::None,
..Default::default()
}) })
), ),
"foo" "foo"
@ -2223,7 +2219,6 @@ mod tests {
map_flags: BPF_F_RDONLY_PROG, map_flags: BPF_F_RDONLY_PROG,
id: 1, id: 1,
pinning: PinningType::None, pinning: PinningType::None,
..Default::default()
}, },
section_index: 1, section_index: 1,
symbol_index: 1, symbol_index: 1,

@ -5,7 +5,6 @@ use aya_common::{
}; };
use crate::{ use crate::{
args::FromPtRegs,
helpers::{bpf_probe_read_kernel, bpf_probe_read_user}, helpers::{bpf_probe_read_kernel, bpf_probe_read_user},
macros::map, macros::map,
maps::{Array, HashMap}, maps::{Array, HashMap},
@ -18,6 +17,9 @@ use crate::bindings::pt_regs;
#[cfg(bpf_target_arch = "aarch64")] #[cfg(bpf_target_arch = "aarch64")]
use crate::bindings::user_pt_regs as pt_regs; use crate::bindings::user_pt_regs as pt_regs;
#[cfg(not(feature = "cookie"))]
use crate::args::FromPtRegs;
#[map(name = "__bpf_usdt_specs")] #[map(name = "__bpf_usdt_specs")]
static USDT_SPECS: Array<UsdtSpec> = Array::with_max_entries(USDT_MAX_SPEC_COUNT, 0); static USDT_SPECS: Array<UsdtSpec> = Array::with_max_entries(USDT_MAX_SPEC_COUNT, 0);
@ -46,6 +48,7 @@ impl UsdtContext {
} }
/// Access the register that holds the next instruction pointer. /// Access the register that holds the next instruction pointer.
#[cfg(not(feature = "cookie"))]
#[inline(always)] #[inline(always)]
fn ip<T: FromPtRegs>(&self) -> Option<T> { fn ip<T: FromPtRegs>(&self) -> Option<T> {
T::from_ip(unsafe { &*self.regs }) T::from_ip(unsafe { &*self.regs })
@ -80,7 +83,7 @@ impl UsdtContext {
if n > USDT_MAX_ARG_COUNT { if n > USDT_MAX_ARG_COUNT {
return Err(UsdtError::MaxArgCount); 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)?; let spec = USDT_SPECS.get(spec_id).ok_or(UsdtError::SpecIdNotFound)?;
if n > (spec.arg_count as usize) { if n > (spec.arg_count as usize) {

@ -26,6 +26,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS) Ok(xdp_action::XDP_PASS)
} }
#[cfg(target_arch = "bpf")]
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() } unsafe { core::hint::unreachable_unchecked() }

@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS) Ok(xdp_action::XDP_PASS)
} }
#[cfg(target_arch = "bpf")]
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() } unsafe { core::hint::unreachable_unchecked() }

@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS) Ok(xdp_action::XDP_PASS)
} }
#[cfg(target_arch = "bpf")]
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() } unsafe { core::hint::unreachable_unchecked() }

@ -15,6 +15,7 @@ unsafe fn try_pass(_ctx: XdpContext) -> Result<u32, u32> {
Ok(xdp_action::XDP_PASS) Ok(xdp_action::XDP_PASS)
} }
#[cfg(target_arch = "bpf")]
#[panic_handler] #[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! { fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() } unsafe { core::hint::unreachable_unchecked() }

Loading…
Cancel
Save