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

Re-enable disabled GCC warnings where possible #7379

Merged
merged 3 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -646,22 +646,26 @@ option(USE_WERROR "Treat compiler warnings as errors" OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(COMPILE_ERROR_FLAGS
"-Wall" # Enable most warnings by default
"-Werror=unused-function" # Unused functions are an error
# TODO: Fix the code and remove the following:
"-Wno-sign-compare" # Permit comparisons between signed and unsigned integers
"-Wno-strict-overflow" # Permit optimisations assuming no signed overflow
)
set(THIRD_PARTY_COMPILE_ERROR_FLAGS
"-w" # Disable all warnings
)

# Due to a regression in gcc-4.8.X, we need to disable array-bounds check
# TODO: Is this still necessary?
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND COMPILE_ERROR_FLAGS
# The following warning generates false positives that are difficult
# to work around, in particular when inlining calls to standard
# algorithms performed on single-element arrays. See, for example,
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111273.
"-Wno-array-bounds" # Permit out-of-bounds array subscripts
"-Wno-attributes" # Permit unrecognised attributes
)

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11")
list(APPEND COMPILE_ERROR_FLAGS
# This has the same problems described above for "array-bounds".
"-Wno-stringop-overread" # Permit string functions overreading the source
)
endif()
endif()

if(USE_WERROR)
Expand Down
4 changes: 2 additions & 2 deletions include/AudioEngineWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class AudioEngineWorkerThread : public QThread

private:
std::atomic<ThreadableJob*> m_items[JOB_QUEUE_SIZE];
std::atomic_int m_writeIndex;
std::atomic_int m_itemsDone;
std::atomic_size_t m_writeIndex;
std::atomic_size_t m_itemsDone;
OperationMode m_opMode;
} ;

Expand Down
10 changes: 3 additions & 7 deletions include/AudioPortAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ class AudioPortAudio : public AudioDevice
return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "PortAudio" );
}


int process_callback( const float *_inputBuffer,
float * _outputBuffer,
unsigned long _framesPerBuffer );

int process_callback(const float* _inputBuffer, float* _outputBuffer, f_cnt_t _framesPerBuffer);

class setupWidget : public gui::AudioDeviceSetupWidget
{
Expand Down Expand Up @@ -151,8 +147,8 @@ class AudioPortAudio : public AudioDevice
bool m_wasPAInitError;

SampleFrame* m_outBuf;
int m_outBufPos;
int m_outBufSize;
std::size_t m_outBufPos;
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
fpp_t m_outBufSize;

bool m_stopped;

Expand Down
4 changes: 2 additions & 2 deletions include/LocklessAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class LocklessAllocator
std::atomic_int * m_freeState;
size_t m_freeStateSets;

std::atomic_int m_available;
std::atomic_int m_startIndex;
std::atomic_size_t m_available;
std::atomic_size_t m_startIndex;

} ;

Expand Down
4 changes: 3 additions & 1 deletion include/MidiEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class MidiEvent
setParam( 0, pitchBend );
}

auto sysExData() const -> const char* { return m_sysExData; }

Source source() const
{
return m_source;
Expand All @@ -212,7 +214,7 @@ class MidiEvent
int32_t m_sysExDataLen; // len of m_sysExData
} m_data;

[[maybe_unused]] const char* m_sysExData;
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 include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class MixerChannel : public ThreadableJob
auto color() const -> const std::optional<QColor>& { return m_color; }
void setColor(const std::optional<QColor>& color) { m_color = color; }

std::atomic_int m_dependenciesMet;
std::atomic_size_t m_dependenciesMet;
void incrementDeps();
void processed();

Expand Down
16 changes: 4 additions & 12 deletions include/Oscillator.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,8 @@ class LMMS_EXPORT Oscillator
{
if (buffer == nullptr || buffer->size() == 0) { return 0; }
const auto frames = buffer->size();
const auto frame = sample * frames;
auto f1 = static_cast<f_cnt_t>(frame) % frames;
if (f1 < 0)
{
f1 += frames;
}
const auto frame = absFraction(sample) * frames;
const auto f1 = static_cast<f_cnt_t>(frame);

return linearInterpolate(buffer->data()[f1][0], buffer->data()[(f1 + 1) % frames][0], fraction(frame));
}
Expand All @@ -190,12 +186,8 @@ class LMMS_EXPORT Oscillator
inline wtSampleControl getWtSampleControl(const float sample) const
{
wtSampleControl control;
control.frame = sample * OscillatorConstants::WAVETABLE_LENGTH;
control.f1 = static_cast<f_cnt_t>(control.frame) % OscillatorConstants::WAVETABLE_LENGTH;
if (control.f1 < 0)
{
control.f1 += OscillatorConstants::WAVETABLE_LENGTH;
}
control.frame = absFraction(sample) * OscillatorConstants::WAVETABLE_LENGTH;
control.f1 = static_cast<f_cnt_t>(control.frame);
control.f2 = control.f1 < OscillatorConstants::WAVETABLE_LENGTH - 1 ?
control.f1 + 1 :
0;
Expand Down
4 changes: 1 addition & 3 deletions include/RemotePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ private slots:
void processErrored(QProcess::ProcessError err );
} ;


LMMS_EXPORT inline std::string QSTR_TO_STDSTR(QString const& qstr)
inline std::string QSTR_TO_STDSTR(QString const& qstr)
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
{
return qstr.toStdString();
}


} // namespace lmms

#endif // LMMS_REMOTE_PLUGIN_H
8 changes: 4 additions & 4 deletions include/RmsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace lmms
class RmsHelper
{
public:
RmsHelper( int size ) :
RmsHelper(std::size_t size) :
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
m_buffer( nullptr )
{
setSize( size );
Expand All @@ -46,7 +46,7 @@ class RmsHelper
if( m_buffer ) delete[] m_buffer;
}

inline void setSize( int size )
void setSize(std::size_t size)
{
if( m_buffer )
{
Expand Down Expand Up @@ -90,8 +90,8 @@ class RmsHelper
private:
float * m_buffer;
float m_sum;
unsigned int m_pos;
unsigned int m_size;
std::size_t m_pos;
std::size_t m_size;
float m_sizef;
};

Expand Down
2 changes: 1 addition & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
void deleteClips();

int numOfClips();
Clip * getClip( int clipNum );
auto getClip(std::size_t clipNum) -> Clip*;
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
int getClipNum(const Clip* clip );

const clipVector & getClips() const
Expand Down
2 changes: 1 addition & 1 deletion include/fft_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace lmms
// NOTE: FFT_BUFFER_SIZE should be considered deprecated!
// It is used by Eq plugin and some older code here, but this should be a user
// switchable parameter, not a constant. Use a value from FFT_BLOCK_SIZES
const unsigned int FFT_BUFFER_SIZE = 2048;
constexpr auto FFT_BUFFER_SIZE = std::size_t{2048};

// Allowed FFT block sizes. Ranging from barely useful to barely acceptable
// because of performance and latency reasons.
Expand Down
5 changes: 2 additions & 3 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ static inline float fraction( const float _x )
* If the result is interpreted as a phase of an oscillator, it makes that negative phases are
* converted to positive phases.
*/
static inline float absFraction( const float _x )
static inline float absFraction(const float x)
{
return( _x - ( _x >= 0.0f ? static_cast<int>( _x ) :
static_cast<int>( _x ) - 1 ) );
return x - std::floor(x);
}

/*!
Expand Down
4 changes: 2 additions & 2 deletions plugins/AudioFileProcessor/AudioFileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void AudioFileProcessor::playNote( NotePlayHandle * _n,

if( !_n->m_pluginData )
{
if (m_stutterModel.value() == true && m_nextPlayStartPoint >= m_sample.endFrame())
if (m_stutterModel.value() == true && m_nextPlayStartPoint >= static_cast<std::size_t>(m_sample.endFrame()))
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
{
// Restart playing the note if in stutter mode, not in loop mode,
// and we're at the end of the sample.
Expand Down Expand Up @@ -288,7 +288,7 @@ auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> f_cnt_t
* Engine::audioEngine()->outputSampleRate()
/ Engine::audioEngine()->baseSampleRate();

const auto startFrame = m_nextPlayStartPoint >= m_sample.endFrame()
const auto startFrame = m_nextPlayStartPoint >= static_cast<std::size_t>(m_sample.endFrame())
? m_sample.startFrame()
: m_nextPlayStartPoint;
const auto duration = m_sample.endFrame() - startFrame;
Expand Down
8 changes: 4 additions & 4 deletions plugins/Bitcrush/Bitcrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames )
// read input buffer and write it to oversampled buffer
if( m_rateEnabled ) // rate crushing enabled so do that
{
for( int f = 0; f < frames; ++f )
for (auto f = std::size_t{0}; f < frames; ++f)
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
{
for( int o = 0; o < OS_RATE; ++o )
{
Expand All @@ -180,7 +180,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames )
}
else // rate crushing disabled: simply oversample with zero-order hold
{
for( int f = 0; f < frames; ++f )
for (auto f = std::size_t{0}; f < frames; ++f)
{
for( int o = 0; o < OS_RATE; ++o )
{
Expand All @@ -196,7 +196,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames )

// the oversampled buffer is now written, so filter it to reduce aliasing

for( int f = 0; f < frames * OS_RATE; ++f )
for (auto f = std::size_t{0}; f < frames * OS_RATE; ++f)
{
if( qMax( qAbs( m_buffer[f][0] ), qAbs( m_buffer[f][1] ) ) >= 1.0e-10f )
{
Expand Down Expand Up @@ -225,7 +225,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames )
double outSum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
for( int f = 0; f < frames; ++f )
for (auto f = std::size_t{0}; f < frames; ++f)
{
float lsum = 0.0f;
float rsum = 0.0f;
Expand Down
24 changes: 12 additions & 12 deletions plugins/CarlaBase/Carla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D
m_paramsCompleter->setCompletionMode(QCompleter::PopupCompletion);

// Add static amount of CarlaParamFloatModel's.
int paramCount = fDescriptor->get_parameter_count(fHandle);
const auto paramCount = fDescriptor->get_parameter_count(fHandle);
m_paramModels.reserve(paramCount);
for (int i=0; i < paramCount; ++i)
for (auto i = std::size_t{0}; i < paramCount; ++i)
{
m_paramModels.push_back(new CarlaParamFloatModel(this));
connect(m_paramModels[i], &CarlaParamFloatModel::dataChanged,
Expand Down Expand Up @@ -274,7 +274,7 @@ const NativeTimeInfo* CarlaInstrument::handleGetTimeInfo() const

void CarlaInstrument::handleUiParameterChanged(const uint32_t index, const float value) const
{
if (m_paramModels.count() > index)
if (m_paramModels.size() > index)
{
m_paramModels[index]->setValue(value);
}
Expand Down Expand Up @@ -369,7 +369,7 @@ void CarlaInstrument::saveSettings(QDomDocument& doc, QDomElement& parent)
std::free(state);

#if CARLA_VERSION_HEX >= CARLA_MIN_PARAM_VERSION
for (uint32_t index = 0; index < m_paramModels.count(); ++index)
for (uint32_t index = 0; index < m_paramModels.size(); ++index)
{
QString idStr = CARLA_SETTING_PREFIX + QString::number(index);
m_paramModels[index]->saveSettings(doc, parent, idStr);
Expand Down Expand Up @@ -439,7 +439,7 @@ void CarlaInstrument::refreshParams(bool init)
void CarlaInstrument::clearParamModels()
{
//Delete the models, this also disconnects all connections (automation and controller connections)
for (uint32_t index=0; index < m_paramModels.count(); ++index)
for (uint32_t index = 0; index < m_paramModels.size(); ++index)
{
delete m_paramModels[index];
}
Expand Down Expand Up @@ -899,7 +899,7 @@ CarlaParamsView::~CarlaParamsView()
m_carlaInstrumentView->m_paramsView = nullptr;

// Clear models
if (m_carlaInstrument->m_paramModels.isEmpty() == false)
if (!m_carlaInstrument->m_paramModels.empty())
{
m_carlaInstrument->clearParamModels();
}
Expand Down Expand Up @@ -930,7 +930,7 @@ void CarlaParamsView::filterKnobs()
m_maxColumns = m_inputScrollArea->width() / maxKnobWidth;

QString text = m_paramsFilterLineEdit->text();
for (uint32_t i=0; i < m_knobs.count(); ++i)
for (uint32_t i = 0; i < m_knobs.size(); ++i)
{
// Don't show disabled (unused) knobs.
if (!m_carlaInstrument->m_paramModels[i]->enabled())
Expand Down Expand Up @@ -975,7 +975,7 @@ void CarlaParamsView::filterKnobs()
void CarlaParamsView::refreshKnobs()
{
// Make sure all the knobs are deleted.
for (uint32_t i=0; i < m_knobs.count(); ++i)
for (uint32_t i = 0; i < m_knobs.size(); ++i)
{
delete m_knobs[i]; // Delete knob widgets itself.
}
Expand All @@ -996,15 +996,15 @@ void CarlaParamsView::refreshKnobs()
m_maxKnobWidthPerGroup[i] = 0;
}

if (!m_carlaInstrument->m_paramModels.count()) { return; }
if (m_carlaInstrument->m_paramModels.empty()) { return; }

// Make room in QList m_knobs
m_knobs.reserve(m_carlaInstrument->m_paramModels.count());
m_knobs.reserve(m_carlaInstrument->m_paramModels.size());

QStringList groupNameList;
groupNameList.reserve(m_carlaInstrument->m_paramGroupCount);

for (uint32_t i=0; i < m_carlaInstrument->m_paramModels.count(); ++i)
for (uint32_t i = 0; i < m_carlaInstrument->m_paramModels.size(); ++i)
{
bool enabled = m_carlaInstrument->m_paramModels[i]->enabled();
m_knobs.push_back(new Knob(KnobType::Dark28, m_inputScrollAreaWidgetContent));
Expand Down Expand Up @@ -1105,7 +1105,7 @@ void CarlaParamsView::addKnob(uint32_t index)
void CarlaParamsView::clearKnobs()
{
// Remove knobs from layout.
for (uint16_t i=0; i < m_knobs.count(); ++i)
for (uint16_t i = 0; i < m_knobs.size(); ++i)
{
m_knobs[i]->close();
}
Expand Down
6 changes: 4 additions & 2 deletions plugins/CarlaBase/Carla.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define CARLA_MIN_PARAM_VERSION 0x020090
#define CARLA_VERSION_HEX_3 0x30000

#include <vector>

// qt
#include <QCloseEvent>
#include <QDomElement>
Expand Down Expand Up @@ -223,7 +225,7 @@ private slots:
QMutex fMutex;

uint8_t m_paramGroupCount;
QList<CarlaParamFloatModel*> m_paramModels;
std::vector<CarlaParamFloatModel*> m_paramModels;
QDomElement m_settingsElem;

QCompleter* m_paramsCompleter;
Expand Down Expand Up @@ -351,7 +353,7 @@ private slots:

CarlaInstrument* const m_carlaInstrument;
CarlaInstrumentView* const m_carlaInstrumentView;
QList<Knob*> m_knobs;
std::vector<Knob*> m_knobs;

// Keep track of the biggest knob width per group
QList<uint16_t> m_maxKnobWidthPerGroup;
Expand Down
Loading
Loading