Skip to content

Commit cf66ba4

Browse files
committed
DEBUG_ASSERT condition is now considered as used.
1 parent 8825b22 commit cf66ba4

6 files changed

Lines changed: 10 additions & 21 deletions

File tree

src/control/controlobject.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ ControlObject::ControlObject(const ConfigKey& key,
4141
ControlObject::~ControlObject() {
4242
DEBUG_ASSERT(m_pControl);
4343
const bool success = m_pControl->resetCreatorCO(this);
44-
Q_UNUSED(success);
4544
DEBUG_ASSERT(success);
4645
}
4746

src/library/dao/autodjcratesdao.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ namespace {
4343
constexpr int kLeastPreferredPercent = 15;
4444

4545
// These consts are only used for DEBUG_ASSERTs
46-
#ifdef MIXXX_DEBUG_ASSERTIONS_ENABLED
4746
constexpr int kLeastPreferredPercentMin = 0;
4847
constexpr int kLeastPreferredPercentMax = 50;
49-
#endif
5048

5149
int bounded_rand(int highest) {
5250
return QRandomGenerator::global()->bounded(highest);

src/qml/qmlwaveformoverview.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ void QmlWaveformOverview::slotTrackLoaded(TrackPointer pTrack) {
7676
}
7777

7878
void QmlWaveformOverview::slotTrackLoading(TrackPointer pNewTrack, TrackPointer pOldTrack) {
79-
Q_UNUSED(pOldTrack); // only used in DEBUG_ASSERT
8079
DEBUG_ASSERT(m_pCurrentTrack == pOldTrack);
8180
setCurrentTrack(pNewTrack);
8281
}

src/sources/soundsourcemp3.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,11 @@ void logFrameHeader(QDebug logger, const mad_header& madHeader) {
105105
<< "flags:" << formatHeaderFlags(madHeader.flags);
106106
}
107107

108-
inline bool isUnrecoverableError(mad_error error) {
108+
bool isUnrecoverableError(mad_error error) {
109109
return (MAD_ERROR_NONE != error) && !MAD_RECOVERABLE(error);
110110
}
111111

112-
#ifndef MIXXX_DEBUG_ASSERTIONS_ENABLED
113-
[[maybe_unused]]
114-
#endif
115-
inline bool
116-
hasUnrecoverableError(const mad_stream* pMadStream) {
112+
bool hasUnrecoverableError(const mad_stream* pMadStream) {
117113
if (pMadStream) {
118114
return isUnrecoverableError(pMadStream->error);
119115
}

src/track/beats.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ Beats::ConstIterator Beats::ConstIterator::operator+=(Beats::ConstIterator::diff
6060
}
6161

6262
DEBUG_ASSERT(n > 0);
63-
#ifdef MIXXX_DEBUG_ASSERTIONS_ENABLED
64-
const auto origValue = m_value;
65-
#endif
63+
const audio::FramePos origValue = m_value;
6664

6765
// Detect integer overflow in `m_beatOffset + n`
6866
const int maxBeatOffset = std::numeric_limits<Beats::ConstIterator::difference_type>::max();
@@ -108,9 +106,7 @@ Beats::ConstIterator Beats::ConstIterator::operator-=(Beats::ConstIterator::diff
108106
}
109107

110108
DEBUG_ASSERT(n > 0);
111-
#ifdef MIXXX_DEBUG_ASSERTIONS_ENABLED
112-
const auto origValue = m_value;
113-
#endif
109+
const audio::FramePos origValue = m_value;
114110

115111
// Detect integer overflow
116112
const int minBeatOffset = std::numeric_limits<Beats::ConstIterator::difference_type>::lowest();

src/util/assert.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ inline void mixxx_release_assert(const char* assertion, const char* file, int li
4949
/// MIXXX_DEBUG_ASSERTIONS_FATAL then the warning message is fatal. Compiles
5050
/// to nothing in release builds.
5151
///
52-
/// Be careful of the common mistake with assertions:
52+
/// In release builds, it marks cond as used and checks if it can be converted
53+
/// to bool. Be careful of the common mistake with assertions:
5354
/// DEBUG_ASSERT(doSomething());
54-
///
55-
/// In release builds, doSomething() is never called!
55+
/// doSomething() is never called, in In release builds.
5656
#ifdef MIXXX_DEBUG_ASSERTIONS_ENABLED
5757
#define DEBUG_ASSERT(cond) \
5858
do \
@@ -61,8 +61,9 @@ inline void mixxx_release_assert(const char* assertion, const char* file, int li
6161
} \
6262
while (0)
6363
#else
64-
#define DEBUG_ASSERT(cond) \
65-
do { \
64+
#define DEBUG_ASSERT(cond) \
65+
do { \
66+
[[maybe_unused]] std::size_t s = sizeof(static_cast<bool>(cond)); \
6667
} while (0)
6768
#endif
6869

0 commit comments

Comments
 (0)