Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmcdona committed Dec 21, 2024
1 parent 3cebf13 commit be73d05
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 66 deletions.
6 changes: 3 additions & 3 deletions src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ mod tests {
assert_eq!(subsystems.subsystem_offset, 0);
assert_eq!(subsystems.category_offset, 19);

let (_, subsystems) = CatalogChunk::parse_process_info_subystem(&data).unwrap();
let (_, subsystems) = CatalogChunk::parse_process_info_subystem(data).unwrap();
assert_eq!(subsystems.identifer, 78);
assert_eq!(subsystems.subsystem_offset, 0);
assert_eq!(subsystems.category_offset, 47);
Expand Down Expand Up @@ -667,7 +667,7 @@ mod tests {
assert_eq!(subchunk.number_string_offsets, 3);
assert_eq!(subchunk.string_offsets, [0, 19, 47]);

let (data, subchunk) = CatalogChunk::parse_catalog_subchunk(&data).unwrap();
let (data, subchunk) = CatalogChunk::parse_catalog_subchunk(data).unwrap();
assert_eq!(subchunk.start, 820274802743600);
assert_eq!(subchunk.end, 820313668399715);
assert_eq!(subchunk.uncompressed_size, 61552);
Expand All @@ -677,7 +677,7 @@ mod tests {
assert_eq!(subchunk.number_string_offsets, 3);
assert_eq!(subchunk.string_offsets, [0, 19, 47]);

let (_, subchunk) = CatalogChunk::parse_catalog_subchunk(&data).unwrap();
let (_, subchunk) = CatalogChunk::parse_catalog_subchunk(data).unwrap();
assert_eq!(subchunk.start, 820313685231257);
assert_eq!(subchunk.end, 820374429029888);
assert_eq!(subchunk.uncompressed_size, 65536);
Expand Down
2 changes: 1 addition & 1 deletion src/chunks/firehose/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod tests {
&firehose.firehose_activity,
&string_results,
&shared_strings_results,
firehose.format_string_location as u64,
u64::from(firehose.format_string_location),
&preamble.first_number_proc_id,
&preamble.second_number_proc_id,
&catalog_data.catalog,
Expand Down
46 changes: 20 additions & 26 deletions src/chunks/firehose/firehose_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2747,8 +2747,8 @@ mod tests {
assert_eq!(firehose.base_continous_time, 4197166166425);

let mut firehouse_result_count = firehose.public_data.len();
while data.len() != 0 {
let (test_data, firehose) = FirehosePreamble::parse_firehose_preamble(&data).unwrap();
while !data.is_empty() {
let (test_data, firehose) = FirehosePreamble::parse_firehose_preamble(data).unwrap();
data = test_data;
firehouse_result_count += firehose.public_data.len();
}
Expand Down Expand Up @@ -2786,9 +2786,8 @@ mod tests {
assert_eq!(firehose.firehose_non_activity.private_strings_offset, 0);
assert_eq!(firehose.firehose_non_activity.private_strings_size, 0);
assert_eq!(firehose.firehose_non_activity.unknown_message_string_ref, 0);
assert_eq!(
firehose.firehose_non_activity.firehose_formatters.main_exe,
false
assert!(
!firehose.firehose_non_activity.firehose_formatters.main_exe
);

assert_eq!(firehose.firehose_non_activity.subsystem_value, 14);
Expand Down Expand Up @@ -2979,19 +2978,17 @@ mod tests {
14968
);

assert_eq!(
assert!(
firehose.public_data[0]
.firehose_non_activity
.firehose_formatters
.main_exe,
true
.main_exe
);
assert_eq!(
firehose.public_data[0]
assert!(
!firehose.public_data[0]
.firehose_non_activity
.firehose_formatters
.shared_cache,
false
.shared_cache
);
assert_eq!(
firehose.public_data[0]
Expand All @@ -3007,12 +3004,11 @@ mod tests {
.large_shared_cache,
0
);
assert_eq!(
firehose.public_data[0]
assert!(
!firehose.public_data[0]
.firehose_non_activity
.firehose_formatters
.absolute,
false
.absolute
);
assert_eq!(
firehose.public_data[0]
Expand All @@ -3021,19 +3017,17 @@ mod tests {
.uuid_relative,
String::new()
);
assert_eq!(
firehose.public_data[0]
assert!(
!firehose.public_data[0]
.firehose_non_activity
.firehose_formatters
.main_plugin,
false
.main_plugin
);
assert_eq!(
firehose.public_data[0]
assert!(
!firehose.public_data[0]
.firehose_non_activity
.firehose_formatters
.pc_style,
false
.pc_style
);
assert_eq!(
firehose.public_data[0]
Expand Down Expand Up @@ -3396,8 +3390,8 @@ mod tests {
assert_eq!(firehose.base_continous_time, 0);

let mut firehouse_result_count = firehose.public_data.len();
while data.len() != 0 {
let (test_data, firehose) = FirehosePreamble::parse_firehose_preamble(&data).unwrap();
while !data.is_empty() {
let (test_data, firehose) = FirehosePreamble::parse_firehose_preamble(data).unwrap();
data = test_data;
firehouse_result_count += firehose.public_data.len();
}
Expand Down
6 changes: 3 additions & 3 deletions src/chunks/firehose/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod tests {
let test_flags = 514;
let (_, results) =
FirehoseFormatters::firehose_formatter_flags(&test_data, &test_flags).unwrap();
assert_eq!(results.main_exe, true);
assert!(results.main_exe);
}

#[test]
Expand All @@ -167,7 +167,7 @@ mod tests {
let test_flags = 516;
let (_, results) =
FirehoseFormatters::firehose_formatter_flags(&test_data, &test_flags).unwrap();
assert_eq!(results.shared_cache, true);
assert!(results.shared_cache);
}

#[test]
Expand All @@ -183,7 +183,7 @@ mod tests {
let test_flags = 8;
let (_, results) =
FirehoseFormatters::firehose_formatter_flags(&test_data, &test_flags).unwrap();
assert_eq!(results.absolute, true);
assert!(results.absolute);
assert_eq!(results.main_exe_alt_index, 65408);
}

Expand Down
2 changes: 1 addition & 1 deletion src/chunks/firehose/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ mod tests {

let test_uuid = "B736DF1625F538248E9527A8CEC4991E";

let (_, image_path) = MessageData::get_uuid_image_path(&test_uuid, &strings).unwrap();
let (_, image_path) = MessageData::get_uuid_image_path(test_uuid, &strings).unwrap();

assert_eq!(image_path, "/usr/libexec/opendirectoryd");
}
Expand Down
6 changes: 3 additions & 3 deletions src/chunks/firehose/nonactivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ mod tests {
nonactivity_results.firehose_formatters.uuid_relative,
String::from("")
);
assert_eq!(nonactivity_results.firehose_formatters.main_exe, false);
assert_eq!(nonactivity_results.firehose_formatters.absolute, false);
assert!(!nonactivity_results.firehose_formatters.main_exe);
assert!(!nonactivity_results.firehose_formatters.absolute);
assert_eq!(nonactivity_results.subsystem_value, 41);
assert_eq!(nonactivity_results.ttl_value, 0);
assert_eq!(nonactivity_results.data_ref_value, 0);
Expand Down Expand Up @@ -301,7 +301,7 @@ mod tests {
&firehose.firehose_non_activity,
&string_results,
&shared_strings_results,
firehose.format_string_location as u64,
u64::from(firehose.format_string_location),
&preamble.first_number_proc_id,
&preamble.second_number_proc_id,
&catalog_data.catalog,
Expand Down
12 changes: 6 additions & 6 deletions src/chunks/firehose/signpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ mod tests {
assert_eq!(results.ttl_value, 0);
assert_eq!(results.data_ref_value, 0);

assert_eq!(results.firehose_formatters.main_exe, true);
assert_eq!(results.firehose_formatters.shared_cache, false);
assert!(results.firehose_formatters.main_exe);
assert!(!results.firehose_formatters.shared_cache);
assert_eq!(results.firehose_formatters.has_large_offset, 0);
assert_eq!(results.firehose_formatters.large_shared_cache, 0);
assert_eq!(results.firehose_formatters.absolute, false);
assert!(!results.firehose_formatters.absolute);
assert_eq!(results.firehose_formatters.uuid_relative, String::new());
assert_eq!(results.firehose_formatters.main_plugin, false);
assert_eq!(results.firehose_formatters.pc_style, false);
assert!(!results.firehose_formatters.main_plugin);
assert!(!results.firehose_formatters.pc_style);
assert_eq!(results.firehose_formatters.main_exe_alt_index, 0);
}

Expand Down Expand Up @@ -306,7 +306,7 @@ mod tests {
&firehose.firehose_signpost,
&string_results,
&shared_strings_results,
firehose.format_string_location as u64,
u64::from(firehose.format_string_location),
&preamble.first_number_proc_id,
&preamble.second_number_proc_id,
&catalog_data.catalog,
Expand Down
2 changes: 1 addition & 1 deletion src/chunks/firehose/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ mod tests {
if firehose.unknown_log_activity_type == activity_type {
let (_, message_data) = FirehoseTrace::get_firehose_trace_strings(
&string_results,
firehose.format_string_location as u64,
u64::from(firehose.format_string_location),
&preamble.first_number_proc_id,
&preamble.second_number_proc_id,
&catalog_data.catalog,
Expand Down
2 changes: 1 addition & 1 deletion src/decoders/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ mod tests {
fn test_get_service_binding() {
let test_data =
"AAEAAAEAAwJoMgAEAAhoEJRAaBCVQAAGACAmBkcAAAAAAAAAAABoEJRAJgZHAAAAAAAAAAAAaBCVQA==";
let result = get_service_binding(&test_data).unwrap();
let result = get_service_binding(test_data).unwrap();
assert_eq!(result, "rdata: 1 . alpn=h2, ipv4 hint:104.16.148.64,104.16.149.64, ipv6 hint:2606:4700::6810:9440,2606:4700::6810:9540");
}

Expand Down
28 changes: 14 additions & 14 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Read;
use std::path::{Component, Path, PathBuf};
use walkdir::WalkDir;

/// Provides an implementation of [FileProvider] that enumerates the
/// Provides an implementation of [`FileProvider`] that enumerates the
/// required files at the correct paths on a live macOS system. These files are only present on
/// macOS Sierra (10.12) and above. The implemented methods emit error log messages if any are
/// encountered while enumerating files or creating readers, but are otherwise infallible.
Expand Down Expand Up @@ -45,7 +45,7 @@ impl From<&Path> for LogFileType {
if filename_s.len() == 30
&& only_hex_chars(filename_s)
&& parent_s.len() == 2
&& only_hex_chars(&parent_s)
&& only_hex_chars(parent_s)
{
return Self::UUIDText;
}
Expand All @@ -72,7 +72,7 @@ impl FileProvider for LiveSystemProvider {
.filter_map(|entry| entry.ok())
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::TraceV3))
.filter_map(|entry| {
Some(Box::new(std::fs::File::open(&entry.path()).ok()?) as Box<dyn Read>)
Some(Box::new(std::fs::File::open(entry.path()).ok()?) as Box<dyn Read>)
}),
)
}
Expand All @@ -86,15 +86,15 @@ impl FileProvider for LiveSystemProvider {
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::UUIDText))
.map(|entry| {
(
std::fs::File::open(&entry.path()),
std::fs::File::open(entry.path()),
entry
.file_name()
.to_os_string()
.to_string_lossy()
.into_owned(),
)
})
.filter_map(|(handle, file_name)| Some((handle.ok(), file_name)))
.map(|(handle, file_name)| (handle.ok(), file_name))
.filter_map(|(handle, file_name)| Some((handle?, file_name)))
.map(|(handle, file_name)| (Box::new(handle) as Box<dyn Read>, file_name)),
)
Expand All @@ -108,15 +108,15 @@ impl FileProvider for LiveSystemProvider {
.filter_map(|entry| entry.ok())
.map(|entry| {
(
std::fs::File::open(&entry.path()),
std::fs::File::open(entry.path()),
entry
.file_name()
.to_os_string()
.to_string_lossy()
.into_owned(),
)
})
.filter_map(|(handle, file_name)| Some((handle.ok(), file_name)))
.map(|(handle, file_name)| (handle.ok(), file_name))
.filter_map(|(handle, file_name)| Some((handle?, file_name)))
.map(|(handle, file_name)| (Box::new(handle) as Box<dyn Read>, file_name)),
)
Expand All @@ -130,7 +130,7 @@ impl FileProvider for LiveSystemProvider {
.filter_map(|entry| entry.ok())
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::Timesync))
.filter_map(|entry| {
Some(Box::new(std::fs::File::open(&entry.path()).ok()?) as Box<dyn Read>)
Some(Box::new(std::fs::File::open(entry.path()).ok()?) as Box<dyn Read>)
}),
)
}
Expand All @@ -156,7 +156,7 @@ impl FileProvider for LogarchiveProvider {
.filter_map(|entry| entry.ok())
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::TraceV3))
.filter_map(|entry| {
Some(Box::new(std::fs::File::open(&entry.path()).ok()?) as Box<dyn Read>)
Some(Box::new(std::fs::File::open(entry.path()).ok()?) as Box<dyn Read>)
}),
)
}
Expand All @@ -169,15 +169,15 @@ impl FileProvider for LogarchiveProvider {
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::UUIDText))
.map(|entry| {
(
std::fs::File::open(&entry.path()),
std::fs::File::open(entry.path()),
entry
.file_name()
.to_os_string()
.to_string_lossy()
.into_owned(),
)
})
.filter_map(|(handle, file_name)| Some((handle.ok(), file_name)))
.map(|(handle, file_name)| (handle.ok(), file_name))
.filter_map(|(handle, file_name)| Some((handle?, file_name)))
.map(|(handle, file_name)| (Box::new(handle) as Box<dyn Read>, file_name)),
)
Expand All @@ -191,15 +191,15 @@ impl FileProvider for LogarchiveProvider {
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::Dsc))
.map(|entry| {
(
std::fs::File::open(&entry.path()),
std::fs::File::open(entry.path()),
entry
.file_name()
.to_os_string()
.to_string_lossy()
.into_owned(),
)
})
.filter_map(|(handle, file_name)| Some((handle.ok(), file_name)))
.map(|(handle, file_name)| (handle.ok(), file_name))
.filter_map(|(handle, file_name)| Some((handle?, file_name)))
.map(|(handle, file_name)| (Box::new(handle) as Box<dyn Read>, file_name)),
)
Expand All @@ -212,7 +212,7 @@ impl FileProvider for LogarchiveProvider {
.filter_map(|entry| entry.ok())
.filter(|entry| matches!(LogFileType::from(entry.path()), LogFileType::Timesync))
.filter_map(|entry| {
Some(Box::new(std::fs::File::open(&entry.path()).ok()?) as Box<dyn Read>)
Some(Box::new(std::fs::File::open(entry.path()).ok()?) as Box<dyn Read>)
}),
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ mod tests {
test_format,
test_width,
test_precision,
&test_type,
test_type,
plus_minus,
hashtag,
);
Expand All @@ -1385,7 +1385,7 @@ mod tests {
test_format,
test_width,
test_precision,
&test_type,
test_type,
plus_minus,
hashtag,
);
Expand Down
Loading

0 comments on commit be73d05

Please sign in to comment.