Merge "first_stage_console: Address compiler warning" into main
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 2d55e5a..d402bf1 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -830,7 +830,7 @@
return subReason;
}
-bool addKernelPanicSubReason(const pstoreConsole& console, std::string& ret) {
+void addKernelPanicSubReason(const pstoreConsole& console, std::string& ret) {
// Check for kernel panic types to refine information
if ((console.rfind("SysRq : Trigger a crash") != std::string::npos) ||
(console.rfind("PC is at sysrq_handle_crash+") != std::string::npos)) {
@@ -842,63 +842,61 @@
if (pos != std::string::npos) {
ret += "," + getSubreason(console, pos + strlen(sysrqSubreason), /* quoted */ true);
}
- return true;
+ return;
}
if (console.rfind("Unable to handle kernel NULL pointer dereference at virtual address") !=
std::string::npos) {
ret = "kernel_panic,null";
- return true;
+ return;
}
if (console.rfind("Kernel BUG at ") != std::string::npos) {
ret = "kernel_panic,bug";
- return true;
+ return;
}
std::string panic("Kernel panic - not syncing: ");
auto pos = console.rfind(panic);
- if (pos != std::string::npos) {
- static const std::vector<std::pair<const std::string, const std::string>> panicReasons = {
- {"Out of memory", "oom"},
- {"out of memory", "oom"},
- {"Oh boy, that early out of memory", "oom"}, // omg
- {"BUG!", "bug"},
- {"hung_task: blocked tasks", "hung"},
- {"audit: ", "audit"},
- {"scheduling while atomic", "atomic"},
- {"Attempted to kill init!", "init"},
- {"Requested init", "init"},
- {"No working init", "init"},
- {"Could not decompress init", "init"},
- {"RCU Stall", "hung,rcu"},
- {"stack-protector", "stack"},
- {"kernel stack overflow", "stack"},
- {"Corrupt kernel stack", "stack"},
- {"low stack detected", "stack"},
- {"corrupted stack end", "stack"},
- {"subsys-restart: Resetting the SoC - modem crashed.", "modem"},
- {"subsys-restart: Resetting the SoC - adsp crashed.", "adsp"},
- {"subsys-restart: Resetting the SoC - dsps crashed.", "dsps"},
- {"subsys-restart: Resetting the SoC - wcnss crashed.", "wcnss"},
- };
+ if (pos == std::string::npos) return;
- ret = "kernel_panic";
- for (auto& s : panicReasons) {
- if (console.find(panic + s.first, pos) != std::string::npos) {
- ret += "," + s.second;
- return true;
- }
+ static const std::vector<std::pair<const std::string, const std::string>> panicReasons = {
+ {"Out of memory", "oom"},
+ {"out of memory", "oom"},
+ {"Oh boy, that early out of memory", "oom"}, // omg
+ {"BUG!", "bug"},
+ {"hung_task: blocked tasks", "hung"},
+ {"audit: ", "audit"},
+ {"scheduling while atomic", "atomic"},
+ {"Attempted to kill init!", "init"},
+ {"Requested init", "init"},
+ {"No working init", "init"},
+ {"Could not decompress init", "init"},
+ {"RCU Stall", "hung,rcu"},
+ {"stack-protector", "stack"},
+ {"kernel stack overflow", "stack"},
+ {"Corrupt kernel stack", "stack"},
+ {"low stack detected", "stack"},
+ {"corrupted stack end", "stack"},
+ {"subsys-restart: Resetting the SoC - modem crashed.", "modem"},
+ {"subsys-restart: Resetting the SoC - adsp crashed.", "adsp"},
+ {"subsys-restart: Resetting the SoC - dsps crashed.", "dsps"},
+ {"subsys-restart: Resetting the SoC - wcnss crashed.", "wcnss"},
+ };
+
+ ret = "kernel_panic";
+ for (auto& s : panicReasons) {
+ if (console.find(panic + s.first, pos) != std::string::npos) {
+ ret += "," + s.second;
+ return;
}
- auto reason = getSubreason(console, pos + panic.length(), /* newline */ false);
- if (reason.length() > 3) {
- ret += "," + reason;
- }
- return true;
}
- return false;
+ auto reason = getSubreason(console, pos + panic.length(), /* newline */ false);
+ if (reason.length() > 3) {
+ ret += "," + reason;
+ }
}
-bool addKernelPanicSubReason(const std::string& content, std::string& ret) {
- return addKernelPanicSubReason(pstoreConsole(content), ret);
+void addKernelPanicSubReason(const std::string& content, std::string& ret) {
+ addKernelPanicSubReason(pstoreConsole(content), ret);
}
const char system_reboot_reason_property[] = "sys.boot.reason";
@@ -1079,12 +1077,7 @@
}
// Check for kernel panics, allowed to override reboot command.
- if (!addKernelPanicSubReason(console, ret) &&
- // check for long-press power down
- ((console.rfind("Power held for ") != std::string::npos) ||
- (console.rfind("charger: [") != std::string::npos))) {
- ret = "cold";
- }
+ (void)addKernelPanicSubReason(console, ret);
}
// TODO: use the HAL to get battery level (http://b/77725702).
diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp
index bd1e91d..af1bb81 100644
--- a/debuggerd/client/debuggerd_client.cpp
+++ b/debuggerd/client/debuggerd_client.cpp
@@ -116,7 +116,6 @@
bool debuggerd_trigger_dump(pid_t tid, DebuggerdDumpType dump_type, unsigned int timeout_ms,
unique_fd output_fd) {
- pid_t pid = tid;
if (dump_type == kDebuggerdJavaBacktrace) {
// Java dumps always get sent to the tgid, so we need to resolve our tid to a tgid.
android::procinfo::ProcessInfo procinfo;
@@ -125,10 +124,10 @@
log_error(output_fd, 0, "failed to get process info: %s", error.c_str());
return false;
}
- pid = procinfo.pid;
+ tid = procinfo.pid;
}
- LOG(INFO) << TAG "started dumping process " << pid;
+ LOG(INFO) << TAG "started dumping process " << tid;
// Rather than try to deal with poll() all the way through the flow, we update
// the socket timeout between each step (and only use poll() during the final
@@ -172,7 +171,7 @@
InterceptRequest req = {
.dump_type = dump_type,
- .pid = pid,
+ .pid = tid,
};
// Create an intermediate pipe to pass to the other end.
@@ -235,8 +234,8 @@
// Send the signal.
const int signal = (dump_type == kDebuggerdJavaBacktrace) ? SIGQUIT : BIONIC_SIGNAL_DEBUGGER;
sigval val = {.sival_int = (dump_type == kDebuggerdNativeBacktrace) ? 1 : 0};
- if (sigqueue(pid, signal, val) != 0) {
- log_error(output_fd, errno, "failed to send signal to pid %d", pid);
+ if (sigqueue(tid, signal, val) != 0) {
+ log_error(output_fd, errno, "failed to send signal to pid %d", tid);
return false;
}
@@ -299,7 +298,7 @@
}
}
- LOG(INFO) << TAG "done dumping process " << pid;
+ LOG(INFO) << TAG "done dumping process " << tid;
return true;
}
diff --git a/debuggerd/include/debuggerd/client.h b/debuggerd/include/debuggerd/client.h
index b7284b0..e7401cc 100644
--- a/debuggerd/include/debuggerd/client.h
+++ b/debuggerd/include/debuggerd/client.h
@@ -26,7 +26,7 @@
// Trigger a dump of specified process to output_fd.
// output_fd is consumed, timeout of 0 will wait forever.
-bool debuggerd_trigger_dump(pid_t pid, enum DebuggerdDumpType dump_type, unsigned int timeout_ms,
+bool debuggerd_trigger_dump(pid_t tid, enum DebuggerdDumpType dump_type, unsigned int timeout_ms,
android::base::unique_fd output_fd);
int dump_backtrace_to_file(pid_t tid, enum DebuggerdDumpType dump_type, int output_fd);
diff --git a/fastboot/usb_linux.cpp b/fastboot/usb_linux.cpp
index 37bb304..72e326a 100644
--- a/fastboot/usb_linux.cpp
+++ b/fastboot/usb_linux.cpp
@@ -269,6 +269,9 @@
auto path = android::base::StringPrintf("/sys/bus/usb/devices/%s/%s:1.%d/interface",
sysfs_name, sysfs_name, ifc->bInterfaceNumber);
if (android::base::ReadFileToString(path, &interface)) {
+ if (!interface.empty() && interface.back() == '\n') {
+ interface.pop_back();
+ }
snprintf(info.interface, sizeof(info.interface), "%s", interface.c_str());
}
@@ -404,34 +407,84 @@
{
unsigned char *data = (unsigned char*) _data;
unsigned count = 0;
- struct usbdevfs_bulktransfer bulk;
- int n;
+ struct usbdevfs_urb urb[2] = {};
+ bool pending[2] = {};
if (handle_->ep_out == 0 || handle_->desc == -1) {
return -1;
}
- do {
- int xfer;
- xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
+ auto submit_urb = [&](size_t i) {
+ int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
- bulk.ep = handle_->ep_out;
- bulk.len = xfer;
- bulk.data = data;
- bulk.timeout = ms_timeout_;
+ urb[i].type = USBDEVFS_URB_TYPE_BULK;
+ urb[i].endpoint = handle_->ep_out;
+ urb[i].buffer_length = xfer;
+ urb[i].buffer = data;
+ urb[i].usercontext = (void *)i;
- n = ioctl(handle_->desc, USBDEVFS_BULK, &bulk);
- if(n != xfer) {
- DBG("ERROR: n = %d, errno = %d (%s)\n",
- n, errno, strerror(errno));
- return -1;
+ int n = ioctl(handle_->desc, USBDEVFS_SUBMITURB, &urb[i]);
+ if (n != 0) {
+ DBG("ioctl(USBDEVFS_SUBMITURB) failed\n");
+ return false;
}
+ pending[i] = true;
count += xfer;
len -= xfer;
data += xfer;
- } while(len > 0);
+ return true;
+ };
+
+ auto reap_urb = [&](size_t i) {
+ while (pending[i]) {
+ struct usbdevfs_urb *urbp;
+ int res = ioctl(handle_->desc, USBDEVFS_REAPURB, &urbp);
+ if (res != 0) {
+ DBG("ioctl(USBDEVFS_REAPURB) failed\n");
+ return false;
+ }
+ size_t done = (size_t)urbp->usercontext;
+ if (done >= 2 || !pending[done]) {
+ DBG("unexpected urb\n");
+ return false;
+ }
+ if (urbp->status != 0 || urbp->actual_length != urbp->buffer_length) {
+ DBG("urb returned error\n");
+ return false;
+ }
+ pending[done] = false;
+ }
+ return true;
+ };
+
+ if (!submit_urb(0)) {
+ return -1;
+ }
+ while (len > 0) {
+ if (!submit_urb(1)) {
+ return -1;
+ }
+ if (!reap_urb(0)) {
+ return -1;
+ }
+ if (len <= 0) {
+ if (!reap_urb(1)) {
+ return -1;
+ }
+ return count;
+ }
+ if (!submit_urb(0)) {
+ return -1;
+ }
+ if (!reap_urb(1)) {
+ return -1;
+ }
+ }
+ if (!reap_urb(0)) {
+ return -1;
+ }
return count;
}
diff --git a/fastboot/util.cpp b/fastboot/util.cpp
index e03012a..5966aea 100644
--- a/fastboot/util.cpp
+++ b/fastboot/util.cpp
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include <sys/time.h>
+#include <time.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
@@ -43,9 +43,9 @@
static bool g_verbose = false;
double now() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000;
}
void die(const char* fmt, ...) {
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_compress.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_compress.h
index 8191d61..ac04245 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_compress.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_compress.h
@@ -17,6 +17,7 @@
#pragma once
#include <memory>
+#include <vector>
#include "libsnapshot/cow_format.h"
namespace android {
@@ -40,8 +41,7 @@
uint32_t GetCompressionLevel() const { return compression_level_; }
uint32_t GetBlockSize() const { return block_size_; }
- [[nodiscard]] virtual std::basic_string<uint8_t> Compress(const void* data,
- size_t length) const = 0;
+ [[nodiscard]] virtual std::vector<uint8_t> Compress(const void* data, size_t length) const = 0;
private:
uint32_t compression_level_;
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h
index 89699dc..651083f 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_writer.h
@@ -122,13 +122,13 @@
CompressWorker(std::unique_ptr<ICompressor>&& compressor);
bool RunThread();
void EnqueueCompressBlocks(const void* buffer, size_t block_size, size_t num_blocks);
- bool GetCompressedBuffers(std::vector<std::basic_string<uint8_t>>* compressed_buf);
+ bool GetCompressedBuffers(std::vector<std::vector<uint8_t>>* compressed_buf);
void Finalize();
static uint32_t GetDefaultCompressionLevel(CowCompressionAlgorithm compression);
static bool CompressBlocks(ICompressor* compressor, size_t block_size, const void* buffer,
size_t num_blocks,
- std::vector<std::basic_string<uint8_t>>* compressed_data);
+ std::vector<std::vector<uint8_t>>* compressed_data);
private:
struct CompressWork {
@@ -136,7 +136,7 @@
size_t num_blocks;
size_t block_size;
bool compression_status = false;
- std::vector<std::basic_string<uint8_t>> compressed_data;
+ std::vector<std::vector<uint8_t>> compressed_data;
};
std::unique_ptr<ICompressor> compressor_;
@@ -150,7 +150,7 @@
size_t total_processed_ = 0;
bool CompressBlocks(const void* buffer, size_t num_blocks, size_t block_size,
- std::vector<std::basic_string<uint8_t>>* compressed_data);
+ std::vector<std::vector<uint8_t>>* compressed_data);
};
// Create an ICowWriter not backed by any file. This is useful for estimating
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp
index 577cdbd..0205f50 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/cow_compress.cpp
@@ -20,6 +20,7 @@
#include <limits>
#include <memory>
#include <queue>
+#include <vector>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -103,9 +104,9 @@
GzCompressor(uint32_t compression_level, const uint32_t block_size)
: ICompressor(compression_level, block_size){};
- std::basic_string<uint8_t> Compress(const void* data, size_t length) const override {
+ std::vector<uint8_t> Compress(const void* data, size_t length) const override {
const auto bound = compressBound(length);
- std::basic_string<uint8_t> buffer(bound, '\0');
+ std::vector<uint8_t> buffer(bound, '\0');
uLongf dest_len = bound;
auto rv = compress2(buffer.data(), &dest_len, reinterpret_cast<const Bytef*>(data), length,
@@ -124,13 +125,13 @@
Lz4Compressor(uint32_t compression_level, const uint32_t block_size)
: ICompressor(compression_level, block_size){};
- std::basic_string<uint8_t> Compress(const void* data, size_t length) const override {
+ std::vector<uint8_t> Compress(const void* data, size_t length) const override {
const auto bound = LZ4_compressBound(length);
if (!bound) {
LOG(ERROR) << "LZ4_compressBound returned 0";
return {};
}
- std::basic_string<uint8_t> buffer(bound, '\0');
+ std::vector<uint8_t> buffer(bound, '\0');
const auto compressed_size =
LZ4_compress_default(static_cast<const char*>(data),
@@ -156,13 +157,13 @@
BrotliCompressor(uint32_t compression_level, const uint32_t block_size)
: ICompressor(compression_level, block_size){};
- std::basic_string<uint8_t> Compress(const void* data, size_t length) const override {
+ std::vector<uint8_t> Compress(const void* data, size_t length) const override {
const auto bound = BrotliEncoderMaxCompressedSize(length);
if (!bound) {
LOG(ERROR) << "BrotliEncoderMaxCompressedSize returned 0";
return {};
}
- std::basic_string<uint8_t> buffer(bound, '\0');
+ std::vector<uint8_t> buffer(bound, '\0');
size_t encoded_size = bound;
auto rv = BrotliEncoderCompress(
@@ -186,8 +187,8 @@
ZSTD_CCtx_setParameter(zstd_context_.get(), ZSTD_c_windowLog, log2(GetBlockSize()));
};
- std::basic_string<uint8_t> Compress(const void* data, size_t length) const override {
- std::basic_string<uint8_t> buffer(ZSTD_compressBound(length), '\0');
+ std::vector<uint8_t> Compress(const void* data, size_t length) const override {
+ std::vector<uint8_t> buffer(ZSTD_compressBound(length), '\0');
const auto compressed_size =
ZSTD_compress2(zstd_context_.get(), buffer.data(), buffer.size(), data, length);
if (compressed_size <= 0) {
@@ -209,13 +210,13 @@
};
bool CompressWorker::CompressBlocks(const void* buffer, size_t num_blocks, size_t block_size,
- std::vector<std::basic_string<uint8_t>>* compressed_data) {
+ std::vector<std::vector<uint8_t>>* compressed_data) {
return CompressBlocks(compressor_.get(), block_size, buffer, num_blocks, compressed_data);
}
bool CompressWorker::CompressBlocks(ICompressor* compressor, size_t block_size, const void* buffer,
size_t num_blocks,
- std::vector<std::basic_string<uint8_t>>* compressed_data) {
+ std::vector<std::vector<uint8_t>>* compressed_data) {
const uint8_t* iter = reinterpret_cast<const uint8_t*>(buffer);
while (num_blocks) {
auto data = compressor->Compress(iter, block_size);
@@ -289,7 +290,7 @@
cv_.notify_all();
}
-bool CompressWorker::GetCompressedBuffers(std::vector<std::basic_string<uint8_t>>* compressed_buf) {
+bool CompressWorker::GetCompressedBuffers(std::vector<std::vector<uint8_t>>* compressed_buf) {
while (true) {
std::unique_lock<std::mutex> lock(lock_);
while ((total_submitted_ != total_processed_) && compressed_queue_.empty() && !stopped_) {
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp
index 1d1d24c..ce80cd7 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/test_v2.cpp
@@ -18,6 +18,7 @@
#include <iostream>
#include <memory>
#include <string_view>
+#include <vector>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -429,7 +430,7 @@
template <typename T>
class HorribleStream : public IByteStream {
public:
- HorribleStream(const std::basic_string<T>& input) : input_(input) {}
+ HorribleStream(const std::vector<T>& input) : input_(input) {}
ssize_t Read(void* buffer, size_t length) override {
if (pos_ >= input_.size()) {
@@ -444,16 +445,17 @@
size_t Size() const override { return input_.size(); }
private:
- std::basic_string<T> input_;
+ std::vector<T> input_;
size_t pos_ = 0;
};
TEST(HorribleStream, ReadFully) {
- std::string expected = "this is some data";
+ std::string expected_str = "this is some data";
+ std::vector<char> expected{expected_str.begin(), expected_str.end()};
HorribleStream<char> stream(expected);
- std::string buffer(expected.size(), '\0');
+ std::vector<char> buffer(expected.size(), '\0');
ASSERT_TRUE(stream.ReadFully(buffer.data(), buffer.size()));
ASSERT_EQ(buffer, expected);
}
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.h b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.h
index 05de2ad..6a37aa7 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.h
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v2.h
@@ -81,8 +81,8 @@
int num_compress_threads_ = 1;
std::vector<std::unique_ptr<CompressWorker>> compress_threads_;
std::vector<std::future<bool>> threads_;
- std::vector<std::basic_string<uint8_t>> compressed_buf_;
- std::vector<std::basic_string<uint8_t>>::iterator buf_iter_;
+ std::vector<std::vector<uint8_t>> compressed_buf_;
+ std::vector<std::vector<uint8_t>>::iterator buf_iter_;
std::vector<std::unique_ptr<CowOperationV2>> opbuffer_vec_;
std::vector<std::unique_ptr<uint8_t[]>> databuffer_vec_;
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
index c92460a..22e6f2c 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.cpp
@@ -512,8 +512,7 @@
}
bytes_written += op.data_length;
}
- if (!WriteOperation({cached_ops_.data(), cached_ops_.size()},
- {data_vec_.data(), data_vec_.size()})) {
+ if (!WriteOperation(cached_ops_, data_vec_)) {
LOG(ERROR) << "Failed to flush " << cached_ops_.size() << " ops to disk";
return false;
}
@@ -632,7 +631,7 @@
}
// Fetch compressed buffers from the threads
- std::vector<std::basic_string<uint8_t>> compressed_buf;
+ std::vector<std::vector<uint8_t>> compressed_buf;
compressed_buf.clear();
for (size_t i = 0; i < num_threads; i++) {
CompressWorker* worker = compress_threads_[i].get();
@@ -684,8 +683,8 @@
return ProcessBlocksWithThreadedCompression(num_blocks, data, type);
}
-bool CowWriterV3::WriteOperation(std::basic_string_view<CowOperationV3> ops,
- std::basic_string_view<struct iovec> data) {
+bool CowWriterV3::WriteOperation(std::span<const CowOperationV3> ops,
+ std::span<const struct iovec> data) {
const auto total_data_size =
std::transform_reduce(data.begin(), data.end(), 0, std::plus<size_t>{},
[](const struct iovec& a) { return a.iov_len; });
diff --git a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.h b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.h
index 4915e9c..48eb67b 100644
--- a/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.h
+++ b/fs_mgr/libsnapshot/libsnapshot_cow/writer_v3.h
@@ -15,6 +15,7 @@
#pragma once
#include <android-base/logging.h>
+#include <span>
#include <string_view>
#include <thread>
#include <vector>
@@ -49,15 +50,14 @@
private:
struct CompressedBuffer {
size_t compression_factor;
- std::basic_string<uint8_t> compressed_data;
+ std::vector<uint8_t> compressed_data;
};
void SetupHeaders();
bool NeedsFlush() const;
bool ParseOptions();
bool OpenForWrite();
bool OpenForAppend(uint64_t label);
- bool WriteOperation(std::basic_string_view<CowOperationV3> op,
- std::basic_string_view<struct iovec> data);
+ bool WriteOperation(std::span<const CowOperationV3> op, std::span<const struct iovec> data);
bool EmitBlocks(uint64_t new_block_start, const void* data, size_t size, uint64_t old_block,
uint16_t offset, CowOperationType type);
bool ConstructCowOpCompressedBuffers(uint64_t new_block_start, const void* data,
@@ -111,7 +111,7 @@
int num_compress_threads_ = 1;
size_t batch_size_ = 1;
std::vector<CowOperationV3> cached_ops_;
- std::vector<std::basic_string<uint8_t>> cached_data_;
+ std::vector<std::vector<uint8_t>> cached_data_;
std::vector<struct iovec> data_vec_;
std::vector<std::thread> threads_;
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.h
index 43e896a..04b2736 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.h
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/read_worker.h
@@ -69,7 +69,7 @@
std::shared_ptr<IBlockServerOpener> block_server_opener_;
std::unique_ptr<IBlockServer> block_server_;
- std::basic_string<uint8_t> xor_buffer_;
+ std::vector<uint8_t> xor_buffer_;
std::unique_ptr<void, decltype(&::free)> aligned_buffer_;
std::unique_ptr<uint8_t[]> decompressed_buffer_;
};
diff --git a/fs_mgr/libsnapshot/tools/cow_benchmark.cpp b/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
index 4d5e346..fb463c8 100644
--- a/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
+++ b/fs_mgr/libsnapshot/tools/cow_benchmark.cpp
@@ -78,7 +78,7 @@
for (size_t i = 0; i < compressors.size(); i++) {
const auto start = std::chrono::steady_clock::now();
- std::basic_string<uint8_t> compressed_data =
+ std::vector<uint8_t> compressed_data =
compressors[i]->Compress(buffer.data(), buffer.size());
const auto end = std::chrono::steady_clock::now();
const auto latency =
@@ -141,13 +141,13 @@
std::vector<std::pair<double, std::string>> ratios;
for (size_t i = 0; i < compressors.size(); i++) {
- std::vector<std::basic_string<uint8_t>> compressed_data_vec;
+ std::vector<std::vector<uint8_t>> compressed_data_vec;
int num_blocks = buffer.size() / BLOCK_SZ;
const uint8_t* iter = reinterpret_cast<const uint8_t*>(buffer.data());
const auto start = std::chrono::steady_clock::now();
while (num_blocks > 0) {
- std::basic_string<uint8_t> compressed_data = compressors[i]->Compress(iter, BLOCK_SZ);
+ std::vector<uint8_t> compressed_data = compressors[i]->Compress(iter, BLOCK_SZ);
compressed_data_vec.emplace_back(compressed_data);
num_blocks--;
iter += BLOCK_SZ;
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index b8bb586..fbdf5fe 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -530,7 +530,7 @@
props.chargerAcOnline ? "a" : "", props.chargerUsbOnline ? "u" : "",
props.chargerWirelessOnline ? "w" : "", props.chargerDockOnline ? "d" : "");
- KLOG_WARNING(LOG_TAG, "%s\n", dmesgline);
+ KLOG_DEBUG(LOG_TAG, "%s\n", dmesgline);
}
void BatteryMonitor::logValues(const HealthInfo_2_1& health_info,
diff --git a/libcutils/ashmem_test.cpp b/libcutils/ashmem_test.cpp
index d158427..571b410 100644
--- a/libcutils/ashmem_test.cpp
+++ b/libcutils/ashmem_test.cpp
@@ -22,6 +22,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include <vector>
+
#include <android-base/macros.h>
#include <android-base/unique_fd.h>
#include <cutils/ashmem.h>
@@ -61,16 +63,16 @@
EXPECT_EQ(prot, ioctl(fd, ASHMEM_GET_PROT_MASK));
}
-void FillData(uint8_t* data, size_t dataLen) {
- for (size_t i = 0; i < dataLen; i++) {
+void FillData(std::vector<uint8_t>& data) {
+ for (size_t i = 0; i < data.size(); i++) {
data[i] = i & 0xFF;
}
}
TEST(AshmemTest, BasicTest) {
- constexpr size_t size = PAGE_SIZE;
- uint8_t data[size];
- FillData(data, size);
+ const size_t size = getpagesize();
+ std::vector<uint8_t> data(size);
+ FillData(data);
unique_fd fd;
ASSERT_NO_FATAL_FAILURE(TestCreateRegion(size, fd, PROT_READ | PROT_WRITE));
@@ -78,21 +80,21 @@
void* region1 = nullptr;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd, size, PROT_READ | PROT_WRITE, ®ion1));
- memcpy(region1, &data, size);
- ASSERT_EQ(0, memcmp(region1, &data, size));
+ memcpy(region1, data.data(), size);
+ ASSERT_EQ(0, memcmp(region1, data.data(), size));
EXPECT_EQ(0, munmap(region1, size));
void *region2;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd, size, PROT_READ, ®ion2));
- ASSERT_EQ(0, memcmp(region2, &data, size));
+ ASSERT_EQ(0, memcmp(region2, data.data(), size));
EXPECT_EQ(0, munmap(region2, size));
}
TEST(AshmemTest, ForkTest) {
- constexpr size_t size = PAGE_SIZE;
- uint8_t data[size];
- FillData(data, size);
+ const size_t size = getpagesize();
+ std::vector<uint8_t> data(size);
+ FillData(data);
unique_fd fd;
ASSERT_NO_FATAL_FAILURE(TestCreateRegion(size, fd, PROT_READ | PROT_WRITE));
@@ -100,8 +102,8 @@
void* region1 = nullptr;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd, size, PROT_READ | PROT_WRITE, ®ion1));
- memcpy(region1, &data, size);
- ASSERT_EQ(0, memcmp(region1, &data, size));
+ memcpy(region1, data.data(), size);
+ ASSERT_EQ(0, memcmp(region1, data.data(), size));
EXPECT_EQ(0, munmap(region1, size));
ASSERT_EXIT(
@@ -113,7 +115,7 @@
if (region2 == MAP_FAILED) {
_exit(1);
}
- if (memcmp(region2, &data, size) != 0) {
+ if (memcmp(region2, data.data(), size) != 0) {
_exit(2);
}
memset(region2, 0, size);
@@ -122,10 +124,10 @@
},
::testing::ExitedWithCode(0), "");
- memset(&data, 0, size);
+ memset(data.data(), 0, size);
void *region2;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd, size, PROT_READ | PROT_WRITE, ®ion2));
- ASSERT_EQ(0, memcmp(region2, &data, size));
+ ASSERT_EQ(0, memcmp(region2, data.data(), size));
EXPECT_EQ(0, munmap(region2, size));
}
@@ -134,18 +136,19 @@
void* region = nullptr;
// Allocate a 4-page buffer, but leave page-sized holes on either side
- constexpr size_t size = PAGE_SIZE * 4;
- constexpr size_t dataSize = PAGE_SIZE * 2;
- constexpr size_t holeSize = PAGE_SIZE;
+ const size_t pageSize = getpagesize();
+ const size_t size = pageSize * 4;
+ const size_t dataSize = pageSize * 2;
+ const size_t holeSize = pageSize;
ASSERT_NO_FATAL_FAILURE(TestCreateRegion(size, fd, PROT_READ | PROT_WRITE));
ASSERT_NO_FATAL_FAILURE(TestMmap(fd, dataSize, PROT_READ | PROT_WRITE, ®ion, holeSize));
- uint8_t data[dataSize];
- FillData(data, dataSize);
- memcpy(region, data, dataSize);
+ std::vector<uint8_t> data(dataSize);
+ FillData(data);
+ memcpy(region, data.data(), dataSize);
- constexpr off_t dataStart = holeSize;
- constexpr off_t dataEnd = dataStart + dataSize;
+ const off_t dataStart = holeSize;
+ const off_t dataEnd = dataStart + dataSize;
// The sequence of seeks below looks something like this:
//
@@ -163,9 +166,12 @@
// Expected lseek() return value
off_t ret;
} seeks[] = {
- {99, SEEK_SET, 99}, {dataStart, SEEK_CUR, dataStart + 99},
- {0, SEEK_DATA, dataStart}, {dataStart, SEEK_HOLE, dataEnd},
- {-99, SEEK_END, size - 99}, {-dataStart, SEEK_CUR, dataEnd - 99},
+ {99, SEEK_SET, 99},
+ {dataStart, SEEK_CUR, dataStart + 99},
+ {0, SEEK_DATA, dataStart},
+ {dataStart, SEEK_HOLE, dataEnd},
+ {-99, SEEK_END, static_cast<off_t>(size) - 99},
+ {-dataStart, SEEK_CUR, dataEnd - 99},
};
for (const auto& cfg : seeks) {
errno = 0;
@@ -180,7 +186,7 @@
uint8_t buf[readSize];
ASSERT_EQ(readSize, TEMP_FAILURE_RETRY(read(fd, buf, readSize)));
- EXPECT_EQ(0, memcmp(buf, data + dataOff, readSize));
+ EXPECT_EQ(0, memcmp(buf, &data[dataOff], readSize));
}
}
@@ -189,7 +195,7 @@
TEST(AshmemTest, ProtTest) {
unique_fd fd;
- constexpr size_t size = PAGE_SIZE;
+ const size_t size = getpagesize();
void *region;
ASSERT_NO_FATAL_FAILURE(TestCreateRegion(size, fd, PROT_READ));
@@ -217,7 +223,7 @@
TEST(AshmemTest, ForkProtTest) {
unique_fd fd;
- constexpr size_t size = PAGE_SIZE;
+ const size_t size = getpagesize();
int protFlags[] = { PROT_READ, PROT_WRITE };
for (size_t i = 0; i < arraysize(protFlags); i++) {
@@ -238,9 +244,9 @@
}
TEST(AshmemTest, ForkMultiRegionTest) {
- constexpr size_t size = PAGE_SIZE;
- uint8_t data[size];
- FillData(data, size);
+ const size_t size = getpagesize();
+ std::vector<uint8_t> data(size);
+ FillData(data);
constexpr int nRegions = 16;
unique_fd fd[nRegions];
@@ -248,8 +254,8 @@
ASSERT_NO_FATAL_FAILURE(TestCreateRegion(size, fd[i], PROT_READ | PROT_WRITE));
void* region = nullptr;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd[i], size, PROT_READ | PROT_WRITE, ®ion));
- memcpy(region, &data, size);
- ASSERT_EQ(0, memcmp(region, &data, size));
+ memcpy(region, data.data(), size);
+ ASSERT_EQ(0, memcmp(region, data.data(), size));
EXPECT_EQ(0, munmap(region, size));
}
@@ -262,7 +268,7 @@
if (region == MAP_FAILED) {
_exit(1);
}
- if (memcmp(region, &data, size) != 0) {
+ if (memcmp(region, data.data(), size) != 0) {
munmap(region, size);
_exit(2);
}
@@ -272,11 +278,11 @@
_exit(0);
}, ::testing::ExitedWithCode(0), "");
- memset(&data, 0, size);
+ memset(data.data(), 0, size);
for (int i = 0; i < nRegions; i++) {
void *region;
ASSERT_NO_FATAL_FAILURE(TestMmap(fd[i], size, PROT_READ | PROT_WRITE, ®ion));
- ASSERT_EQ(0, memcmp(region, &data, size));
+ ASSERT_EQ(0, memcmp(region, data.data(), size));
EXPECT_EQ(0, munmap(region, size));
}
}
diff --git a/libprocessgroup/TEST_MAPPING b/libprocessgroup/TEST_MAPPING
new file mode 100644
index 0000000..29a9ff0
--- /dev/null
+++ b/libprocessgroup/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "postsubmit": [
+ {
+ "name": "StagedRollbackTest"
+ }
+ ]
+}
diff --git a/libstats/pull_rust/Android.bp b/libstats/pull_rust/Android.bp
index 4609e6b..6902026 100644
--- a/libstats/pull_rust/Android.bp
+++ b/libstats/pull_rust/Android.bp
@@ -60,8 +60,8 @@
crate_name: "statspull_rust",
srcs: ["stats_pull.rs"],
rustlibs: [
- "liblazy_static",
"liblog_rust",
+ "libonce_cell",
"libstatslog_rust_header",
"libstatspull_bindgen",
],
diff --git a/libstats/pull_rust/stats_pull.rs b/libstats/pull_rust/stats_pull.rs
index d188b5f..b2bebcc 100644
--- a/libstats/pull_rust/stats_pull.rs
+++ b/libstats/pull_rust/stats_pull.rs
@@ -14,7 +14,7 @@
//! A Rust interface for the StatsD pull API.
-use lazy_static::lazy_static;
+use once_cell::sync::Lazy;
use statslog_rust_header::{Atoms, Stat, StatsError};
use statspull_bindgen::*;
use std::collections::HashMap;
@@ -107,9 +107,8 @@
}
}
-lazy_static! {
- static ref COOKIES: Mutex<HashMap<i32, fn() -> StatsPullResult>> = Mutex::new(HashMap::new());
-}
+static COOKIES: Lazy<Mutex<HashMap<i32, fn() -> StatsPullResult>>> =
+ Lazy::new(|| Mutex::new(HashMap::new()));
/// # Safety
///
diff --git a/libutils/StopWatch.cpp b/libutils/StopWatch.cpp
index c88d60f..c91cd5c 100644
--- a/libutils/StopWatch.cpp
+++ b/libutils/StopWatch.cpp
@@ -18,10 +18,6 @@
#include <utils/StopWatch.h>
-/* for PRId64 */
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS 1
-#endif
#include <inttypes.h>
#include <log/log.h>
diff --git a/libutils/binder/SharedBuffer_test.cpp b/libutils/binder/SharedBuffer_test.cpp
index 1d6317f..26702b0 100644
--- a/libutils/binder/SharedBuffer_test.cpp
+++ b/libutils/binder/SharedBuffer_test.cpp
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#define __STDC_LIMIT_MACROS
-
#include <gtest/gtest.h>
#include <memory>
diff --git a/libutils/binder/String8.cpp b/libutils/binder/String8.cpp
index 749bfcb..1de9e8b 100644
--- a/libutils/binder/String8.cpp
+++ b/libutils/binder/String8.cpp
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-#define __STDC_LIMIT_MACROS
-#include <stdint.h>
-
#include <utils/String8.h>
#include <log/log.h>
#include <utils/String16.h>
#include <ctype.h>
+#include <stdint.h>
#include <limits>
#include <string>
diff --git a/libutils/binder/Vector_test.cpp b/libutils/binder/Vector_test.cpp
index 6d90eaa..312dcf6 100644
--- a/libutils/binder/Vector_test.cpp
+++ b/libutils/binder/Vector_test.cpp
@@ -16,7 +16,6 @@
#define LOG_TAG "Vector_test"
-#define __STDC_LIMIT_MACROS
#include <stdint.h>
#include <unistd.h>
diff --git a/trusty/keymint/src/keymint_hal_main.rs b/trusty/keymint/src/keymint_hal_main.rs
index cfa859f..eda986a 100644
--- a/trusty/keymint/src/keymint_hal_main.rs
+++ b/trusty/keymint/src/keymint_hal_main.rs
@@ -92,8 +92,8 @@
android_logger::init_once(
android_logger::Config::default()
.with_tag("keymint-hal-trusty")
- .with_min_level(log::Level::Info)
- .with_log_id(android_logger::LogId::System),
+ .with_max_level(log::LevelFilter::Info)
+ .with_log_buffer(android_logger::LogId::System),
);
// Redirect panic messages to logcat.
panic::set_hook(Box::new(|panic_info| {
diff --git a/trusty/metrics/include/trusty/metrics/tipc.h b/trusty/metrics/include/trusty/metrics/tipc.h
index 66d0876..b29628e 100644
--- a/trusty/metrics/include/trusty/metrics/tipc.h
+++ b/trusty/metrics/include/trusty/metrics/tipc.h
@@ -91,9 +91,12 @@
* struct metrics_report_crash_req - arguments of %METRICS_CMD_REPORT_CRASH
* requests
* @app_id_len: length of app ID that follows this structure
+ * @crash_reason: architecture-specific code representing the reason for the
+ * crash
*/
struct metrics_report_crash_req {
uint32_t app_id_len;
+ uint32_t crash_reason;
} __attribute__((__packed__));
#define METRICS_MAX_APP_ID_LEN 256
diff --git a/trusty/secretkeeper/src/hal_main.rs b/trusty/secretkeeper/src/hal_main.rs
index 1dc697d..df30493 100644
--- a/trusty/secretkeeper/src/hal_main.rs
+++ b/trusty/secretkeeper/src/hal_main.rs
@@ -101,8 +101,8 @@
android_logger::init_once(
android_logger::Config::default()
.with_tag("secretkeeper-hal-trusty")
- .with_min_level(log::Level::Info)
- .with_log_id(android_logger::LogId::System),
+ .with_max_level(log::LevelFilter::Info)
+ .with_log_buffer(android_logger::LogId::System),
);
// Redirect panic messages to logcat.
panic::set_hook(Box::new(|panic_info| {