summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 06:54:10 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 06:54:10 +0000
commit71b1ea0d8bcb9f8e886fcbfff4323ebe18210fea (patch)
tree4f60cc104be3c4d98888fedc7529c8ca449fe405
parent99501508faa89407ed1ec72015fd2812cec0d2e4 (diff)
parent7e486cb657c3ae0f79f77d3d0d93cb7c027919e3 (diff)
downloadbsdiff-android13-mainline-adbd-release.tar.gz
Snap for 8564071 from 7e486cb657c3ae0f79f77d3d0d93cb7c027919e3 to mainline-adbd-releaseaml_adb_331610000aml_adb_331314020aml_adb_331113120aml_adb_331011050aml_adb_331011040android13-mainline-adbd-release
Change-Id: I8723dd22c125ad3f38a53cb6f7167da88062e2c0
-rw-r--r--Android.bp1
-rw-r--r--OWNERS2
-rw-r--r--TEST_MAPPING5
-rw-r--r--bspatch.cc2
-rw-r--r--include/bsdiff/compressor_interface.h (renamed from compressor_interface.h)0
-rw-r--r--include/bsdiff/control_entry.h15
-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.cc2
-rw-r--r--patch_writer.cc7
-rw-r--r--suffix_array_index.cc1
14 files changed, 28 insertions, 16 deletions
diff --git a/Android.bp b/Android.bp
index ee6dc4f..3541d03 100644
--- a/Android.bp
+++ b/Android.bp
@@ -73,6 +73,7 @@ cc_library_static {
cc_library_static {
name: "libbsdiff",
+ recovery_available: true,
defaults: ["bsdiff_defaults"],
srcs: [
diff --git a/OWNERS b/OWNERS
index ab036c1..b730db9 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,5 @@
deymo@google.com
senj@google.com
xunchang@google.com
+zhangkelvin@google.com
+
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 598f4c9..570788d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -3,5 +3,10 @@
{
"name": "bsdiff_unittest"
}
+ ],
+ "hwasan-postsubmit": [
+ {
+ "name": "bsdiff_unittest"
+ }
]
}
diff --git a/bspatch.cc b/bspatch.cc
index d7f1710..e95b9a2 100644
--- a/bspatch.cc
+++ b/bspatch.cc
@@ -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
diff --git a/suffix_array_index.cc b/suffix_array_index.cc
index b02655c..710249c 100644
--- a/suffix_array_index.cc
+++ b/suffix_array_index.cc
@@ -4,6 +4,7 @@
#include "bsdiff/suffix_array_index.h"
+#include <algorithm>
#include <limits>
#include <vector>