From: Danilo Krummrich <dakr@redhat.com>
To: mcgrof@kernel.org, russ.weight@linux.dev, gregkh@linuxfoundation.org
Cc: chrisi.schrefl@gmail.com, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org,
Danilo Krummrich <dakr@redhat.com>
Subject: [PATCH v2 1/2] firmware_loader: annotate doctests as `no_run`
Date: Mon, 8 Jul 2024 22:07:20 +0200 [thread overview]
Message-ID: <20240708200724.3203-1-dakr@redhat.com> (raw)
The doctests of `Firmware` are compile-time only tests, since they
require a proper `Device` and a valid path to a (firmware) blob in order
to do something sane on runtime - we can't satisfy both of those
requirements.
Hence, configure the example as `no_run`.
Unfortunately, the kernel's Rust build system can't consider the
`no_run` attribute yet. Hence, for the meantime, wrap the example code
into a new function and never actually call it.
Fixes: de6582833db0 ("rust: add firmware abstractions")
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
v2: (no changes)
---
rust/kernel/firmware.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs
index 386c8fb44785..106a928a535e 100644
--- a/rust/kernel/firmware.rs
+++ b/rust/kernel/firmware.rs
@@ -26,14 +26,18 @@
///
/// # Examples
///
-/// ```
+/// ```no_run
/// # use kernel::{c_str, device::Device, firmware::Firmware};
///
+/// # fn no_run() -> Result<(), Error> {
/// # // SAFETY: *NOT* safe, just for the example to get an `ARef<Device>` instance
/// # let dev = unsafe { Device::from_raw(core::ptr::null_mut()) };
///
-/// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev).unwrap();
+/// let fw = Firmware::request(c_str!("path/to/firmware.bin"), &dev)?;
/// let blob = fw.data();
+///
+/// # Ok(())
+/// # }
/// ```
pub struct Firmware(NonNull<bindings::firmware>);
base-commit: 997197b58bf6e22b8c6ef88a168d8292fa9acec9
--
2.45.2
next reply other threads:[~2024-07-08 20:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 20:07 Danilo Krummrich [this message]
2024-07-08 20:07 ` [PATCH v2 2/2] firmware_loader: fix soundness issue in `request_internal` Danilo Krummrich
2024-07-08 20:37 ` Luis Chamberlain
2024-07-08 21:07 ` Danilo Krummrich
2024-07-08 22:16 ` Christian Schrefl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240708200724.3203-1-dakr@redhat.com \
--to=dakr@redhat.com \
--cc=chrisi.schrefl@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=russ.weight@linux.dev \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.