mirror of https://github.com/aya-rs/aya
Merge pull request #1234 from dave-tucker/fix-clippy-warn
chore: Fix clippy panic_handler warningspull/1235/head
commit
816f6d8a25
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "ebpf-panic"
|
||||
publish = false
|
||||
version = "1.0.0"
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
@ -0,0 +1,33 @@
|
||||
//! A panic handler for eBPF rust targets.
|
||||
//!
|
||||
//! Panics are not supported in the eBPF rust targets however since crates for
|
||||
//! the eBPF targets are no_std they must provide a panic handler. This crate
|
||||
//! provides a panic handler that loops forever. Such a function, if called,
|
||||
//! will cause the program to be rejected by the eBPF verifier with an error
|
||||
//! message similar to:
|
||||
//!
|
||||
//! ```text
|
||||
//! last insn is not an exit or jmp
|
||||
//! ```
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```ignore
|
||||
//! #![no_std]
|
||||
//!
|
||||
//! use aya_ebpf::{macros::tracepoint, programs::TracePointContext};
|
||||
//! #[cfg(not(test))]
|
||||
//! extern crate ebpf_panic;
|
||||
//!
|
||||
//! #[tracepoint]
|
||||
//! pub fn test_tracepoint_one(_ctx: TracePointContext) -> u32 {
|
||||
//! 0
|
||||
//! }
|
||||
//! ```
|
||||
#![no_std]
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[panic_handler]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
Loading…
Reference in New Issue