From 8409f20a7f10cf2e470c1f1fb7d99d78c1450ad6 Mon Sep 17 00:00:00 2001 From: Serge Lamikhov-Center Date: Fri, 11 Nov 2022 01:09:12 +0200 Subject: [PATCH] Remove output to std::cerr --- elfio/elfio_section.hpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index 38f5fd1..974a1ae 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -225,31 +225,19 @@ template class section_impl : public section return false; } - if ( ( get_flags() & SHF_RPX_DEFLATE ) || - ( get_flags() & SHF_COMPRESSED ) ) { - if ( compression == nullptr ) { - std::cerr - << "WARN: compressed section found but no " - "compression implementation provided. Skipping." - << std::endl; - data = nullptr; - return false; - } + if ( ( ( get_flags() & SHF_RPX_DEFLATE ) || + ( get_flags() & SHF_COMPRESSED ) ) && + compression != nullptr ) { // at this point, data holds the whole compressed stream Elf_Xword uncompressed_size = 0; auto decompressed_data = compression->inflate( data.get(), convertor, size, uncompressed_size ); - if ( decompressed_data == nullptr ) { - std::cerr << "Failed to decompress section data." - << std::endl; - data = nullptr; - return false; + if ( decompressed_data != nullptr ) { + set_size( uncompressed_size ); + data = std::move( decompressed_data ); } - - set_size( uncompressed_size ); - - data = std::move( decompressed_data ); } + // refresh size because it may have changed if we had to decompress data size = get_size(); data.get()[size] =