diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-17 03:22:38 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-17 03:22:38 +0000 |
commit | 1323b3ca9d6f9b0f2219a4754d79c459b288963c (patch) | |
tree | 65c58c77b3f59c9ed33373fff8cefe9ff9602067 | |
parent | b014a9cf171cca28c3efabb54b18127a01e9d821 (diff) | |
parent | 0ebc44d3684a1ea9b7e59149942d48e7480d3507 (diff) | |
download | bsdiff-1323b3ca9d6f9b0f2219a4754d79c459b288963c.tar.gz |
Snap for 8191477 from 0ebc44d3684a1ea9b7e59149942d48e7480d3507 to tm-frc-networking-release
Change-Id: Ie9e403e198c76c3818742d6e0df9d44520f33cb7
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | OWNERS | 2 | ||||
-rw-r--r-- | bspatch.cc | 2 | ||||
-rw-r--r-- | include/bsdiff/compressor_interface.h (renamed from compressor_interface.h) | 0 | ||||
-rw-r--r-- | include/bsdiff/control_entry.h | 15 | ||||
-rw-r--r-- | include/bsdiff/decompressor_interface.h (renamed from decompressor_interface.h) | 0 | ||||
-rw-r--r-- | include/bsdiff/file.h (renamed from file.h) | 0 | ||||
-rw-r--r-- | include/bsdiff/memory_file.h (renamed from memory_file.h) | 0 | ||||
-rw-r--r-- | include/bsdiff/patch_reader.h (renamed from patch_reader.h) | 0 | ||||
-rw-r--r-- | include/bsdiff/patch_writer.h (renamed from patch_writer.h) | 9 | ||||
-rw-r--r-- | patch_reader.cc | 2 | ||||
-rw-r--r-- | patch_writer.cc | 7 |
12 files changed, 22 insertions, 16 deletions
@@ -73,6 +73,7 @@ cc_library_static { cc_library_static { name: "libbsdiff", + recovery_available: true, defaults: ["bsdiff_defaults"], srcs: [ @@ -1,3 +1,5 @@ deymo@google.com senj@google.com xunchang@google.com +zhangkelvin@google.com + @@ -33,8 +33,8 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59: #include <errno.h> #include <fcntl.h> #include <inttypes.h> -#include <stdio.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> diff --git a/compressor_interface.h b/include/bsdiff/compressor_interface.h index c0ff18d..c0ff18d 100644 --- a/compressor_interface.h +++ b/include/bsdiff/compressor_interface.h diff --git a/include/bsdiff/control_entry.h b/include/bsdiff/control_entry.h index 2c849f6..3d2d96c 100644 --- a/include/bsdiff/control_entry.h +++ b/include/bsdiff/control_entry.h @@ -8,23 +8,24 @@ #include <stdint.h> struct ControlEntry { - ControlEntry(uint64_t diff_size, - uint64_t extra_size, - int64_t offset_increment) + constexpr ControlEntry(uint64_t diff_size, + uint64_t extra_size, + int64_t offset_increment) : diff_size(diff_size), extra_size(extra_size), offset_increment(offset_increment) {} + constexpr ControlEntry() = default; // The number of bytes to copy from the source and diff stream. - uint64_t diff_size; + uint64_t diff_size{0}; // The number of bytes to copy from the extra stream. - uint64_t extra_size; + uint64_t extra_size{0}; // The value to add to the source pointer after patching from the diff stream. - int64_t offset_increment; + int64_t offset_increment{0}; - bool operator==(const ControlEntry& o) const { + [[nodiscard]] bool operator==(const ControlEntry& o) const { return diff_size == o.diff_size && extra_size == o.extra_size && offset_increment == o.offset_increment; } diff --git a/decompressor_interface.h b/include/bsdiff/decompressor_interface.h index 46ee444..46ee444 100644 --- a/decompressor_interface.h +++ b/include/bsdiff/decompressor_interface.h diff --git a/file.h b/include/bsdiff/file.h index 959c53e..959c53e 100644 --- a/file.h +++ b/include/bsdiff/file.h diff --git a/memory_file.h b/include/bsdiff/memory_file.h index 4100fd6..4100fd6 100644 --- a/memory_file.h +++ b/include/bsdiff/memory_file.h diff --git a/patch_reader.h b/include/bsdiff/patch_reader.h index fe0451b..fe0451b 100644 --- a/patch_reader.h +++ b/include/bsdiff/patch_reader.h diff --git a/patch_writer.h b/include/bsdiff/patch_writer.h index 8ad4cde..6d2bcf5 100644 --- a/patch_writer.h +++ b/include/bsdiff/patch_writer.h @@ -14,6 +14,15 @@ namespace bsdiff { + +constexpr void EncodeInt64(int64_t x, uint8_t* buf) { + uint64_t y = x < 0 ? (1ULL << 63ULL) - x : x; + for (int i = 0; i < 8; ++i) { + buf[i] = y & 0xff; + y /= 256; + } +} + // A PatchWriterInterface class with three compressors and a 32-byte header. class BsdiffPatchWriter : public PatchWriterInterface { public: diff --git a/patch_reader.cc b/patch_reader.cc index e863b9a..6d317f3 100644 --- a/patch_reader.cc +++ b/patch_reader.cc @@ -32,7 +32,7 @@ bool BsdiffPatchReader::Init(const uint8_t* patch_data, size_t patch_size) { // extra block; seek forwards in oldfile by z bytes". if (patch_size < 32) { - LOG(ERROR) << "Too small to be a bspatch."; + LOG(ERROR) << "Too small to be a bspatch. " << patch_size; return false; } // Check for appropriate magic. diff --git a/patch_writer.cc b/patch_writer.cc index 52982e0..b7d9b08 100644 --- a/patch_writer.cc +++ b/patch_writer.cc @@ -15,13 +15,6 @@ namespace { -void EncodeInt64(int64_t x, uint8_t* buf) { - uint64_t y = x < 0 ? (1ULL << 63ULL) - x : x; - for (int i = 0; i < 8; ++i) { - buf[i] = y & 0xff; - y /= 256; - } -} } // namespace |