Skip to content

Commit

Permalink
Fix MSVC warnings up to level 2 (LMMS#7329)
Browse files Browse the repository at this point in the history
* Fix MSVC warnings up to /W2

* Fix large shift UB warning
  • Loading branch information
DomClark authored Jun 22, 2024
1 parent 26646c6 commit a1f7753
Show file tree
Hide file tree
Showing 44 changed files with 215 additions and 217 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ jobs:
--toolchain C:/vcpkg/scripts/buildsystems/vcpkg.cmake `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DUSE_COMPILE_CACHE=ON `
-DUSE_WERROR=ON `
-DVCPKG_TARGET_TRIPLET="${{ matrix.arch }}-windows" `
-DVCPKG_HOST_TRIPLET="${{ matrix.arch }}-windows" `
-DVCPKG_MANIFEST_INSTALL="${{ env.should_install_manifest }}"
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ elseif(MSVC)
"/external:W0" # Don't emit warnings for third-party code
"/external:anglebrackets" # Consider headers included with angle brackets to be third-party
"/external:templates-" # Still emit warnings from first-party instantiations of third-party templates
# Silence "class X needs to have DLL-interface to be used by clients of
# class Y" warnings. These aren't trivial to address, and don't pose a
# problem for us since we build all modules with the same compiler and
# options, and dynamically link the CRT.
"/wd4251"
)
set(THIRD_PARTY_COMPILE_ERROR_FLAGS
"/W0" # Disable all warnings
Expand Down
2 changes: 1 addition & 1 deletion plugins/CarlaBase/Carla.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class CarlaParamFloatModel : public FloatModel
{
public:
CarlaParamFloatModel(Model * parent):
FloatModel(0.0, 0.0, 1.0, 0.001, parent, "Unused"),
FloatModel(0.f, 0.f, 1.f, 0.001f, parent, "Unused"),
m_isOutput(false),
m_isEnabled(false)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/Compressor/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace lmms
{


constexpr float COMP_LOG = -2.2;
constexpr float COMP_LOG = -2.2f;

class CompressorEffect : public Effect
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/Compressor/CompressorControlDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class QLabel;
namespace lmms
{

constexpr float COMP_NOISE_FLOOR = 0.000001;// -120 dbFs
constexpr float COMP_NOISE_FLOOR = 0.000001f;// -120 dbFs

class CompressorControls;

Expand Down
12 changes: 6 additions & 6 deletions plugins/Delay/DelayControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ namespace lmms
DelayControls::DelayControls( DelayEffect* effect ):
EffectControls( effect ),
m_effect ( effect ),
m_delayTimeModel( 0.5, 0.01, 5.0, 0.0001, 5000.0, this, tr( "Delay samples" )) ,
m_feedbackModel(0.0f,0.0f,1.0f,0.01f,this,tr( "Feedback" ) ),
m_lfoTimeModel(2.0, 0.01, 5.0, 0.0001, 20000.0, this, tr( "LFO frequency" ) ),
m_lfoAmountModel(0.0, 0.0, 0.5, 0.0001, 2000.0, this, tr ( "LFO amount" ) ),
m_outGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) )
m_delayTimeModel(0.5f, 0.01f, 5.f, 0.0001f, 5000.f, this, tr("Delay samples")) ,
m_feedbackModel(0.0f, 0.0f, 1.0f, 0.01f, this, tr("Feedback")),
m_lfoTimeModel(2.f, 0.01f, 5.f, 0.0001f, 20000.f, this, tr("LFO frequency")),
m_lfoAmountModel(0.f, 0.f, 0.5f, 0.0001f, 2000.f, this, tr("LFO amount")),
m_outGainModel(0.f, -60.f, 20.f, 0.01f, this, tr("Output gain"))
{
connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) );
m_outPeakL = 0.0;
Expand Down Expand Up @@ -77,4 +77,4 @@ void DelayControls::changeSampleRate()
}


} // namespace lmms
} // namespace lmms
6 changes: 3 additions & 3 deletions plugins/Delay/StereoDelay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace lmms
StereoDelay::StereoDelay( int maxTime, int sampleRate )
{
m_buffer = 0;
m_maxTime = maxTime;
m_maxTime = static_cast<float>(maxTime);
m_maxLength = maxTime * sampleRate;
m_length = m_maxLength;
m_length = static_cast<float>(m_maxLength);

m_writeIndex = 0;
m_feedback = 0.0f;
Expand All @@ -58,7 +58,7 @@ StereoDelay::~StereoDelay()
void StereoDelay::tick( sampleFrame& frame )
{
m_writeIndex = ( m_writeIndex + 1 ) % ( int )m_maxLength;
int readIndex = m_writeIndex - m_length;
int readIndex = m_writeIndex - static_cast<int>(m_length);
if (readIndex < 0 ) { readIndex += m_maxLength; }
float lOut = m_buffer[ readIndex ][ 0 ];
float rOut = m_buffer[ readIndex ] [1 ];
Expand Down
6 changes: 3 additions & 3 deletions plugins/Dispersion/DispersionControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ DispersionControls::DispersionControls(DispersionEffect* effect) :
EffectControls(effect),
m_effect(effect),
m_amountModel(0, 0, MAX_DISPERSION_FILTERS, this, tr("Amount")),
m_freqModel(200, 20, 20000, 0.001, this, tr("Frequency")),
m_resoModel(0.707, 0.01, 8, 0.0001, this, tr("Resonance")),
m_feedbackModel(0.f, -1.f, 1.f, 0.0001, this, tr("Feedback")),
m_freqModel(200, 20, 20000, 0.001f, this, tr("Frequency")),
m_resoModel(0.707f, 0.01f, 8, 0.0001f, this, tr("Resonance")),
m_feedbackModel(0.f, -1.f, 1.f, 0.0001f, this, tr("Feedback")),
m_dcModel(false, this, tr("DC Offset Removal"))
{
m_freqModel.setScaleLogarithmic(true);
Expand Down
4 changes: 2 additions & 2 deletions plugins/DualFilter/DualFilterControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) :
m_enabled1Model( true, this, tr( "Filter 1 enabled" ) ),
m_filter1Model( this, tr( "Filter 1 type" ) ),
m_cut1Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff frequency 1" ) ),
m_res1Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 1" ) ),
m_res1Model(0.5f, BasicFilters<>::minQ(), 10.f, 0.01f, this, tr("Q/Resonance 1")),
m_gain1Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 1" ) ),

m_mixModel( 0.0f, -1.0f, 1.0f, 0.01f, this, tr( "Mix" ) ),

m_enabled2Model( true, this, tr( "Filter 2 enabled" ) ),
m_filter2Model( this, tr( "Filter 2 type" ) ),
m_cut2Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff frequency 2" ) ),
m_res2Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 2" ) ),
m_res2Model(0.5f, BasicFilters<>::minQ(), 10.f, 0.01f, this, tr("Q/Resonance 2")),
m_gain2Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 2" ) )
{
m_filter1Model.addItem( tr( "Low-pass" ), std::make_unique<PixmapLoader>( "filter_lp" ) );
Expand Down
48 changes: 24 additions & 24 deletions plugins/Eq/EqControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@ namespace lmms
EqControls::EqControls( EqEffect *effect ) :
EffectControls( effect ),
m_effect( effect ),
m_inGainModel( 0.0, -60.0, 20.0, 0.01, this, tr( "Input gain") ),
m_outGainModel( -.0, -60.0, 20.0, 0.01, this, tr( "Output gain" ) ),
m_lowShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "Low-shelf gain" ) ),
m_para1GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 1 gain" ) ),
m_para2GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 2 gain" ) ),
m_para3GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 3 gain" ) ),
m_para4GainModel( 0.0 , -18, 18, 0.001, this, tr( "Peak 4 gain" ) ),
m_highShelfGainModel( 0.0 , -18, 18, 0.001, this, tr( "High-shelf gain" ) ),
m_hpResModel( 0.707,0.003, 10.0 , 0.001, this, tr( "HP res" ) ),
m_lowShelfResModel( 0.707, 0.55, 10.0 , 0.001, this , tr( "Low-shelf res" ) ),
m_para1BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 1 BW" ) ),
m_para2BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 2 BW" ) ),
m_para3BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 3 BW" ) ),
m_para4BwModel( 0.3, 0.1, 4 , 0.001, this , tr( "Peak 4 BW" ) ),
m_highShelfResModel( 0.707, 0.55, 10.0 , 0.001, this , tr( "High-shelf res" ) ),
m_lpResModel( 0.707,0.003, 10.0 , 0.001, this , tr( "LP res" ) ),
m_hpFeqModel( 31.0, 20.0, 20000, 0.001, this , tr( "HP freq" ) ),
m_lowShelfFreqModel( 80.0, 20.0, 20000, 0.001, this , tr( "Low-shelf freq" ) ),
m_para1FreqModel( 120.0, 20.0, 20000, 0.001, this , tr( "Peak 1 freq" ) ),
m_para2FreqModel( 250.0, 20.0, 20000, 0.001, this, tr( "Peak 2 freq" ) ),
m_para3FreqModel( 2000.0, 20.0, 20000, 0.001, this , tr( "Peak 3 freq" ) ),
m_para4FreqModel( 4000.0, 20.0, 20000, 0.001, this , tr( "Peak 4 freq" ) ),
m_highShelfFreqModel( 12000.0, 20.0, 20000, 0.001, this , tr( "High-shelf freq" ) ),
m_lpFreqModel( 18000.0, 20.0, 20000, 0.001, this , tr( "LP freq" ) ),
m_inGainModel(0.f, -60.f, 20.f, 0.01f, this, tr("Input gain")),
m_outGainModel(-0.f, -60.f, 20.f, 0.01f, this, tr("Output gain")),
m_lowShelfGainModel( 0.f, -18, 18, 0.001f, this, tr("Low-shelf gain")),
m_para1GainModel(0.f, -18, 18, 0.001f, this, tr("Peak 1 gain")),
m_para2GainModel(0.f, -18, 18, 0.001f, this, tr("Peak 2 gain")),
m_para3GainModel(0.f, -18, 18, 0.001f, this, tr("Peak 3 gain")),
m_para4GainModel(0.f, -18, 18, 0.001f, this, tr("Peak 4 gain")),
m_highShelfGainModel(0.f, -18, 18, 0.001f, this, tr("High-shelf gain")),
m_hpResModel(0.707f,0.003f, 10.f, 0.001f, this, tr("HP res")),
m_lowShelfResModel(0.707f, 0.55f, 10.f, 0.001f, this, tr("Low-shelf res")),
m_para1BwModel(0.3f, 0.1f, 4, 0.001f, this, tr("Peak 1 BW")),
m_para2BwModel(0.3f, 0.1f, 4, 0.001f, this, tr("Peak 2 BW")),
m_para3BwModel(0.3f, 0.1f, 4, 0.001f, this, tr("Peak 3 BW")),
m_para4BwModel(0.3f, 0.1f, 4, 0.001f, this, tr("Peak 4 BW")),
m_highShelfResModel(0.707f, 0.55f, 10.f, 0.001f, this, tr("High-shelf res")),
m_lpResModel(0.707f,0.003f, 10.f, 0.001f, this, tr("LP res")),
m_hpFeqModel(31.f, 20.f, 20000, 0.001f, this, tr("HP freq")),
m_lowShelfFreqModel(80.f, 20.f, 20000, 0.001f, this, tr("Low-shelf freq")),
m_para1FreqModel(120.f, 20.f, 20000, 0.001f, this, tr("Peak 1 freq")),
m_para2FreqModel(250.f, 20.f, 20000, 0.001f, this, tr("Peak 2 freq")),
m_para3FreqModel(2000.f, 20.f, 20000, 0.001f, this, tr("Peak 3 freq")),
m_para4FreqModel(4000.f, 20.f, 20000, 0.001f, this, tr("Peak 4 freq")),
m_highShelfFreqModel(12000.f, 20.f, 20000, 0.001f, this, tr("High-shelf freq")),
m_lpFreqModel(18000.f, 20.f, 20000, 0.001f, this, tr("LP freq")),
m_hpActiveModel( false, this , tr( "HP active" ) ),
m_lowShelfActiveModel( false, this , tr( "Low-shelf active" ) ),
m_para1ActiveModel( false, this , tr( "Peak 1 active" ) ),
Expand Down
11 changes: 1 addition & 10 deletions plugins/Eq/EqCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,17 +581,8 @@ void EqHandle::wheelEvent( QGraphicsSceneWheelEvent *wevent )

if( wevent->orientation() == Qt::Vertical )
{
m_resonance = m_resonance + ( numSteps );
m_resonance = std::clamp(m_resonance + numSteps, 0.1f, highestBandwich);

if( m_resonance < 0.1 )
{
m_resonance = 0.1;
}

if( m_resonance > highestBandwich )
{
m_resonance = highestBandwich;
}
emit positionChanged();
}
wevent->accept();
Expand Down
2 changes: 1 addition & 1 deletion plugins/Eq/EqFader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private slots:
{
const float opl = getPeak_L();
const float opr = getPeak_R();
const float fallOff = 1.07;
const float fallOff = 1.07f;
if( *m_lPeak > opl )
{
setPeak_L( *m_lPeak );
Expand Down
12 changes: 6 additions & 6 deletions plugins/Eq/EqSpectrumView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ EqAnalyser::EqAnalyser() :

//initialize Blackman-Harris window, constants taken from
//https://en.wikipedia.org/wiki/Window_function#A_list_of_window_functions
const float a0 = 0.35875;
const float a1 = 0.48829;
const float a2 = 0.14128;
const float a3 = 0.01168;
const float a0 = 0.35875f;
const float a1 = 0.48829f;
const float a2 = 0.14128f;
const float a3 = 0.01168f;

for (int i = 0; i < FFT_BUFFER_SIZE; i++)
{
Expand Down Expand Up @@ -230,7 +230,7 @@ void EqSpectrumView::paintEvent(QPaintEvent *event)
float *bands = m_analyser->m_bands;
m_path.moveTo( 0, height() );
m_peakSum = 0;
const float fallOff = 1.07;
const float fallOff = 1.07f;
for( int x = 0; x < MAX_BANDS; ++x, ++bands )
{
float peak = *bands != 0. ? (fh * 2.0 / 3.0 * (20. * log10(*bands / energy) - LOWER_Y) / (-LOWER_Y)) : 0.;
Expand Down Expand Up @@ -305,4 +305,4 @@ void EqSpectrumView::periodicalUpdate()

} // namespace gui

} // namespace lmms
} // namespace lmms
12 changes: 6 additions & 6 deletions plugins/Flanger/FlangerControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ namespace lmms
FlangerControls::FlangerControls( FlangerEffect *effect ) :
EffectControls ( effect ),
m_effect ( effect ),
m_delayTimeModel(0.001, 0.0001, 0.050, 0.0001, this, tr( "Delay samples" ) ),
m_lfoFrequencyModel( 0.25, 0.01, 60, 0.0001, 60000.0, this, tr( "LFO frequency" ) ),
m_lfoAmountModel( 0.0, 0.0, 0.0025, 0.0001, this, tr( "Amount" ) ),
m_lfoPhaseModel( 90.0, 0.0, 360.0, 0.0001, this, tr( "Stereo phase" ) ),
m_feedbackModel( 0.0, -1.0, 1.0, 0.0001, this, tr( "Feedback" ) ),
m_whiteNoiseAmountModel( 0.0, 0.0, 0.05, 0.0001, this, tr( "Noise" ) ),
m_delayTimeModel(0.001f, 0.0001f, 0.050f, 0.0001f, this, tr("Delay samples")),
m_lfoFrequencyModel(0.25f, 0.01f, 60, 0.0001f, 60000.f, this, tr("LFO frequency")),
m_lfoAmountModel(0.f, 0.f, 0.0025f, 0.0001f, this, tr("Amount")),
m_lfoPhaseModel(90.f, 0.f, 360.f, 0.0001f, this, tr("Stereo phase")),
m_feedbackModel(0.f, -1.f, 1.f, 0.0001f, this, tr("Feedback")),
m_whiteNoiseAmountModel(0.f, 0.f, 0.05f, 0.0001f, this, tr("Noise")),
m_invertFeedbackModel ( false, this, tr( "Invert" ) )

{
Expand Down
6 changes: 3 additions & 3 deletions plugins/Flanger/MonoDelay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace lmms
MonoDelay::MonoDelay( int maxTime , int sampleRate )
{
m_buffer = 0;
m_maxTime = maxTime;
m_maxTime = static_cast<float>(maxTime);
m_maxLength = maxTime * sampleRate;
m_length = m_maxLength;
m_length = static_cast<float>(m_maxLength);

m_writeIndex = 0;
m_feedback = 0.0f;
Expand All @@ -57,7 +57,7 @@ MonoDelay::~MonoDelay()
void MonoDelay::tick( sample_t* sample )
{
m_writeIndex = ( m_writeIndex + 1 ) % ( int )m_maxLength;
int readIndex = m_writeIndex - m_length;
int readIndex = m_writeIndex - static_cast<int>(m_length);
if (readIndex < 0 ) { readIndex += m_maxLength; }
float out = m_buffer[ readIndex ];
m_buffer[ m_writeIndex ] = *sample + ( out * m_feedback );
Expand Down
6 changes: 3 additions & 3 deletions plugins/LOMM/LOMM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ LOMMEffect::LOMMEffect(Model* parent, const Descriptor::SubPluginFeatures::Key*
m_hp2(m_sampleRate),
m_ap(m_sampleRate),
m_needsUpdate(true),
m_coeffPrecalc(-0.05),
m_crestTimeConst(0.999),
m_coeffPrecalc(-0.05f),
m_crestTimeConst(0.999f),
m_lookWrite(0),
m_lookBufLength(2)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ bool LOMMEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
{
m_lp1.setLowpass(m_lommControls.m_split1Model.value());
m_hp1.setHighpass(m_lommControls.m_split1Model.value());
m_ap.calcFilterCoeffs(m_lommControls.m_split1Model.value(), 0.70710678118);
m_ap.calcFilterCoeffs(m_lommControls.m_split1Model.value(), 0.70710678118f);
}
if (m_needsUpdate || m_lommControls.m_split2Model.isValueChanged())
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/LOMM/LOMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace lmms
{

constexpr inline float LOMM_MIN_FLOOR = 0.00012589;// -72 dBFS
constexpr inline float LOMM_MIN_FLOOR = 0.00012589f;// -72 dBFS
constexpr inline float LOMM_MAX_LOOKAHEAD = 20.f;
constexpr inline float LOMM_AUTO_TIME_ADJUST = 5.f;

Expand Down
Loading

0 comments on commit a1f7753

Please sign in to comment.