Skip to content

Commit

Permalink
Fix warnings in Clang build (#6893)
Browse files Browse the repository at this point in the history
* Fix unused variable warning

* Fix implicit conversion warning

* Fix unused lambda capture in DataFile.cpp

* Fix implicit conversions in InstrumentFunctions.cpp

* Fix operator precedence bug in Flags.h

* Fix unused variable warning in Lv2UridMap.h

* Fix unused lambda capture in MixerView.cpp

* Fix unused lambda captures in SetupDialog.cpp

* Fix unused lambda capture in TrackOperationsWidget.cpp

* Fix MSVC build

* Fix style

* Remove unused member variable in Lv2UridMap.h
  • Loading branch information
messmerd authored Sep 29, 2023
1 parent 23ef89b commit 8fb9c3e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/Flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class Flags
m_value{value}
{}

constexpr auto testAll(Flags flags) const -> bool { return *this & flags == flags; }
constexpr auto testAny(Flags flags) const -> bool { return *this & flags != Flags{}; }
constexpr auto testAll(Flags flags) const -> bool { return (*this & flags) == flags; }
constexpr auto testAny(Flags flags) const -> bool { return (*this & flags) != Flags{}; }
constexpr auto testFlag(EnumType flag) const -> bool { return static_cast<bool>(*this & flag); }

constexpr auto operator~() const -> Flags { return Flags{~m_value}; }
Expand Down
2 changes: 0 additions & 2 deletions include/Lv2UridMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class UridMap
LV2_URID_Map m_mapFeature;
LV2_URID_Unmap m_unmapFeature;

LV2_URID m_lastUrid = 0;

public:
//! constructor; will set up the features
UridMap();
Expand Down
2 changes: 1 addition & 1 deletion include/MidiEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class MidiEvent
int32_t m_sysExDataLen; // len of m_sysExData
} m_data;

const char* m_sysExData;
[[maybe_unused]] const char* m_sysExData;
const void* m_sourcePort;

// Stores the source of the MidiEvent: Internal or External (hardware controllers).
Expand Down
2 changes: 1 addition & 1 deletion src/core/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void DataFile::write( QTextStream & _strm )
bool DataFile::writeFile(const QString& filename, bool withResources)
{
// Small lambda function for displaying errors
auto showError = [this](QString title, QString body){
auto showError = [](QString title, QString body){
if (gui::getGUI() != nullptr)
{
QMessageBox mb;
Expand Down
7 changes: 4 additions & 3 deletions src/core/DrumSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sa
//generation
long Length, tpos=0, tplus, totmp, t, i, j;
float x[3] = {0.f, 0.f, 0.f};
float MasterTune, randmax, randmax2;
float MasterTune;
constexpr float randmax = 1.f / static_cast<float>(RAND_MAX);
constexpr float randmax2 = 2.f / static_cast<float>(RAND_MAX);
int MainFilter, HighPass;

long NON, NT, TON, DiON, TDroop=0, DStep;
Expand Down Expand Up @@ -454,7 +456,6 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sa
}

//prepare envelopes
randmax = 1.f / RAND_MAX; randmax2 = 2.f * randmax;
for (i=1;i<8;i++) { envData[i][NEXTT]=0; envData[i][PNT]=0; }
Length = LongestEnv();

Expand Down Expand Up @@ -745,4 +746,4 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sa
}


} // namespace lmms
} // namespace lmms
4 changes: 2 additions & 2 deletions src/core/InstrumentFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )
// Skip notes randomly
if( m_arpSkipModel.value() )
{
if( 100 * ( (float) rand() / (float)( RAND_MAX + 1.0f ) ) < m_arpSkipModel.value() )
if (100 * static_cast<float>(rand()) / (static_cast<float>(RAND_MAX) + 1.0f) < m_arpSkipModel.value())
{
// update counters
frames_processed += arp_frames;
Expand All @@ -425,7 +425,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )

if( m_arpMissModel.value() )
{
if( 100 * ( (float) rand() / (float)( RAND_MAX + 1.0f ) ) < m_arpMissModel.value() )
if (100 * static_cast<float>(rand()) / (static_cast<float>(RAND_MAX) + 1.0f) < m_arpMissModel.value())
{
dir = ArpDirection::Random;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ bool MixerView::confirmRemoval(int index)
QString messageTitleRemoveTrack = tr("Confirm removal");
QString askAgainText = tr("Don't ask again");
auto askAgainCheckBox = new QCheckBox(askAgainText, nullptr);
connect(askAgainCheckBox, &QCheckBox::stateChanged, [this](int state) {
connect(askAgainCheckBox, &QCheckBox::stateChanged, [](int state) {
// Invert button state, if it's checked we *shouldn't* ask again
ConfigManager::inst()->setValue("ui", "mixerchanneldeletionwarning", state ? "0" : "1");
});
Expand Down
6 changes: 3 additions & 3 deletions src/gui/modals/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :


// Constants for positioning LED check boxes.
const int XDelta = 10;
const int YDelta = 18;
constexpr int XDelta = 10;
constexpr int YDelta = 18;

// Main widget.
auto main_w = new QWidget(this);
Expand Down Expand Up @@ -212,7 +212,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
auto generalControlsLayout = new QVBoxLayout;
generalControlsLayout->setSpacing(10);

auto addLedCheckBox = [&XDelta, &YDelta, this](const QString& ledText, TabWidget* tw, int& counter,
auto addLedCheckBox = [&](const QString& ledText, TabWidget* tw, int& counter,
bool initialState, const char* toggledSlot, bool showRestartWarning) {
auto checkBox = new LedCheckBox(ledText, tw);
counter++;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tracks/TrackOperationsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool TrackOperationsWidget::confirmRemoval()
QString messageTitleRemoveTrack = tr("Confirm removal");
QString askAgainText = tr("Don't ask again");
auto askAgainCheckBox = new QCheckBox(askAgainText, nullptr);
connect(askAgainCheckBox, &QCheckBox::stateChanged, [this](int state){
connect(askAgainCheckBox, &QCheckBox::stateChanged, [](int state){
// Invert button state, if it's checked we *shouldn't* ask again
ConfigManager::inst()->setValue("ui", "trackdeletionwarning", state ? "0" : "1");
});
Expand Down

0 comments on commit 8fb9c3e

Please sign in to comment.