Skip to content

Commit

Permalink
chore: fix new clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vthib committed Dec 9, 2024
1 parent dd31aaf commit 45b4bb4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion boreal-parser/src/nom_recipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn singleline_comment(input: Input) -> ParseResult<()> {
pub(crate) fn map_res<'a, O1, O2, F, G>(
mut parser: F,
mut f: G,
) -> impl FnMut(Input<'a>) -> ParseResult<O2>
) -> impl FnMut(Input<'a>) -> ParseResult<'a, O2>
where
F: Parser<Input<'a>, O1, Error>,
G: FnMut(O1) -> Result<O2, ErrorKind>,
Expand Down
4 changes: 2 additions & 2 deletions boreal/src/matcher/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const DEFAULT_ALPHABET: &[u8; 64] =
///
/// How this work is that every byte from the resulting base64 string that is involved with
/// padding is removed from the returned value.
pub fn encode_base64(s: &[u8], alphabet: &Option<[u8; 64]>, offset: usize) -> Option<Vec<u8>> {
let alphabet = alphabet.as_ref().unwrap_or(DEFAULT_ALPHABET);
pub fn encode_base64(s: &[u8], alphabet: Option<&[u8; 64]>, offset: usize) -> Option<Vec<u8>> {
let alphabet = alphabet.unwrap_or(DEFAULT_ALPHABET);

let mut res = Vec::with_capacity(s.len() * 4 / 3);

Expand Down
8 changes: 6 additions & 2 deletions boreal/src/matcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ impl Matcher {
if base64.ascii {
for lit in &old_literals {
for offset in 0..=2 {
if let Some(lit) = base64::encode_base64(lit, &base64.alphabet, offset) {
if let Some(lit) =
base64::encode_base64(lit, base64.alphabet.as_ref(), offset)
{
// Fullword is not compatible with base64 modifiers, hence ordering of
// literals is not required.
if base64.wide {
Expand All @@ -233,7 +235,9 @@ impl Matcher {
} else {
for lit in &old_literals {
for offset in 0..=2 {
if let Some(lit) = base64::encode_base64(lit, &base64.alphabet, offset) {
if let Some(lit) =
base64::encode_base64(lit, base64.alphabet.as_ref(), offset)
{
literals.push(string_to_wide(&lit));
}
}
Expand Down
4 changes: 2 additions & 2 deletions boreal/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl<'a> Memory<'a> {
pub(crate) fn new_fragmented(
obj: Box<dyn FragmentedMemory + 'a>,
params: MemoryParams,
) -> Memory {
Memory::Fragmented(Fragmented { obj, params })
) -> Self {
Self::Fragmented(Fragmented { obj, params })
}
}

Expand Down
4 changes: 2 additions & 2 deletions boreal/tests/it/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ macro_rules! define_symbol_scanner_method {
};
}

impl<'a> Scanner<'a> {
impl Scanner<'_> {
#[track_caller]
pub fn check(&mut self, mem: &[u8], expected_res: bool) {
self.check_boreal(mem, expected_res);
Expand Down Expand Up @@ -1115,7 +1115,7 @@ struct YaraBlocks<'a> {
regions: &'a [(usize, Option<&'a [u8]>)],
}

impl<'a> yara::MemoryBlockIterator for YaraBlocks<'a> {
impl yara::MemoryBlockIterator for YaraBlocks<'_> {
fn first(&mut self) -> Option<yara::MemoryBlock> {
self.current = 0;
self.next()
Expand Down

0 comments on commit 45b4bb4

Please sign in to comment.