From 426a383ff84f4a7419fca73ca4b2be5fa4ba2689 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 8 Oct 2019 23:58:10 +0200 Subject: [PATCH 1/7] engine/sidechain/enginenetworkstream: Remove some unused variables --- src/engine/sidechain/enginenetworkstream.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/sidechain/enginenetworkstream.cpp b/src/engine/sidechain/enginenetworkstream.cpp index d23480b45d2c..3286d894e6ce 100644 --- a/src/engine/sidechain/enginenetworkstream.cpp +++ b/src/engine/sidechain/enginenetworkstream.cpp @@ -137,7 +137,6 @@ qint64 EngineNetworkStream::getNetworkTimeUs() { // will overflow > 200,000 years #ifdef __WINDOWS__ FILETIME ft; - qint64 t; // no GetSystemTimePreciseAsFileTime available, fall // back to GetSystemTimeAsFileTime. This happens before // Windows 8 and Windows Server 2012 @@ -156,11 +155,9 @@ qint64 EngineNetworkStream::getNetworkTimeUs() { // timer was not incremented since last call (< 15 ms) // Add time since last function call after last increment // This reduces the jitter < one call cycle which is sufficient - LARGE_INTEGER li; now += timerSinceInc.elapsed().toIntegerMicros(); } else { // timer was incremented - LARGE_INTEGER li; timerSinceInc.start(); oldNow = now; } From ddda3ac3eabec50b45124a3f92d52cce5e5f154c Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 9 Oct 2019 00:16:05 +0200 Subject: [PATCH 2/7] waveform/waveform.h: Typecast std::vector::size_type to int explicitly --- src/waveform/waveform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/waveform/waveform.h b/src/waveform/waveform.h index 31d468069ea0..aa544d6058c3 100644 --- a/src/waveform/waveform.h +++ b/src/waveform/waveform.h @@ -111,7 +111,7 @@ class Waveform { // We do not lock the mutex since m_data is not resized after the // constructor runs. - inline int getTextureSize() const { return m_data.size(); } + inline int getTextureSize() const { return static_cast(m_data.size()); } // Atomically get the number of data elements in this Waveform. We do not // lock the mutex since m_dataSize is not changed after the constructor From a1c245230cf4ffedff99affeaee140c36cb88292 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 9 Oct 2019 00:20:05 +0200 Subject: [PATCH 3/7] Add more typecasts from std::vector::size_type to int --- src/library/searchquery.cpp | 4 ++-- src/musicbrainz/chromaprinter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/searchquery.cpp b/src/library/searchquery.cpp index 29b051b3c0ba..0f7f4cea7b76 100644 --- a/src/library/searchquery.cpp +++ b/src/library/searchquery.cpp @@ -89,7 +89,7 @@ bool AndNode::match(const TrackPointer& pTrack) const { QString AndNode::toSql() const { QStringList queryFragments; - queryFragments.reserve(m_nodes.size()); + queryFragments.reserve(static_cast(m_nodes.size())); for (const auto& pNode: m_nodes) { QString sql = pNode->toSql(); if (!sql.isEmpty()) { @@ -118,7 +118,7 @@ bool OrNode::match(const TrackPointer& pTrack) const { QString OrNode::toSql() const { QStringList queryFragments; - queryFragments.reserve(m_nodes.size()); + queryFragments.reserve(static_cast(m_nodes.size())); for (const auto& pNode: m_nodes) { QString sql = pNode->toSql(); if (!sql.isEmpty()) { diff --git a/src/musicbrainz/chromaprinter.cpp b/src/musicbrainz/chromaprinter.cpp index 54503f94115f..c25acad437e2 100644 --- a/src/musicbrainz/chromaprinter.cpp +++ b/src/musicbrainz/chromaprinter.cpp @@ -64,7 +64,7 @@ QString calcFingerprint( PerformanceTimer timerGeneratingFingerprint; timerGeneratingFingerprint.start(); - int success = chromaprint_feed(ctx, &fingerprintSamples[0], fingerprintSamples.size()); + int success = chromaprint_feed(ctx, &fingerprintSamples[0], static_cast(fingerprintSamples.size())); chromaprint_finish(ctx); if (!success) { qWarning() << "Failed to generate fingerprint from sample data"; From ea88b92cf9bd6f77f5ecdec760d8b8ef8085d36c Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Wed, 9 Oct 2019 00:20:35 +0200 Subject: [PATCH 4/7] soundio/soundmanagerutil.cpp: Remove unnecessary switch statement --- src/soundio/soundmanagerutil.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/soundio/soundmanagerutil.cpp b/src/soundio/soundmanagerutil.cpp index 31ab76d81619..4af1df173a83 100644 --- a/src/soundio/soundmanagerutil.cpp +++ b/src/soundio/soundmanagerutil.cpp @@ -290,10 +290,7 @@ unsigned char AudioPath::minChannelsForType(AudioPathType type) { // static unsigned char AudioPath::maxChannelsForType(AudioPathType type) { - switch (type) { - default: - return 2; - } + return 2; } /** From 56c6b91349120ea273ba78827bc783ccddb1e613 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sat, 19 Oct 2019 19:04:48 +0200 Subject: [PATCH 5/7] preferences/dialog/dlgprefsound: Fix -Wreorder warning --- src/preferences/dialog/dlgprefsound.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences/dialog/dlgprefsound.h b/src/preferences/dialog/dlgprefsound.h index a2fb180a2435..1ce32731d168 100644 --- a/src/preferences/dialog/dlgprefsound.h +++ b/src/preferences/dialog/dlgprefsound.h @@ -112,8 +112,8 @@ class DlgPrefSound : public DlgPreferencePage, public Ui::DlgPrefSoundDlg { bool m_settingsModified; bool m_bLatencyChanged; bool m_bSkipConfigClear; - SoundManagerConfig m_config; bool m_loading; + SoundManagerConfig m_config; }; #endif From 03bff6d4c3f5d18eca70728a25fa2ba09de727f7 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sat, 19 Oct 2019 19:07:43 +0200 Subject: [PATCH 6/7] soundio/soundmanagerutil: Add Q_UNUSED to fix unused parameter warning --- src/soundio/soundmanagerutil.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/soundio/soundmanagerutil.cpp b/src/soundio/soundmanagerutil.cpp index 4af1df173a83..6b32859e0555 100644 --- a/src/soundio/soundmanagerutil.cpp +++ b/src/soundio/soundmanagerutil.cpp @@ -290,6 +290,7 @@ unsigned char AudioPath::minChannelsForType(AudioPathType type) { // static unsigned char AudioPath::maxChannelsForType(AudioPathType type) { + Q_UNUSED(type); return 2; } From 3fbf31bf3ee57bfb8bfa4882b8554d8b2b9fcd89 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sat, 19 Oct 2019 19:24:34 +0200 Subject: [PATCH 7/7] util/platform: Add support for the GCC/G++ fallthrough attribute --- src/util/platform.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/platform.h b/src/util/platform.h index e6d4a11b137e..e5bb65f1a42a 100644 --- a/src/util/platform.h +++ b/src/util/platform.h @@ -27,6 +27,11 @@ #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") #define M_FALLTHROUGH_INTENDED [[clang::fallthrough]] #endif +#elif defined(__GNUC__) +// Taken from https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough_003d +// We could also use a comment, but that would require ccache users to set the +// keep_comments_cpp option. If we switch to C++17, we can use [[fallthough]]. +#define M_FALLTHROUGH_INTENDED __attribute__ ((fallthrough)); #endif #ifndef M_FALLTHROUGH_INTENDED