Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ff14wed committed Jul 6, 2024
1 parent 78cbc8d commit 17b0d51
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions deucalion/src/hook/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ pub enum HookType {

#[repr(u32)]
#[derive(Debug, Clone, Copy)]
pub(self) enum Channel {
enum Channel {
Lobby,
Zone,
Chat,
}

#[derive(Debug, Error)]
pub(self) enum HookError {
enum HookError {
#[error("number of signature matches is incorrect: {0} != {1}")]
SignatureMatchFailed(usize, usize),
}
Expand Down
6 changes: 3 additions & 3 deletions deucalion/src/procloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ pub fn get_ffxiv_filepath() -> Result<String> {
/// * `pat` - pattern to match
/// * `pe` - the PE to search through
/// * `save` - each level of the result is saved as additional entries in this
/// array
/// array
/// * `search_start_rva` - Optionally specify that the search range starts at a
/// different relative virtual address. Set to 0 for starting at the beginning.
/// different relative virtual address. Set to 0 for starting at the beginning.
pub fn fast_pattern_scan<'a, P: Pe<'a>>(
pat: &[pat::Atom],
pe: P,
Expand Down Expand Up @@ -298,7 +298,7 @@ mod tests {

#[test]
fn test_incorrect_pat_len() {
if let Ok(_) = get_pat_len_and_excerpt(BAD_SIG) {
if get_pat_len_and_excerpt(BAD_SIG).is_ok() {
panic!("Bad sig should return error");
}
}
Expand Down
4 changes: 2 additions & 2 deletions deucalion/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ mod tests {
let payload_op = payload.op as u8;
codec.encode(payload, &mut buf).unwrap();
let expected: &[u8] = &[12, 0, 0, 0, payload_op, 100, 0, 0, 0, 1, 2, 3];
let mut dst: &mut [u8] = &mut [0; 12];
buf.copy_to_slice(&mut dst);
let dst: &mut [u8] = &mut [0; 12];
buf.copy_to_slice(dst);
assert_eq!(dst, expected);
}
}
Expand Down
21 changes: 10 additions & 11 deletions deucalion/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ mod tests {
use std::sync::atomic::{AtomicU32, Ordering};

use super::*;
use ntest::timeout;
use ntest::{assert_false, assert_true, timeout};
use rand::Rng;
use tokio::{select, task::JoinHandle};

Expand All @@ -544,9 +544,9 @@ mod tests {
const ALLOW_EVERYTHING: u32 = 0xFF;
for (filter, op, ctx) in configurations {
let filter = filter as u32;
assert_eq!(allow_broadcast(op, ctx, ALLOW_EVERYTHING), true);
assert_eq!(allow_broadcast(op, ctx, filter), true);
assert_eq!(allow_broadcast(op, ctx, ALLOW_EVERYTHING & !filter), false);
assert_true!(allow_broadcast(op, ctx, ALLOW_EVERYTHING));
assert_true!(allow_broadcast(op, ctx, filter));
assert_false!(allow_broadcast(op, ctx, ALLOW_EVERYTHING & !filter));
}
}

Expand All @@ -573,7 +573,7 @@ mod tests {
),
];
for (nickname, expected_err) in nickname_tests {
match validate_nickname(&nickname.to_string()) {
match validate_nickname(nickname) {
Ok(()) => {
if let Some(err_msg) = expected_err {
panic!("Expected validation for {nickname} to error with {err_msg}");
Expand Down Expand Up @@ -718,10 +718,10 @@ mod tests {

select! {
data = frames.next() => {
assert_eq!(should_be_allowed, true, "packet should be filtered: {:?}", data);
assert!(should_be_allowed, "packet should be filtered: {:?}", data);
}
_ = time::sleep(Duration::from_millis(100)) => {
assert_eq!(should_be_allowed, false, "packet should not be filtered: {:?}: {}", op, ctx)
assert!(!should_be_allowed, "packet should not be filtered: {:?}: {}", op, ctx)
}
}
}
Expand Down Expand Up @@ -849,8 +849,7 @@ mod tests {

handle_server_hello(&mut frames).await;

let subscriber_handle =
tokio::spawn(async move { while let Some(_) = frames.next().await {} });
let subscriber_handle = tokio::spawn(async move { while frames.next().await.is_some() {} });

// Disconnect the subscriber forcefully
subscriber_handle.abort();
Expand Down Expand Up @@ -899,7 +898,7 @@ mod tests {

let codec = PayloadCodec::new();
let mut frames = Framed::new(subscriber, codec);
while let Some(_) = frames.next().await {}
while frames.next().await.is_some() {}
});
second_subscriber.abort();

Expand Down Expand Up @@ -994,7 +993,7 @@ mod tests {
if let Ok(subscriber) = Endpoint::connect(&pipe_name_clone).await {
let codec = PayloadCodec::new();
let mut frames = Framed::new(subscriber, codec);
while let Some(_) = frames.next().await {}
while frames.next().await.is_some() {}
}
});
sub_handle.abort();
Expand Down

0 comments on commit 17b0d51

Please sign in to comment.