Skip to content

Commit 1eda3a5

Browse files
authored
Add deny lints to hyperlight-host crate (#352)
* cargo: fix test application Cargo.lock files Signed-off-by: Doru Blânzeanu <dblnz@pm.me> * cargo: add crate level deny lints for hyperlight-host - denies dead_code, missing_docs and unused_mut in the crate Signed-off-by: Doru Blânzeanu <dblnz@pm.me> --------- Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
1 parent f570a2d commit 1eda3a5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/hyperlight_host/src/lib.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
#![deny(dead_code, missing_docs, unused_mut)]
17+
//! This crate contains an SDK that is used to execute specially-
18+
// compiled binaries within a very lightweight hypervisor environment.
1619

1720
use std::sync::Once;
1821

19-
/// This crate contains an SDK that is used to execute specially-
20-
/// compiled binaries within a very lightweight hypervisor environment.
2122
use log::info;
2223
/// The `built` crate is used to generate a `built.rs` file that contains
2324
/// information about the build environment. This information is used to
@@ -26,13 +27,10 @@ pub(crate) mod built_info {
2627
include!(concat!(env!("OUT_DIR"), "/built.rs"));
2728
}
2829
/// Dealing with errors, including errors across VM boundaries
29-
#[deny(dead_code, missing_docs, unused_mut)]
3030
pub mod error;
3131
/// Wrappers for host and guest functions.
32-
#[deny(dead_code, missing_docs, unused_mut)]
3332
pub mod func;
3433
/// Wrappers for hypervisor implementations
35-
#[deny(dead_code, missing_docs, unused_mut)]
3634
pub mod hypervisor;
3735
/// Functionality to establish and manage an individual sandbox's
3836
/// memory.
@@ -62,15 +60,12 @@ pub mod hypervisor;
6260
///
6361
/// The pointer passed to the Entrypoint in the Guest application is the 0x200000 + size of page table + size of code,
6462
/// at this address structs below are laid out in this order
65-
#[deny(dead_code, missing_docs, unused_mut)]
6663
pub mod mem;
6764
/// Metric definitions and helpers
68-
#[deny(dead_code, missing_docs, unused_mut)]
6965
pub mod metrics;
7066
/// The main sandbox implementations. Do not use this module directly in code
7167
/// outside this file. Types from this module needed for public consumption are
7268
/// re-exported below.
73-
#[deny(dead_code, missing_docs, unused_mut)]
7469
pub mod sandbox;
7570
/// `trait`s and other functionality for dealing with defining sandbox
7671
/// states and moving between them
@@ -82,7 +77,6 @@ pub(crate) mod seccomp;
8277
pub(crate) mod signal_handlers;
8378
/// Utilities for testing including interacting with `simpleguest.exe`
8479
/// and `callbackguest.exe`, our two most basic guest binaries for testing
85-
#[deny(missing_docs, unused_mut)]
8680
#[cfg(test)]
8781
pub(crate) mod testing;
8882

@@ -110,8 +104,8 @@ pub use crate::func::call_ctx::MultiUseGuestCallContext;
110104
/// The universal `Result` type used throughout the Hyperlight codebase.
111105
pub type Result<T> = core::result::Result<T, error::HyperlightError>;
112106

113-
// Logs an error then returns with it , more or less equivalent to the bail! macro in anyhow
114-
// but for HyperlightError instead of anyhow::Error
107+
/// Logs an error then returns with it, more or less equivalent to the bail! macro in anyhow
108+
/// but for HyperlightError instead of anyhow::Error
115109
#[macro_export]
116110
macro_rules! log_then_return {
117111
($msg:literal $(,)?) => {{
@@ -140,7 +134,7 @@ macro_rules! log_then_return {
140134
};
141135
}
142136

143-
// same as log::debug!, but will additionally print to stdout if the print_debug feature is enabled
137+
/// Same as log::debug!, but will additionally print to stdout if the print_debug feature is enabled
144138
#[macro_export]
145139
macro_rules! debug {
146140
($($arg:tt)+) =>

src/hyperlight_host/src/sandbox_state/sandbox.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ pub trait Sandbox: Sized + Debug {
5555
/// A utility trait to recognize a Sandbox that has not yet been initialized.
5656
/// It allows retrieval of a strongly typed UninitializedSandbox.
5757
pub trait UninitializedSandbox: Sandbox {
58+
/// Retrieves reference to strongly typed `UninitializedSandbox`
5859
fn get_uninitialized_sandbox(&self) -> &crate::sandbox::UninitializedSandbox;
5960

61+
/// Retrieves mutable reference to strongly typed `UninitializedSandbox`
6062
fn get_uninitialized_sandbox_mut(&mut self) -> &mut crate::sandbox::UninitializedSandbox;
6163

64+
/// Returns `true` if the Sandbox is configured to run in process otherwise `false`
6265
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
6366
fn is_running_in_process(&self) -> bool {
6467
self.get_uninitialized_sandbox().run_inprocess
@@ -69,12 +72,14 @@ pub trait UninitializedSandbox: Sandbox {
6972
pub trait EvolvableSandbox<Cur: Sandbox, Next: Sandbox, T: TransitionMetadata<Cur, Next>>:
7073
Sandbox
7174
{
75+
/// Evolve `Self` to `Next` providing Metadata.
7276
fn evolve(self, tsn: T) -> Result<Next>;
7377
}
7478

7579
/// A `Sandbox` that knows how to roll back to a "previous" `Sandbox`
7680
pub trait DevolvableSandbox<Cur: Sandbox, Prev: Sandbox, T: TransitionMetadata<Cur, Prev>>:
7781
Sandbox
7882
{
83+
/// Devolve `Self` to `Prev` providing Metadata.
7984
fn devolve(self, tsn: T) -> Result<Prev>;
8085
}

src/hyperlight_host/src/sandbox_state/transition.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl<'a, Cur: Sandbox, F> MultiUseContextCallback<'a, Cur, F>
121121
where
122122
F: FnOnce(&mut MultiUseGuestCallContext) -> Result<()>,
123123
{
124+
/// Invokes the callback on the provided guest context
124125
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
125126
pub fn call(self, cur: &mut MultiUseGuestCallContext) -> Result<()> {
126127
(self.cb)(cur)

0 commit comments

Comments
 (0)