From 93eb277a883c8f7e33d9f8962066aaa32c3a27ce Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 11 Feb 2022 00:01:42 -0800 Subject: [PATCH] Update error messages --- native/jni/magiskboot/compress.cpp | 6 +++++- native/jni/utils/stream.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/native/jni/magiskboot/compress.cpp b/native/jni/magiskboot/compress.cpp index 2070cf341..e9966cad3 100644 --- a/native/jni/magiskboot/compress.cpp +++ b/native/jni/magiskboot/compress.cpp @@ -438,7 +438,11 @@ public: ~LZ4F_encoder() override { size_t len = LZ4F_compressEnd(ctx, out_buf, outCapacity, nullptr); - bwrite(out_buf, len); + if (LZ4F_isError(len)) { + LOGE("LZ4F end of frame error: %s\n", LZ4F_getErrorName(len)); + } else if (!bwrite(out_buf, len)) { + LOGE("LZ4F end of frame error: I/O error\n"); + } LZ4F_freeCompressionContext(ctx); delete[] out_buf; } diff --git a/native/jni/utils/stream.cpp b/native/jni/utils/stream.cpp index 3dbba71ed..a5816fd32 100644 --- a/native/jni/utils/stream.cpp +++ b/native/jni/utils/stream.cpp @@ -163,7 +163,9 @@ bool chunk_out_stream::write(const void *_in, size_t len, bool final) { void chunk_out_stream::finalize() { if (buf_off) { - write_chunk(_buf, buf_off, true); + if (!write_chunk(_buf, buf_off, true)) { + LOGE("Error in finalize, file truncated\n"); + } delete[] _buf; _buf = nullptr; buf_off = 0;