diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-11-11 05:08:45 +0100 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-11-11 05:08:45 +0100 |
commit | 2a4f016c4b062ce8f5955b77a9153b0e9587089f (patch) | |
tree | 2700cccf121a9199e94ea8c789d06aac5e49bde9 | |
parent | Snap for 5115169 from cf2a142c4370c023eb62f86fb193e1c6b1d62b02 to qt-release (diff) | |
parent | Merge "Check and dump the signal info for killed updater." am: 02a945556e am: d409598e08 (diff) | |
download | android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar.gz android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar.bz2 android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar.lz android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar.xz android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.tar.zst android_bootable_recovery-2a4f016c4b062ce8f5955b77a9153b0e9587089f.zip |
-rw-r--r-- | install.cpp | 11 | ||||
-rw-r--r-- | minui/include/minui/minui.h | 14 | ||||
-rw-r--r-- | minui/resources.cpp | 15 |
3 files changed, 25 insertions, 15 deletions
diff --git a/install.cpp b/install.cpp index e1e8ee879..680937dd1 100644 --- a/install.cpp +++ b/install.cpp @@ -497,9 +497,16 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b if (retry_update) { return INSTALL_RETRY; } - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - LOG(ERROR) << "Error in " << package << " (Status " << WEXITSTATUS(status) << ")"; + if (WIFEXITED(status)) { + if (WEXITSTATUS(status) != EXIT_SUCCESS) { + LOG(ERROR) << "Error in " << package << " (status " << WEXITSTATUS(status) << ")"; + return INSTALL_ERROR; + } + } else if (WIFSIGNALED(status)) { + LOG(ERROR) << "Error in " << package << " (killed by signal " << WTERMSIG(status) << ")"; return INSTALL_ERROR; + } else { + LOG(FATAL) << "Invalid status code " << status; } return INSTALL_SUCCESS; diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h index 0b499e621..3231248a0 100644 --- a/minui/include/minui/minui.h +++ b/minui/include/minui/minui.h @@ -17,6 +17,7 @@ #pragma once #include <stdint.h> +#include <stdlib.h> #include <sys/types.h> #include <functional> @@ -32,7 +33,7 @@ class GRSurface { public: - virtual ~GRSurface(); + virtual ~GRSurface() = default; // Creates and returns a GRSurface instance that's sufficient for storing an image of the given // size. The starting address of the surface data is aligned to SURFACE_DATA_ALIGNMENT. Returns @@ -44,7 +45,7 @@ class GRSurface { std::unique_ptr<GRSurface> Clone() const; virtual uint8_t* data() { - return data_; + return data_.get(); } const uint8_t* data() const { @@ -61,7 +62,14 @@ class GRSurface { : width(width), height(height), row_bytes(row_bytes), pixel_bytes(pixel_bytes) {} private: - uint8_t* data_{ nullptr }; + // The deleter for data_, whose data is allocated via aligned_alloc(3). + struct DataDeleter { + void operator()(uint8_t* data) { + free(data); + } + }; + + std::unique_ptr<uint8_t, DataDeleter> data_; size_t data_size_; DISALLOW_COPY_AND_ASSIGN(GRSurface); diff --git a/minui/resources.cpp b/minui/resources.cpp index 9027bc668..c7af1904d 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -46,24 +46,19 @@ std::unique_ptr<GRSurface> GRSurface::Create(int width, int height, int row_byte auto result = std::unique_ptr<GRSurface>(new GRSurface(width, height, row_bytes, pixel_bytes)); result->data_size_ = (data_size + kSurfaceDataAlignment - 1) / kSurfaceDataAlignment * kSurfaceDataAlignment; - result->data_ = static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, result->data_size_)); - if (result->data_ == nullptr) return nullptr; + result->data_.reset( + static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, result->data_size_))); + if (!result->data_) return nullptr; return result; } std::unique_ptr<GRSurface> GRSurface::Clone() const { auto result = GRSurface::Create(width, height, row_bytes, pixel_bytes, data_size_); - memcpy(result->data_, data_, data_size_); + if (!result) return nullptr; + memcpy(result->data(), data(), data_size_); return result; } -GRSurface::~GRSurface() { - if (data_ != nullptr) { - free(data_); - data_ = nullptr; - } -} - PngHandler::PngHandler(const std::string& name) { std::string res_path = g_resource_dir + "/" + name + ".png"; png_fp_.reset(fopen(res_path.c_str(), "rbe")); |