From 5765c4c9f058c5b96bd98b8d7a0ec0170d0aa725 Mon Sep 17 00:00:00 2001 From: David McDonald <49174690+dgmcdona@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:26:32 -0600 Subject: [PATCH] clippy: Fixup default initializations (#42) --- src/chunks/firehose/firehose_log.rs | 8 +++++--- src/chunks/firehose/message.rs | 9 +++++---- src/dsc.rs | 12 +++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/chunks/firehose/firehose_log.rs b/src/chunks/firehose/firehose_log.rs index 7fcd768..a5c4ee1 100755 --- a/src/chunks/firehose/firehose_log.rs +++ b/src/chunks/firehose/firehose_log.rs @@ -615,9 +615,11 @@ impl FirehosePreamble { let (_, item_type) = le_u8(item_type)?; let (_, item_size) = le_u8(item_size)?; - let mut item = FirehoseItemType::default(); - item.item_type = item_type; - item.item_size = item_size; + let mut item = FirehoseItemType { + item_type, + item_size, + ..Default::default() + }; // Firehose string item values let string_item: Vec = vec![ diff --git a/src/chunks/firehose/message.rs b/src/chunks/firehose/message.rs index f42ad47..623ad2f 100644 --- a/src/chunks/firehose/message.rs +++ b/src/chunks/firehose/message.rs @@ -181,10 +181,11 @@ impl MessageData { let (_, main_uuid) = MessageData::get_catalog_dsc(catalogs, first_proc_id, second_proc_id); // log entries with main_exe flag do not use dsc cache uuid file - let mut message_data = MessageData::default(); - - message_data.library_uuid = main_uuid.to_owned(); - message_data.process_uuid = main_uuid; + let mut message_data = MessageData { + library_uuid: main_uuid.to_owned(), + process_uuid: main_uuid, + ..Default::default() + }; // If most significant bit is set, the string offset is "dynamic" (the formatter is "%s") if original_offset & 0x80000000 != 0 { diff --git a/src/dsc.rs b/src/dsc.rs index 9c237de..523bfe8 100755 --- a/src/dsc.rs +++ b/src/dsc.rs @@ -47,19 +47,21 @@ impl SharedCacheStrings { /// Parse shared strings data (the file(s) in /private/var/db/uuidtext/dsc) pub fn parse_dsc(data: &[u8]) -> nom::IResult<&[u8], SharedCacheStrings> { let (input, sig) = take(size_of::())(data)?; - let (_, dsc_sig) = le_u32(sig)?; + let (_, signature) = le_u32(sig)?; let expected_dsc_signature = 0x64736368; - if expected_dsc_signature != dsc_sig { + if expected_dsc_signature != signature { error!( "[macos-unifiedlogs] Incorrect DSC file signature. Expected {}. Got: {}", - expected_dsc_signature, dsc_sig + expected_dsc_signature, signature ); return Err(nom::Err::Incomplete(Needed::Unknown)); } - let mut shared_cache_strings = SharedCacheStrings::default(); - shared_cache_strings.signature = dsc_sig; + let mut shared_cache_strings = SharedCacheStrings { + signature, + ..Default::default() + }; let (input, major) = take(size_of::())(input)?; let (input, minor) = take(size_of::())(input)?;