Skip to content

Commit

Permalink
chore: fix unsafe in unsafe blocks lint
Browse files Browse the repository at this point in the history
Enable this lint and fix the two cases where it breaks.
  • Loading branch information
vthib committed Sep 27, 2023
1 parent 524bc0e commit afa4189
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion boreal/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ impl Compiler {
pub unsafe fn new_with_pe_signatures() -> Self {
let mut this = Self::new_without_pe_module();

let _r = this.add_module(crate::module::Pe::new_with_signatures());
let _r = this.add_module(
// Safety: guaranteed by the safety contract of this function
unsafe { crate::module::Pe::new_with_signatures() },
);

this
}
Expand Down
1 change: 1 addition & 0 deletions boreal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#![deny(unused_lifetimes)]
#![deny(unused_qualifications)]
#![deny(unused_results)]
#![deny(unsafe_op_in_unsafe_fn)]
// Do the same for clippy
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
Expand Down
5 changes: 4 additions & 1 deletion boreal/src/module/pe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,10 @@ impl Pe {
#[cfg(feature = "authenticode")]
pub unsafe fn new_with_signatures() -> Self {
Self {
token: Some(authenticode_parser::InitializationToken::new()),
token: Some(
// Safety: guaranteed by the safety contract of this function
unsafe { authenticode_parser::InitializationToken::new() },
),
}
}

Expand Down

0 comments on commit afa4189

Please sign in to comment.