Commit cfb444ca authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[Zucchini] Format change: PatchElementHeader: Group fields by "old" and "new".

Previously PatchElementHeader members were ordered by:
  [old_offset, new_offset, old_length, new_length].
This CL changes the order to
  [old_offset, old_length, new_offset, new_length]
to be consistent with PatchHeader's grouping by "old" and "new".

Also improve comments in patch_read_write_unittest.cc, and fix
input value in PatchElementTest.WrongExtraData.

Change-Id: I0dab56b7de1ba99f0a2f686dfebdf422a9d1c3b0
Reviewed-on: https://chromium-review.googlesource.com/1043073
Commit-Queue: Samuel Huang <huangs@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556076}
parent ad7ac05b
......@@ -209,8 +209,8 @@ PatchElement self contained.
Name | Format | Description
--- | --- | ---
old_offset | uint32 | Starting offset of the element in old file.
new_offset | uint32 | Starting offset of the element in new file.
old_length | uint32 | Length of the element in old file.
new_offset | uint32 | Starting offset of the element in new file.
new_length | uint32 | Length of the element in new file.
exe_type | uint32 | Executable type for this unit, see `enum ExecutableType`.
......
......@@ -38,8 +38,8 @@ bool ParseElementMatch(BufferSource* source, ElementMatch* element_match) {
// Caveat: Element offsets and lengths can still be invalid (e.g., exceeding
// archive bounds), but this will be checked later.
element_match->old_element.offset = element_header.old_offset;
element_match->new_element.offset = element_header.new_offset;
element_match->old_element.size = element_header.old_length;
element_match->new_element.offset = element_header.new_offset;
element_match->new_element.size = element_header.new_length;
element_match->old_element.exe_type = exe_type;
element_match->new_element.exe_type = exe_type;
......
......@@ -34,20 +34,20 @@ struct PatchHeader {
};
// Sanity check.
static_assert(sizeof(PatchHeader) == 20, "PatchHeader is 20 bytes");
static_assert(sizeof(PatchHeader) == 20, "PatchHeader must be 20 bytes");
// Header for a patch element, found at the beginning of every patch element.
struct PatchElementHeader {
uint32_t old_offset;
uint32_t new_offset;
uint32_t old_length;
uint32_t new_offset;
uint32_t new_length;
uint32_t exe_type;
uint32_t exe_type; // ExecutableType.
};
// Sanity check.
static_assert(sizeof(PatchElementHeader) == 20,
"PatchElementHeader is 28 bytes");
"PatchElementHeader must be 20 bytes");
#pragma pack(pop)
......
......@@ -23,10 +23,10 @@ bool SerializeElementMatch(const ElementMatch& element_match,
PatchElementHeader element_header;
element_header.old_offset =
base::checked_cast<uint32_t>(element_match.old_element.offset);
element_header.new_offset =
base::checked_cast<uint32_t>(element_match.new_element.offset);
element_header.old_length =
base::checked_cast<uint32_t>(element_match.old_element.size);
element_header.new_offset =
base::checked_cast<uint32_t>(element_match.new_element.offset);
element_header.new_length =
base::checked_cast<uint32_t>(element_match.new_element.size);
element_header.exe_type = element_match.exe_type();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment