From aab3c343d0d2328cc35b5f76feefb8fb2278f013 Mon Sep 17 00:00:00 2001 From: badaix Date: Sat, 28 Nov 2020 21:20:32 +0100 Subject: [PATCH] Fix warnings --- CMakeLists.txt | 4 +++- client/decoder/flac_decoder.cpp | 3 ++- client/decoder/ogg_decoder.cpp | 2 +- client/player/player.cpp | 1 - client/player/wasapi_player.cpp | 4 ++++ client/player/wasapi_player.hpp | 5 +++++ client/stream.cpp | 2 +- common/aixlog.hpp | 4 ++-- common/message/client_info.hpp | 2 +- common/message/message.hpp | 2 +- common/message/server_settings.hpp | 2 +- common/time_defs.hpp | 1 + server/control_session_http.hpp | 3 +++ server/control_session_ws.hpp | 3 +++ server/stream_session_ws.hpp | 3 +++ 15 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a040a94e..c576a573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,9 @@ option(BUILD_TESTS "Build tests (run tests with make test)" ON) if (MSVC) # warning level 4 and all warnings as errors - add_compile_options(/W4 /WX) + # warning C4505: 'getArch': unreferenced local function has been removed + # warning C4458: declaration of 'size' hides class member + add_compile_options(/W4 /WX /wd4458 /wd4505) else() # lots of warnings and all warnings as errors add_compile_options(-Wall -Wextra -pedantic -Werror -Wno-unused-function) diff --git a/client/decoder/flac_decoder.cpp b/client/decoder/flac_decoder.cpp index c8e1d838..08a67437 100644 --- a/client/decoder/flac_decoder.cpp +++ b/client/decoder/flac_decoder.cpp @@ -206,7 +206,8 @@ void metadata_callback(const FLAC__StreamDecoder* /*decoder*/, const FLAC__Strea if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { static_cast(client_data)->cacheInfo_.sampleRate_ = metadata->data.stream_info.sample_rate; - sampleFormat.setFormat(metadata->data.stream_info.sample_rate, metadata->data.stream_info.bits_per_sample, metadata->data.stream_info.channels); + sampleFormat.setFormat(metadata->data.stream_info.sample_rate, static_cast(metadata->data.stream_info.bits_per_sample), + static_cast(metadata->data.stream_info.channels)); } } diff --git a/client/decoder/ogg_decoder.cpp b/client/decoder/ogg_decoder.cpp index fa11c572..d0ef4a25 100644 --- a/client/decoder/ogg_decoder.cpp +++ b/client/decoder/ogg_decoder.cpp @@ -225,7 +225,7 @@ SampleFormat OggDecoder::setHeader(msg::CodecHeader* chunk) /// local state for most of the decode so multiple block decodes can proceed /// in parallel. We could init multiple vorbis_block structures for vd here - sampleFormat_.setFormat(vi.rate, 16, vi.channels); + sampleFormat_.setFormat(vi.rate, 16, static_cast(vi.channels)); /* Throw the comments plus a few lines about the bitstream we're decoding */ char** ptr = vc.user_comments; diff --git a/client/player/player.cpp b/client/player/player.cpp index d7c18882..a694af2e 100644 --- a/client/player/player.cpp +++ b/client/player/player.cpp @@ -149,7 +149,6 @@ bool Player::getHardwareVolume(double& volume, bool& muted) std::ignore = volume; std::ignore = muted; throw SnapException("Failed to get hardware mixer volume: not supported"); - return false; } diff --git a/client/player/wasapi_player.cpp b/client/player/wasapi_player.cpp index 252c7c42..359d14f5 100644 --- a/client/player/wasapi_player.cpp +++ b/client/player/wasapi_player.cpp @@ -156,6 +156,8 @@ vector WASAPIPlayer::pcm_list() return deviceList; } +#pragma warning(push) +#pragma warning(disable : 4127) void WASAPIPlayer::worker() { assert(sizeof(char) == sizeof(BYTE)); @@ -396,6 +398,7 @@ void WASAPIPlayer::worker() } } } +#pragma warning(pop) HRESULT STDMETHODCALLTYPE AudioSessionEventListener::QueryInterface(REFIID riid, VOID** ppvInterface) { @@ -419,6 +422,7 @@ HRESULT STDMETHODCALLTYPE AudioSessionEventListener::QueryInterface(REFIID riid, HRESULT STDMETHODCALLTYPE AudioSessionEventListener::OnSimpleVolumeChanged(float NewVolume, BOOL NewMute, LPCGUID EventContext) { + std::ignore = EventContext; volume_ = NewVolume; muted_ = NewMute; diff --git a/client/player/wasapi_player.hpp b/client/player/wasapi_player.hpp index 04675f3d..eba9119b 100644 --- a/client/player/wasapi_player.hpp +++ b/client/player/wasapi_player.hpp @@ -19,6 +19,9 @@ #ifndef WASAPI_PLAYER_HPP #define WASAPI_PLAYER_HPP +#pragma warning(push) +#pragma warning(disable : 4100) + #include "player.hpp" #include #include @@ -187,4 +190,6 @@ private: ClientSettings::SharingMode mode_; }; +#pragma warning(pop) + #endif diff --git a/client/stream.cpp b/client/stream.cpp index 003b7495..9a6d4c15 100644 --- a/client/stream.cpp +++ b/client/stream.cpp @@ -115,7 +115,7 @@ void Stream::addChunk(unique_ptr chunk) std::shared_ptr front_; while (chunks_.front_copy(front_)) { - auto age = std::chrono::duration_cast(TimeProvider::serverNow() - front_->start()); + age = std::chrono::duration_cast(TimeProvider::serverNow() - front_->start()); if ((age > 5s + bufferMs_) && chunks_.try_pop(front_)) LOG(TRACE, LOG_TAG) << "Oldest chunk too old: " << age.count() << " ms, removing. Chunks in queue left: " << chunks_.size() << "\n"; else diff --git a/common/aixlog.hpp b/common/aixlog.hpp index 491f33c9..acc7b72f 100644 --- a/common/aixlog.hpp +++ b/common/aixlog.hpp @@ -178,7 +178,7 @@ enum class Severity : std::int8_t static Severity to_severity(std::string severity, Severity def = Severity::info) { - std::transform(severity.begin(), severity.end(), severity.begin(), [](unsigned char c) { return std::tolower(c); }); + std::transform(severity.begin(), severity.end(), severity.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); if (severity == "trace") return Severity::trace; else if (severity == "debug") @@ -841,7 +841,7 @@ struct SinkOutputDebugString : public Sink { } - void log(const Metadata& metadata, const std::string& message) override + void log(const Metadata& /*metadata*/, const std::string& message) override { std::wstring wide = std::wstring(message.begin(), message.end()); OutputDebugString(wide.c_str()); diff --git a/common/message/client_info.hpp b/common/message/client_info.hpp index c8592509..cf918939 100644 --- a/common/message/client_info.hpp +++ b/common/message/client_info.hpp @@ -40,7 +40,7 @@ public: uint16_t getVolume() { - return get("volume", 100); + return get("volume", static_cast(100)); } bool isMuted() diff --git a/common/message/message.hpp b/common/message/message.hpp index 20599209..f40e408c 100644 --- a/common/message/message.hpp +++ b/common/message/message.hpp @@ -124,7 +124,7 @@ struct BaseMessage { } - BaseMessage(message_type type_) : type(type_), id(0), refersTo(0) + BaseMessage(message_type type_) : type(static_cast(type_)), id(0), refersTo(0) { } diff --git a/common/message/server_settings.hpp b/common/message/server_settings.hpp index 4aad4211..a5b86fe8 100644 --- a/common/message/server_settings.hpp +++ b/common/message/server_settings.hpp @@ -50,7 +50,7 @@ public: uint16_t getVolume() { - return get("volume", 100); + return get("volume", static_cast(100)); } bool isMuted() diff --git a/common/time_defs.hpp b/common/time_defs.hpp index af65c151..b2a2e1f3 100644 --- a/common/time_defs.hpp +++ b/common/time_defs.hpp @@ -61,6 +61,7 @@ inline static void timeofday(struct timeval* tv) // Implementation from http://stackoverflow.com/a/26085827/2510022 inline static int gettimeofday(struct timeval* tp, struct timezone* tzp) { + std::ignore = tzp; // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); diff --git a/server/control_session_http.hpp b/server/control_session_http.hpp index 26a32a6c..56016721 100644 --- a/server/control_session_http.hpp +++ b/server/control_session_http.hpp @@ -21,7 +21,10 @@ #include "control_session.hpp" #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" #include +#pragma GCC diagnostic pop #include namespace beast = boost::beast; // from diff --git a/server/control_session_ws.hpp b/server/control_session_ws.hpp index c5836b46..fb8d9ced 100644 --- a/server/control_session_ws.hpp +++ b/server/control_session_ws.hpp @@ -21,7 +21,10 @@ #include "control_session.hpp" #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" #include +#pragma GCC diagnostic pop #include namespace beast = boost::beast; // from diff --git a/server/stream_session_ws.hpp b/server/stream_session_ws.hpp index 201ae848..c18212a6 100644 --- a/server/stream_session_ws.hpp +++ b/server/stream_session_ws.hpp @@ -21,7 +21,10 @@ #include "stream_session.hpp" #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" #include +#pragma GCC diagnostic pop #include namespace beast = boost::beast; // from