From 8857bc75dfa48931aa6f7288cd0dc68499edb87b Mon Sep 17 00:00:00 2001 From: Oz Date: Wed, 17 Jan 2024 18:08:35 +0100 Subject: [PATCH] Fix warnings and build on some compilers --- include/bit7z/bitoutputarchive.hpp | 2 +- src/internal/cfixedbufferoutstream.cpp | 2 +- src/internal/windows.hpp | 5 +++-- tests/src/test_bitoutputarchive.cpp | 2 +- tests/src/test_dateutil.cpp | 2 ++ tests/src/utils/filesystem.cpp | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/bit7z/bitoutputarchive.hpp b/include/bit7z/bitoutputarchive.hpp index c4812da8..52cc7a6d 100644 --- a/include/bit7z/bitoutputarchive.hpp +++ b/include/bit7z/bitoutputarchive.hpp @@ -55,7 +55,7 @@ using DeletedItems = std::set< uint32_t >; * Note: given an InputIndex i: * if i < mInputArchiveItemsCount, the item is old (old item in the input archive); * if i >= mInputArchiveItemsCount, the item is new (added by the user); */ -enum class InputIndex : std::uint32_t {}; +enum class InputIndex : std::uint32_t {}; // NOLINT(*-enum-size) class UpdateCallback; diff --git a/src/internal/cfixedbufferoutstream.cpp b/src/internal/cfixedbufferoutstream.cpp index 169bce82..42397ea1 100644 --- a/src/internal/cfixedbufferoutstream.cpp +++ b/src/internal/cfixedbufferoutstream.cpp @@ -21,7 +21,7 @@ #include "bittypes.hpp" #include "internal/util.hpp" -#include //for std::copy_n +#include // for std::copy_n #include #include diff --git a/src/internal/windows.hpp b/src/internal/windows.hpp index 61f6d0c8..7faed7ad 100644 --- a/src/internal/windows.hpp +++ b/src/internal/windows.hpp @@ -90,8 +90,9 @@ constexpr auto WIN32_MASK = 0x0000FFFF; /* Note: p7zip uses FACILITY_WIN32, 7-zip version of HRESULT_FROM_WIN32 uses FACILITY_ERRNO. */ inline constexpr auto HRESULT_FROM_WIN32( unsigned int x ) -> HRESULT { - auto res = static_cast< HRESULT >( x ); - return ( res > 0 ) ? static_cast< HRESULT >( ( x & WIN32_MASK ) | ( FACILITY_WIN32 << 16u ) | 0x80000000 ) : res; + return ( static_cast< HRESULT >( x ) > 0 ) ? + static_cast< HRESULT >( ( x & WIN32_MASK ) | ( FACILITY_WIN32 << 16u ) | 0x80000000 ) : + static_cast< HRESULT >( x ); } constexpr auto ERROR_NEGATIVE_SEEK = 0x100131; diff --git a/tests/src/test_bitoutputarchive.cpp b/tests/src/test_bitoutputarchive.cpp index 24350403..a8426bfe 100644 --- a/tests/src/test_bitoutputarchive.cpp +++ b/tests/src/test_bitoutputarchive.cpp @@ -39,7 +39,7 @@ TEST_CASE( "BitOutputArchive: Compressing a commented file should preserve the c REQUIRE_NOTHROW( writer.addFile( path_to_tstring( commentedFile ) ) ); TempTestDirectory testOutDir{ "test_bitinputarchive" }; - INFO( "Output directory: " << testOutDir ); + INFO( "Output directory: " << testOutDir ) const auto* const outputArchive = BIT7Z_STRING( "commented.7z" ); REQUIRE_NOTHROW( writer.compressTo( outputArchive ) ); diff --git a/tests/src/test_dateutil.cpp b/tests/src/test_dateutil.cpp index fd3fd499..dadff23e 100644 --- a/tests/src/test_dateutil.cpp +++ b/tests/src/test_dateutil.cpp @@ -14,6 +14,8 @@ #include +#include // For std::time_t (on MSVC 2015). + using namespace bit7z; /* Note: std::time_t is usually a UNIX timestamp, so we are using only dates after the UNIX epoch datetime. diff --git a/tests/src/utils/filesystem.cpp b/tests/src/utils/filesystem.cpp index 0a666644..af2de36b 100644 --- a/tests/src/utils/filesystem.cpp +++ b/tests/src/utils/filesystem.cpp @@ -313,7 +313,7 @@ auto get_file_comment( const fs::path& filePath ) -> std::wstring { CCoInitialize init; CMyComPtr< IPropertyStore > propertyStore{}; SHGetPropertyStoreFromParsingName( filePath.c_str(), nullptr, GPS_READWRITE, IID_PPV_ARGS( &propertyStore ) ); - return get_property_as_string( propertyStore, PKEY_Comment ); + return propertyStore != nullptr ? get_property_as_string( propertyStore, PKEY_Comment ) : L""; } #endif