Skip to content

Commit

Permalink
clippy: Fixup default initializations (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmcdona authored Dec 10, 2024
1 parent ba314c1 commit 5765c4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/chunks/firehose/firehose_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = vec![
Expand Down
9 changes: 5 additions & 4 deletions src/chunks/firehose/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions src/dsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>())(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::<u16>())(input)?;
let (input, minor) = take(size_of::<u16>())(input)?;
Expand Down

0 comments on commit 5765c4c

Please sign in to comment.