From b28ae97053de744e8558ef50e5f877894146622e Mon Sep 17 00:00:00 2001 From: William Findlay Date: Wed, 22 Dec 2021 01:27:10 -0500 Subject: [PATCH] bpf/macros: fix tests Doctests were broken due to depencencies on a generated vmlinux, incorrect function signatures, and a missing unsafe keyword. --- bpf/aya-bpf-macros/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bpf/aya-bpf-macros/src/lib.rs b/bpf/aya-bpf-macros/src/lib.rs index 4ae01f83..61d49bae 100644 --- a/bpf/aya-bpf-macros/src/lib.rs +++ b/bpf/aya-bpf-macros/src/lib.rs @@ -358,18 +358,20 @@ pub fn socket_filter(attrs: TokenStream, item: TokenStream) -> TokenStream { /// # Examples /// /// ```no_run +/// # #![allow(non_camel_case_types)] /// use aya_bpf::{macros::fentry, programs::FEntryContext}; -/// use vmlinux::{filename, path}; +/// # type filename = u32; +/// # type path = u32; /// /// #[fentry(name = "filename_lookup")] /// fn filename_lookup(ctx: FEntryContext) -> i32 { -/// match { try_filename_lookup(ctx) } { +/// match unsafe { try_filename_lookup(ctx) } { /// Ok(ret) => ret, /// Err(ret) => ret, /// } /// } /// -/// unsafe fn try_filename_lookup(ctx: FEntryContext) -> Result { +/// unsafe fn try_filename_lookup(ctx: FEntryContext) -> Result { /// let _f: *const filename = ctx.arg(1); /// let _p: *const path = ctx.arg(3); /// @@ -400,18 +402,20 @@ pub fn fentry(attrs: TokenStream, item: TokenStream) -> TokenStream { /// # Examples /// /// ```no_run +/// # #![allow(non_camel_case_types)] /// use aya_bpf::{macros::fexit, programs::FExitContext}; -/// use vmlinux::{filename, path}; +/// # type filename = u32; +/// # type path = u32; /// /// #[fexit(name = "filename_lookup")] /// fn filename_lookup(ctx: FExitContext) -> i32 { -/// match { try_filename_lookup(ctx) } { +/// match unsafe { try_filename_lookup(ctx) } { /// Ok(ret) => ret, /// Err(ret) => ret, /// } /// } /// -/// unsafe fn try_filename_lookup(ctx: FExitContext) -> Result { +/// unsafe fn try_filename_lookup(ctx: FExitContext) -> Result { /// let _f: *const filename = ctx.arg(1); /// let _p: *const path = ctx.arg(3); ///