Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings in Clang build #6893

Merged
merged 12 commits into from
Sep 29, 2023
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: 1 addition & 1 deletion include/Lv2UridMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class UridMap
LV2_URID_Map m_mapFeature;
LV2_URID_Unmap m_unmapFeature;

LV2_URID m_lastUrid = 0;
[[maybe_unused]] LV2_URID m_lastUrid = 0;

public:
//! constructor; will set up the features
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 * ( (float) rand() / (static_cast<float>(RAND_MAX) + 1.0f)) < m_arpSkipModel.value() )
messmerd marked this conversation as resolved.
Show resolved Hide resolved
{
// 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 * ( (float) rand() / (static_cast<float>(RAND_MAX) + 1.0f)) < m_arpMissModel.value() )
messmerd marked this conversation as resolved.
Show resolved Hide resolved
{
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,
messmerd marked this conversation as resolved.
Show resolved Hide resolved
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