Skip to content

Commit

Permalink
Fix test workload warnings for no_std.
Browse files Browse the repository at this point in the history
Fix missing cargo-clippy feature warning.

Fix unused imports / functions warnings when testing no_std.

Fix unused mut warning in rbpf_plugin.rs.

Fix unused Error, Errorkind import warning.

Signed-off-by: SzymonKubica <szymo.kubica@gmail.com>
  • Loading branch information
SzymonKubica committed Jun 9, 2024
1 parent e4d186c commit 9b6eb04
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ hex = "0.4.3"

[features]
default = ["std"]
cargo-clippy = []
std = ["dep:time", "dep:libc", "combine/std"]
cranelift = [
"dep:cranelift-codegen",
Expand Down
1 change: 1 addition & 0 deletions examples/rbpf_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn _unwind(a: u64, _b: u64, _c: u64, _d: u64, _e: u64) -> u64
// It reads the program from stdin.
fn main() {
let mut args: Vec<String> = std::env::args().collect();
#[allow(unused_mut)] // In no_std the jit variable isn't mutated.
let mut jit : bool = false;
let mut cranelift : bool = false;
let mut program_text = String::new();
Expand Down
4 changes: 4 additions & 0 deletions tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

extern crate rbpf;

#[cfg(feature = "std")]
use rbpf::lib::{Error, ErrorKind};
#[cfg(feature = "std")]
use rbpf::assembler::assemble;
#[cfg(feature = "std")]
use rbpf::helpers;

// The following two examples have been compiled from C with the following command:
Expand Down Expand Up @@ -573,10 +575,12 @@ fn test_vm_exec_no_program() {
assert_eq!(vm.execute_program().unwrap(), 0xBEE);
}

#[cfg(feature = "std")]
fn verifier_success(_prog: &[u8]) -> Result<(), Error> {
Ok(())
}

#[cfg(feature = "std")]
fn verifier_fail(_prog: &[u8]) -> Result<(), Error> {
Err(Error::new(ErrorKind::Other,
"Gaggablaghblagh!"))
Expand Down

0 comments on commit 9b6eb04

Please sign in to comment.