Re-enable disabled GCC warnings where possible (#7379)

This commit is contained in:
Dominic Clark
2024-07-21 22:34:34 +01:00
committed by GitHub
parent 9c0fc8fc69
commit 851c884f58
68 changed files with 222 additions and 241 deletions

View File

@@ -79,7 +79,7 @@ void AudioEngineWorkerThread::JobQueue::run()
while (processedJob && m_itemsDone < m_writeIndex)
{
processedJob = false;
for( int i = 0; i < m_writeIndex && i < JOB_QUEUE_SIZE; ++i )
for (auto i = std::size_t{0}; i < m_writeIndex && i < JOB_QUEUE_SIZE; ++i)
{
ThreadableJob * job = m_items[i].exchange(nullptr);
if( job )

View File

@@ -159,11 +159,10 @@ inline void ControllerConnection::setTargetName( const QString & _name )
*/
void ControllerConnection::finalizeConnections()
{
for( int i = 0; i < s_connections.size(); ++i )
for (auto i = std::size_t{0}; i < s_connections.size(); ++i)
{
ControllerConnection * c = s_connections[i];
if ( !c->isFinalized() && c->m_controllerId <
Engine::getSong()->controllers().size() )
if (!c->isFinalized() && static_cast<std::size_t>(c->m_controllerId) < Engine::getSong()->controllers().size())
{
c->setController( Engine::getSong()->
controllers().at( c->m_controllerId ) );
@@ -221,7 +220,7 @@ void ControllerConnection::loadSettings( const QDomElement & _this )
if (!Engine::getSong()->isLoadingProject()
&& m_controllerId != -1
&& m_controllerId < Engine::getSong()->controllers().size())
&& static_cast<std::size_t>(m_controllerId) < Engine::getSong()->controllers().size())
{
setController( Engine::getSong()->
controllers().at( m_controllerId ) );

View File

@@ -1184,7 +1184,7 @@ static void upgradeElement_1_2_0_rc2_42( QDomElement & el )
int syncmode = el.attribute( "syncmode" ).toInt();
QStringList names;
QDomNamedNodeMap atts = el.attributes();
for( uint i = 0; i < atts.length(); i++ )
for (auto i = 0; i < atts.length(); i++)
{
QString name = atts.item( i ).nodeName();
if( name.endsWith( "_numerator" ) )

View File

@@ -299,11 +299,6 @@ void EnvelopeAndLfoParameters::fillLevel( float * _buf, f_cnt_t _frame,
{
QMutexLocker m(&m_paramMutex);
if( _frame < 0 || _release_begin < 0 )
{
return;
}
fillLfoLevel( _buf, _frame, _frames );
for( fpp_t offset = 0; offset < _frames; ++offset, ++_buf, ++_frame )

View File

@@ -66,7 +66,7 @@ InstrumentSoundShaping::InstrumentSoundShaping(
m_filterCutModel( 14000.0, 1.0, 14000.0, 1.0, this, tr( "Cutoff frequency" ) ),
m_filterResModel(0.5f, BasicFilters<>::minQ(), 10.f, 0.01f, this, tr("Q/Resonance"))
{
for( int i = 0; i < NumTargets; ++i )
for (auto i = std::size_t{0}; i < NumTargets; ++i)
{
float value_for_zero_amount = 0.0;
if( static_cast<Target>(i) == Target::Volume )
@@ -279,7 +279,7 @@ f_cnt_t InstrumentSoundShaping::envFrames( const bool _only_vol ) const
if( _only_vol == false )
{
for( int i = static_cast<std::size_t>(Target::Volume)+1; i < NumTargets; ++i )
for (auto i = static_cast<std::size_t>(Target::Volume) + 1; i < NumTargets; ++i)
{
if( m_envLfoParameters[i]->isUsed() &&
m_envLfoParameters[i]->PAHD_Frames() > ret_val )
@@ -313,7 +313,7 @@ f_cnt_t InstrumentSoundShaping::releaseFrames() const
return m_envLfoParameters[static_cast<std::size_t>(Target::Volume)]->releaseFrames();
}
for( int i = static_cast<std::size_t>(Target::Volume)+1; i < NumTargets; ++i )
for (auto i = static_cast<std::size_t>(Target::Volume) + 1; i < NumTargets; ++i)
{
if( m_envLfoParameters[i]->isUsed() )
{
@@ -333,7 +333,7 @@ void InstrumentSoundShaping::saveSettings( QDomDocument & _doc, QDomElement & _t
m_filterResModel.saveSettings( _doc, _this, "fres" );
m_filterEnabledModel.saveSettings( _doc, _this, "fwet" );
for( int i = 0; i < NumTargets; ++i )
for (auto i = std::size_t{0}; i < NumTargets; ++i)
{
m_envLfoParameters[i]->saveState( _doc, _this ).setTagName(
m_envLfoParameters[i]->nodeName() +
@@ -356,7 +356,7 @@ void InstrumentSoundShaping::loadSettings( const QDomElement & _this )
{
if( node.isElement() )
{
for( int i = 0; i < NumTargets; ++i )
for (auto i = std::size_t{0}; i < NumTargets; ++i)
{
if( node.nodeName() ==
m_envLfoParameters[i]->nodeName() +

View File

@@ -71,8 +71,7 @@ LocklessAllocator::LocklessAllocator( size_t nmemb, size_t size )
LocklessAllocator::~LocklessAllocator()
{
int available = m_available;
if( available != m_capacity )
if (m_available != m_capacity)
{
fprintf( stderr, "LocklessAllocator: "
"Destroying with elements still allocated\n" );
@@ -110,7 +109,7 @@ void * LocklessAllocator::alloc()
// Some of these CAS loops could probably use relaxed atomics, as discussed
// in http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange.
// Let's use sequentially-consistent ops to be safe for now.
int available = m_available.load();
auto available = m_available.load();
do
{
if( !available )

View File

@@ -126,14 +126,14 @@ int Microtuner::octaveSize() const
*/
void Microtuner::updateScaleList(int index)
{
if (index >= 0 && index < MaxScaleCount)
if (index >= 0 && static_cast<std::size_t>(index) < MaxScaleCount)
{
m_scaleModel.replaceItem(index,
QString::number(index) + ": " + Engine::getSong()->getScale(index)->getDescription());
}
else
{
for (int i = 0; i < MaxScaleCount; i++)
for (auto i = std::size_t{0}; i < MaxScaleCount; i++)
{
m_scaleModel.replaceItem(i,
QString::number(i) + ": " + Engine::getSong()->getScale(i)->getDescription());
@@ -147,14 +147,14 @@ void Microtuner::updateScaleList(int index)
*/
void Microtuner::updateKeymapList(int index)
{
if (index >= 0 && index < MaxKeymapCount)
if (index >= 0 && static_cast<std::size_t>(index) < MaxKeymapCount)
{
m_keymapModel.replaceItem(index,
QString::number(index) + ": " + Engine::getSong()->getKeymap(index)->getDescription());
}
else
{
for (int i = 0; i < MaxKeymapCount; i++)
for (auto i = std::size_t{0}; i < MaxKeymapCount; i++)
{
m_keymapModel.replaceItem(i,
QString::number(i) + ": " + Engine::getSong()->getKeymap(i)->getDescription());

View File

@@ -99,7 +99,7 @@ inline void MixerChannel::processed()
void MixerChannel::incrementDeps()
{
int i = m_dependenciesMet++ + 1;
const auto i = m_dependenciesMet++ + 1;
if( i >= m_receives.size() && ! m_queued )
{
m_queued = true;
@@ -235,7 +235,7 @@ int Mixer::createChannel()
void Mixer::activateSolo()
{
for (int i = 1; i < m_mixerChannels.size(); ++i)
for (auto i = std::size_t{1}; i < m_mixerChannels.size(); ++i)
{
m_mixerChannels[i]->m_muteBeforeSolo = m_mixerChannels[i]->m_muteModel.value();
m_mixerChannels[i]->m_muteModel.setValue( true );
@@ -244,7 +244,7 @@ void Mixer::activateSolo()
void Mixer::deactivateSolo()
{
for (int i = 1; i < m_mixerChannels.size(); ++i)
for (auto i = std::size_t{1}; i < m_mixerChannels.size(); ++i)
{
m_mixerChannels[i]->m_muteModel.setValue( m_mixerChannels[i]->m_muteBeforeSolo );
}
@@ -260,7 +260,7 @@ void Mixer::toggledSolo()
m_mixerChannels[m_lastSoloed]->m_soloModel.setValue( false );
}
//determine the soloed channel
for (int i = 0; i < m_mixerChannels.size(); ++i)
for (auto i = std::size_t{0}; i < m_mixerChannels.size(); ++i)
{
if (m_mixerChannels[i]->m_soloModel.value() == true)
soloedChan = i;
@@ -355,7 +355,7 @@ void Mixer::deleteChannel( int index )
m_mixerChannels.erase(m_mixerChannels.begin() + index);
delete ch;
for( int i = index; i < m_mixerChannels.size(); ++i )
for (auto i = static_cast<std::size_t>(index); i < m_mixerChannels.size(); ++i)
{
validateChannelName( i, i + 1 );
@@ -381,7 +381,7 @@ void Mixer::deleteChannel( int index )
void Mixer::moveChannelLeft( int index )
{
// can't move master or first channel
if( index <= 1 || index >= m_mixerChannels.size() )
if (index <= 1 || static_cast<std::size_t>(index) >= m_mixerChannels.size())
{
return;
}
@@ -744,7 +744,7 @@ void Mixer::clearChannel(mix_ch_t index)
void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
// save channels
for( int i = 0; i < m_mixerChannels.size(); ++i )
for (auto i = std::size_t{0}; i < m_mixerChannels.size(); ++i)
{
MixerChannel * ch = m_mixerChannels[i];
@@ -755,7 +755,7 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
ch->m_volumeModel.saveSettings( _doc, mixch, "volume" );
ch->m_muteModel.saveSettings( _doc, mixch, "muted" );
ch->m_soloModel.saveSettings( _doc, mixch, "soloed" );
mixch.setAttribute( "num", i );
mixch.setAttribute("num", static_cast<qulonglong>(i));
mixch.setAttribute( "name", ch->m_name );
if (const auto& color = ch->color()) { mixch.setAttribute("color", color->name()); }
@@ -774,7 +774,8 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
// make sure we have at least num channels
void Mixer::allocateChannelsTo(int num)
{
while( num > m_mixerChannels.size() - 1 )
if (num <= 0) { return; }
while (static_cast<std::size_t>(num) > m_mixerChannels.size() - 1)
{
createChannel();
@@ -813,7 +814,7 @@ void Mixer::loadSettings( const QDomElement & _this )
// mixer sends
QDomNodeList chData = mixch.childNodes();
for( unsigned int i=0; i<chData.length(); ++i )
for (auto i = 0; i < chData.length(); ++i)
{
QDomElement chDataItem = chData.at(i).toElement();
if( chDataItem.nodeName() == QString( "send" ) )

View File

@@ -144,7 +144,6 @@ void RingBuffer::pop( SampleFrame* dst )
void RingBuffer::read( SampleFrame* dst, f_cnt_t offset )
{
f_cnt_t pos = ( m_position + offset ) % m_size;
if( pos < 0 ) { pos += m_size; }
if( pos + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here
{
@@ -171,7 +170,6 @@ void RingBuffer::read( SampleFrame* dst, float offset )
void RingBuffer::read( SampleFrame* dst, f_cnt_t offset, f_cnt_t length )
{
f_cnt_t pos = ( m_position + offset ) % m_size;
if( pos < 0 ) { pos += m_size; }
if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here
{

View File

@@ -140,12 +140,12 @@ bool Sample::play(SampleFrame* dst, PlaybackState* state, size_t numFrames, floa
= state->resampler().resample(&playBuffer[0][0], playBuffer.size(), &dst[0][0], numFrames, resampleRatio);
advance(state, resampleResult.inputFramesUsed, loopMode);
const auto outputFrames = resampleResult.outputFramesGenerated;
const auto outputFrames = static_cast<f_cnt_t>(resampleResult.outputFramesGenerated);
if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, SampleFrame{}); }
if (!typeInfo<float>::isEqual(m_amplification, 1.0f))
{
for (int i = 0; i < numFrames; ++i)
for (auto i = std::size_t{0}; i < numFrames; ++i)
{
dst[i][0] *= m_amplification;
dst[i][1] *= m_amplification;

View File

@@ -174,7 +174,7 @@ auto decodeSampleOggVorbis(const QString& audioFile) -> std::optional<SampleDeco
}
auto result = std::vector<SampleFrame>(totalSamplesRead / numChannels);
for (int i = 0; i < result.size(); ++i)
for (auto i = std::size_t{0}; i < result.size(); ++i)
{
if (numChannels == 1) { result[i] = {buffer[i], buffer[i]}; }
else if (numChannels > 1) { result[i] = {buffer[i * numChannels], buffer[i * numChannels + 1]}; }

View File

@@ -847,7 +847,7 @@ void Song::clearProject()
stop();
}
for( int i = 0; i < PlayModeCount; i++ )
for (auto i = std::size_t{0}; i < PlayModeCount; i++)
{
setPlayPos( 0, ( PlayMode )i );
}
@@ -1349,7 +1349,7 @@ void Song::restoreScaleStates(const QDomElement &element)
{
QDomNode node = element.firstChild();
for (int i = 0; i < MaxScaleCount && !node.isNull() && !isCancelled(); i++)
for (auto i = std::size_t{0}; i < MaxScaleCount && !node.isNull() && !isCancelled(); i++)
{
m_scales[i]->restoreState(node.toElement());
node = node.nextSibling();
@@ -1374,7 +1374,7 @@ void Song::restoreKeymapStates(const QDomElement &element)
{
QDomNode node = element.firstChild();
for (int i = 0; i < MaxKeymapCount && !node.isNull() && !isCancelled(); i++)
for (auto i = std::size_t{0}; i < MaxKeymapCount && !node.isNull() && !isCancelled(); i++)
{
m_keymaps[i]->restoreState(node.toElement());
node = node.nextSibling();

View File

@@ -388,14 +388,14 @@ int Track::numOfClips()
* \todo if we create a Clip here, should we somehow attach it to the
* track?
*/
Clip * Track::getClip( int clipNum )
auto Track::getClip(std::size_t clipNum) -> Clip*
{
if( clipNum < m_clips.size() )
{
return m_clips[clipNum];
}
printf( "called Track::getClip( %d ), "
"but Clip %d doesn't exist\n", clipNum, clipNum );
printf( "called Track::getClip( %zu ), "
"but Clip %zu doesn't exist\n", clipNum, clipNum );
return createClip( clipNum * TimePos::ticksPerBar() );
}

View File

@@ -99,10 +99,9 @@ AudioOss::AudioOss( bool & _success_ful, AudioEngine* _audioEngine ) :
fcntl( m_audioFD, F_SETFD, fcntl( m_audioFD, F_GETFD ) | FD_CLOEXEC );
int frag_spec;
for( frag_spec = 0; static_cast<int>( 0x01 << frag_spec ) <
audioEngine()->framesPerPeriod() * channels() *
BYTES_PER_INT_SAMPLE;
++frag_spec )
for (frag_spec = 0;
1u << frag_spec < audioEngine()->framesPerPeriod() * channels() * BYTES_PER_INT_SAMPLE;
++frag_spec)
{
}

View File

@@ -229,10 +229,7 @@ void AudioPortAudio::stopProcessing()
}
int AudioPortAudio::process_callback(
const float *_inputBuffer,
float * _outputBuffer,
unsigned long _framesPerBuffer )
int AudioPortAudio::process_callback(const float* _inputBuffer, float* _outputBuffer, f_cnt_t _framesPerBuffer)
{
if( supportsCapture() )
{
@@ -261,8 +258,7 @@ int AudioPortAudio::process_callback(
}
m_outBufSize = frames;
}
const int min_len = std::min(static_cast<int>(_framesPerBuffer),
m_outBufSize - m_outBufPos);
const auto min_len = std::min(_framesPerBuffer, m_outBufSize - m_outBufPos);
for( fpp_t frame = 0; frame < min_len; ++frame )
{

View File

@@ -92,7 +92,7 @@ bool MainApplication::winEventFilter(MSG* msg, long* result)
switch(msg->message)
{
case WM_STYLECHANGING:
if(msg->wParam == GWL_EXSTYLE)
if (msg->wParam == static_cast<WPARAM>(GWL_EXSTYLE))
{
// Prevent plugins making the main window transparent
STYLESTRUCT * style = reinterpret_cast<STYLESTRUCT *>(msg->lParam);

View File

@@ -224,14 +224,14 @@ MicrotunerConfig::MicrotunerConfig() :
*/
void MicrotunerConfig::updateScaleList(int index)
{
if (index >= 0 && index < MaxScaleCount)
if (index >= 0 && static_cast<std::size_t>(index) < MaxScaleCount)
{
m_scaleComboModel.replaceItem(index,
QString::number(index) + ": " + Engine::getSong()->getScale(index)->getDescription());
}
else
{
for (int i = 0; i < MaxScaleCount; i++)
for (auto i = std::size_t{0}; i < MaxScaleCount; i++)
{
m_scaleComboModel.replaceItem(i,
QString::number(i) + ": " + Engine::getSong()->getScale(i)->getDescription());
@@ -246,14 +246,14 @@ void MicrotunerConfig::updateScaleList(int index)
*/
void MicrotunerConfig::updateKeymapList(int index)
{
if (index >= 0 && index < MaxKeymapCount)
if (index >= 0 && static_cast<std::size_t>(index) < MaxKeymapCount)
{
m_keymapComboModel.replaceItem(index,
QString::number(index) + ": " + Engine::getSong()->getKeymap(index)->getDescription());
}
else
{
for (int i = 0; i < MaxKeymapCount; i++)
for (auto i = std::size_t{0}; i < MaxKeymapCount; i++)
{
m_keymapComboModel.replaceItem(i,
QString::number(i) + ": " + Engine::getSong()->getKeymap(i)->getDescription());

View File

@@ -51,12 +51,12 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q
const size_t maxFrames = numPixels * static_cast<size_t>(framesPerPixel);
int pixelIndex = 0;
auto pixelIndex = std::size_t{0};
for (int i = 0; i < maxFrames; i += static_cast<int>(resolution))
for (auto i = std::size_t{0}; i < maxFrames; i += static_cast<std::size_t>(resolution))
{
pixelIndex = i / framesPerPixel;
const int frameIndex = !parameters.reversed ? i : maxFrames - i;
const auto frameIndex = !parameters.reversed ? i : maxFrames - i;
const auto& frame = parameters.buffer[frameIndex];
const auto value = frame.average();
@@ -75,11 +75,11 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q
pixelIndex++;
}
for (int i = 0; i < numPixels; i++)
for (auto i = std::size_t{0}; i < numPixels; i++)
{
const int lineY1 = centerY - max[i] * halfHeight * parameters.amplification;
const int lineY2 = centerY - min[i] * halfHeight * parameters.amplification;
const int lineX = i + x;
const int lineX = static_cast<int>(i) + x;
painter.drawLine(lineX, lineY1, lineX, lineY2);
const float rms = std::sqrt(squared[i] / framesPerResolution);

View File

@@ -534,8 +534,9 @@ DataFile ClipView::createClipDataFiles(
{
// Insert into the dom under the "clips" element
Track* clipTrack = clipView->m_trackView->getTrack();
int trackIndex = std::distance(tc->tracks().begin(), std::find(tc->tracks().begin(), tc->tracks().end(), clipTrack));
assert(trackIndex != tc->tracks().size());
const auto trackIt = std::find(tc->tracks().begin(), tc->tracks().end(), clipTrack);
assert(trackIt != tc->tracks().end());
int trackIndex = std::distance(tc->tracks().begin(), trackIt);
QDomElement clipElement = dataFile.createElement("clip");
clipElement.setAttribute( "trackIndex", trackIndex );
clipElement.setAttribute( "trackType", static_cast<int>(clipTrack->type()) );

View File

@@ -135,10 +135,10 @@ void PatternEditor::dropEvent(QDropEvent* de)
// Ensure pattern clips exist
bool hasValidPatternClips = false;
if (t->getClips().size() == m_ps->numOfPatterns())
if (t->getClips().size() == static_cast<std::size_t>(m_ps->numOfPatterns()))
{
hasValidPatternClips = true;
for (int i = 0; i < t->getClips().size(); ++i)
for (auto i = std::size_t{0}; i < t->getClips().size(); ++i)
{
if (t->getClips()[i]->startPosition() != TimePos(i, 0))
{

View File

@@ -219,7 +219,7 @@ PianoRoll::PianoRoll() :
m_noteEditMenu = new QMenu( this );
m_noteEditMenu->clear();
for( int i = 0; i < m_nemStr.size(); ++i )
for (auto i = std::size_t{0}; i < m_nemStr.size(); ++i)
{
auto act = new QAction(m_nemStr.at(i), this);
connect( act, &QAction::triggered, [this, i](){ changeNoteEditMode(i); } );

View File

@@ -48,7 +48,7 @@ InstrumentSoundShapingView::InstrumentSoundShapingView(QWidget* parent) :
m_targetsTabWidget = new TabWidget(tr("TARGET"), this);
for (int i = 0; i < InstrumentSoundShaping::NumTargets; ++i)
for (auto i = std::size_t{0}; i < InstrumentSoundShaping::NumTargets; ++i)
{
m_envLfoViews[i] = new EnvelopeAndLfoView(m_targetsTabWidget);
m_targetsTabWidget->addTab(m_envLfoViews[i],
@@ -115,7 +115,7 @@ void InstrumentSoundShapingView::modelChanged()
m_filterComboBox->setModel( &m_ss->m_filterModel );
m_filterCutKnob->setModel( &m_ss->m_filterCutModel );
m_filterResKnob->setModel( &m_ss->m_filterResModel );
for( int i = 0; i < InstrumentSoundShaping::NumTargets; ++i )
for (auto i = std::size_t{0}; i < InstrumentSoundShaping::NumTargets; ++i)
{
m_envLfoViews[i]->setModel( m_ss->m_envLfoParameters[i] );
}

View File

@@ -56,7 +56,7 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name,
}
int cbIndex = 0;
for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i )
for (auto i = std::size_t{0}; i < ProjectRenderer::NumFileFormats; ++i)
{
if( ProjectRenderer::fileEncodeDevices[i].isAvailable() )
{
@@ -268,7 +268,7 @@ void ExportProjectDialog::startBtnClicked()
}
// Find proper file extension.
for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i )
for (auto i = std::size_t{0}; i < ProjectRenderer::NumFileFormats; ++i)
{
if (m_ft == ProjectRenderer::fileEncodeDevices[i].m_fileFormat)
{

View File

@@ -413,7 +413,7 @@ bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QMimeData* md
int finalTrackIndex = trackIndex + currentTrackIndex - initialTrackIndex;
// Track must be in TrackContainer's tracks
if( finalTrackIndex < 0 || finalTrackIndex >= tracks.size() )
if (finalTrackIndex < 0 || static_cast<std::size_t>(finalTrackIndex) >= tracks.size())
{
return false;
}

View File

@@ -190,7 +190,7 @@ void Oscilloscope::paintEvent( QPaintEvent * )
otherChannelsColor(); // Any other channel
p.setPen(QPen(color, width));
for( int frame = 0; frame < frames; ++frame )
for (auto frame = std::size_t{0}; frame < frames; ++frame)
{
sample_t const clippedSample = AudioEngine::clip(m_buffer[frame][ch]);
m_points[frame] = QPointF(

View File

@@ -474,7 +474,6 @@ MidiClip * MidiClip::adjacentMidiClipByOffset(int offset) const
{
auto& clips = m_instrumentTrack->getClips();
int clipNum = m_instrumentTrack->getClipNum(this);
if (clipNum < 0 || clipNum > clips.size() - 1) { return nullptr; }
return dynamic_cast<MidiClip*>(clips[clipNum + offset]);
}