Clean up most remaining MSVC warnings.

This commit is contained in:
James Crook 2018-01-06 13:03:48 +00:00
parent b2f8cf180f
commit d2fe7b1757
21 changed files with 685 additions and 667 deletions

View File

@ -0,0 +1,8 @@
// -*- mode: c++ -*-
// Indirectly include Allegro header so that we can disable warnings about unused parameters
// when compiling Audacity itself.
#pragma warning( push )
#pragma warning( disable : 4100)
#include "../portsmf/allegro.h"
#pragma warning( pop )

View File

@ -0,0 +1,8 @@
// -*- mode: c++ -*-
// Indirectly include SBSMS header so that we can disable warnings about unused parameters
// when compiling Audacity itself.
#pragma warning( push )
#pragma warning( disable : 4100)
#include "../sbsms/include/sbsms.h"
#pragma warning( pop )

View File

@ -1063,6 +1063,10 @@ void AudacityApp::OnFatalException()
exit(-1);
}
#pragma warning( push )
#pragma warning( disable : 4702) // unreachable code warning.
bool AudacityApp::OnExceptionInMainLoop()
{
// This function is invoked from catch blocks in the wxWidgets framework,
@ -1099,10 +1103,10 @@ bool AudacityApp::OnExceptionInMainLoop()
// Let the inherited function do throw; again and whatever else it does.
return wxApp::OnExceptionInMainLoop();
}
// Shouldn't ever reach this line
return false;
}
#pragma warning( pop )
#if defined(EXPERIMENTAL_CRASH_REPORT)
void AudacityApp::GenerateCrashReport(wxDebugReport::Context ctx)

View File

@ -29,7 +29,7 @@
#include "../lib-src/portmidi/pm_common/portmidi.h"
#include "../lib-src/portmidi/porttime/porttime.h"
#include <cstring> // Allegro include fails if this header isn't included do to no memcpy
#include "../lib-src/portsmf/allegro.h"
#include "../lib-src/header-substitutes/allegro.h"
class NoteTrack;
using NoteTrackArray = std::vector < NoteTrack* >;

View File

@ -556,7 +556,7 @@ size_t BlockFile::CommonReadData(
else {
auto channels = info.channels;
wxASSERT(channels >= 1);
wxASSERT(channel < channels);
wxASSERT(channel < (unsigned int)channels);
if (channels == 1 &&
format == int16Sample &&

View File

@ -67,7 +67,7 @@ bool Envelope::ConsistencyCheck()
for ( size_t ii = 0, count = mEnv.size(); ii < count; ) {
// Find range of points with equal T
const double thisT = mEnv[ii].GetT();
double nextT;
double nextT = 0.0f;
auto nextI = ii + 1;
while ( nextI < count && thisT == ( nextT = mEnv[nextI].GetT() ) )
++nextI;
@ -1080,7 +1080,7 @@ void Envelope::SetTrackLen( double trackLen, double sampleDur )
// Preserve the left-side limit at trackLen.
auto range = EqualRange( trackLen, sampleDur );
bool needPoint = ( range.first == range.second && trackLen < mTrackLen );
double value;
double value=0.0;
if ( needPoint )
value = GetValueRelative( trackLen );
@ -1344,7 +1344,7 @@ void Envelope::GetValues
// Getting many envelope values, corresponding to pixel columns, which may
// not be uniformly spaced in time when there is a fisheye.
double prevDiscreteTime, prevSampleVal, nextSampleVal;
double prevDiscreteTime=0.0, prevSampleVal=0.0, nextSampleVal=0.0;
for ( int xx = 0; xx < bufferLen; ++xx ) {
auto time = zoomInfo.PositionToTime( xx, -leftOffset );
if ( sampleDur <= 0 )

View File

@ -357,8 +357,9 @@ const wxChar *WindowFuncName(int whichFunction)
}
}
void NewWindowFunc(int whichFunction, size_t NumSamples, bool extraSample, float *in)
void NewWindowFunc(int whichFunction, size_t NumSamplesIn, bool extraSample, float *in)
{
int NumSamples = (int)NumSamplesIn;
if (extraSample) {
wxASSERT(NumSamples > 0);
--NumSamples;
@ -533,7 +534,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
wxASSERT(NumSamples > 0);
--NumSamples;
// in[0] *= 1.0f;
for (int ii = 1; ii < NumSamples; ++ii)
for (int ii = 1; ii < (int)NumSamples; ++ii)
in[ii] = 0.0f;
in[NumSamples] *= -1.0f;
return;
@ -585,7 +586,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
in[0] *= coeff0;
if (!extraSample)
--NumSamples;
for (int ii = 0; ii < NumSamples; ++ii)
for (int ii = 0; ii < (int)NumSamples; ++ii)
in[ii] *= - coeff1 * sin(ii * multiplier);
if (extraSample)
in[NumSamples] *= - coeff0;
@ -599,7 +600,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
// Hanning
const double multiplier = 2 * M_PI / NumSamples;
const double coeff1 = -0.5 * multiplier;
for (int ii = 0; ii < NumSamples; ++ii)
for (int ii = 0; ii < (int)NumSamples; ++ii)
in[ii] *= - coeff1 * sin(ii * multiplier);
if (extraSample)
in[NumSamples] = 0.0f;
@ -611,7 +612,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
const double multiplier = 2 * M_PI / NumSamples;
const double multiplier2 = 2 * multiplier;
const double coeff1 = -0.5 * multiplier, coeff2 = 0.08 * multiplier2;
for (int ii = 0; ii < NumSamples; ++ii)
for (int ii = 0; ii < (int)NumSamples; ++ii)
in[ii] *= - coeff1 * sin(ii * multiplier) - coeff2 * sin(ii * multiplier2);
if (extraSample)
in[NumSamples] = 0.0f;
@ -625,7 +626,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
const double multiplier3 = 3 * multiplier;
const double coeff1 = -0.48829 * multiplier,
coeff2 = 0.14128 * multiplier2, coeff3 = -0.01168 * multiplier3;
for (int ii = 0; ii < NumSamples; ++ii)
for (int ii = 0; ii < (int)NumSamples; ++ii)
in[ii] *= - coeff1 * sin(ii * multiplier) - coeff2 * sin(ii * multiplier2) - coeff3 * sin(ii * multiplier3);
if (extraSample)
in[NumSamples] = 0.0f;
@ -636,7 +637,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
// Welch
const float N = NumSamples;
const float NN = NumSamples * NumSamples;
for (int ii = 0; ii < NumSamples; ++ii) {
for (int ii = 0; ii < (int)NumSamples; ++ii) {
in[ii] *= 4 * (N - ii - ii) / NN;
}
if (extraSample)
@ -668,7 +669,7 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
in[0] *= exp(A * 0.25) * (1 - invN);
if (!extraSample)
--NumSamples;
for (int ii = 1; ii < NumSamples; ++ii) {
for (int ii = 1; ii < (int)NumSamples; ++ii) {
const float iOverN = ii * invN;
in[ii] *= exp(A * (0.25 + (iOverN * iOverN) - iOverN)) * (2 * ii * invNN - invN);
}

View File

@ -20,7 +20,7 @@
#if defined(USE_MIDI)
#include "allegro.h"
#include "../lib-src/header-substitutes/allegro.h"
// define this switch to play MIDI during redisplay to sonify run times
// Note that if SONIFY is defined, the default MIDI device will be opened

View File

@ -420,7 +420,7 @@ std::unique_ptr<Sequence> Sequence::Copy(sampleCount s0, sampleCount s1) const
// Nonnegative result is length of block0 or less:
blocklen =
( std::min(s1, block0.start + file->GetLength()) - s0 ).as_size_t();
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
wxASSERT(file->IsAlias() || (blocklen <= (int)mMaxSamples)); // Vaughan, 2012-02-29
ensureSampleBufferSize(buffer, mSampleFormat, bufferSize, blocklen);
Get(b0, buffer.ptr(), mSampleFormat, s0, blocklen, true);
@ -440,7 +440,7 @@ std::unique_ptr<Sequence> Sequence::Copy(sampleCount s0, sampleCount s1) const
const auto &file = block.f;
// s1 is within block:
blocklen = (s1 - block.start).as_size_t();
wxASSERT(file->IsAlias() || (blocklen <= mMaxSamples)); // Vaughan, 2012-02-29
wxASSERT(file->IsAlias() || (blocklen <= (int)mMaxSamples)); // Vaughan, 2012-02-29
if (blocklen < (int)file->GetLength()) {
ensureSampleBufferSize(buffer, mSampleFormat, bufferSize, blocklen);
Get(b1, buffer.ptr(), mSampleFormat, block.start, blocklen, true);

View File

@ -2581,7 +2581,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
}
else {
int specIndex = (xx - fisheyeLeft) * nBins;
wxASSERT(specIndex >= 0 && specIndex < specCache.freq.size());
wxASSERT(specIndex >= 0 && specIndex < (int)specCache.freq.size());
uncached = &specCache.freq[specIndex];
}

View File

@ -21,20 +21,17 @@ class wxDC;
// MSVC 2013 says this can't be instantiated - but in fact it can
// using {} syntax.
// As it's a bogus warning caused by a bug in MSVC2013, it's Ok to disable it.
#pragma warning( push )
#pragma warning( disable : 4510)
#pragma warning( disable : 4610)
struct TrackPanelDrawingContext {
wxDC &dc;
UIHandlePtr target;
wxMouseState lastState;
// MSVC 2013 has a bug and reports
// warning C4610: struct 'TrackPanelDrawingContext'
// can never be instantiated
#ifdef _MSC_VER
// Add a default initialiser here to workaround that?
//TrackPanelDrawingContext();
#endif
};
#pragma warning( pop )
#endif

View File

@ -126,19 +126,19 @@ public:
//if they are both off the cache boundary in the same direction, the cache is missed,
//so we are safe, and don't need to track this one.
if((invalStart<0 && invalEnd <0) || (invalStart>=len && invalEnd >= len))
if((invalStart<0 && invalEnd <0) || (invalStart>=(long)len && invalEnd >= (long)len))
return;
//in all other cases, we need to clip the boundries so they make sense with the cache.
//for some reason, the cache is set up to access up to array[len], not array[len-1]
if(invalStart <0)
invalStart =0;
else if(invalStart > len)
else if((size_t)invalStart > len)
invalStart = len;
if(invalEnd <0)
invalEnd =0;
else if(invalEnd > len)
else if((size_t)invalEnd > len)
invalEnd = len;
@ -153,13 +153,13 @@ public:
{
//if the regions intersect OR are pixel adjacent
InvalidRegion &region = mRegions[i];
if(region.start <= invalEnd+1
&& region.end + 1 >= invalStart)
if(region.start <= (size_t)(invalEnd+1)
&& (region.end + 1) >= (size_t)invalStart)
{
//take the union region
if(region.start > invalStart)
if(region.start > (size_t)invalStart)
region.start = invalStart;
if(region.end < invalEnd)
if((int)region.end < invalEnd)
region.end = invalEnd;
added=true;
break;
@ -206,7 +206,7 @@ public:
}
//if we are past the end of the region we added, we are past the area of regions that might be oversecting.
if(region.start > invalEnd)
if(invalEnd < 0 || region.start > (size_t)invalEnd)
{
break;
}
@ -842,7 +842,7 @@ bool SpecCache::CalculateOneSpectrum
from = sampleCount(
where[0].as_double() + xx * (rate / pixelsPerSecond)
);
else if (xx > len)
else if ((size_t)xx > len)
from = sampleCount(
where[len].as_double() + (xx - len) * (rate / pixelsPerSecond)
);
@ -857,7 +857,7 @@ bool SpecCache::CalculateOneSpectrum
auto nBins = settings.NBins();
if (from < 0 || from >= numSamples) {
if (xx >= 0 && xx < len) {
if (xx >= 0 && xx < (int)len) {
// Pixel column is out of bounds of the clip! Should not happen.
float *const results = &out[nBins * xx];
std::fill(results, results + nBins, 0.0f);
@ -1276,8 +1276,8 @@ bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache,
// old cache doesn't match. It won't happen in resize, since the
// spectrum view is pinned to left side of window.
wxASSERT(
(copyBegin >= 0 && copyEnd == numPixels) || // copied the end
(copyBegin == 0 && copyEnd <= numPixels) // copied the beginning
(copyBegin >= 0 && copyEnd == (int)numPixels) || // copied the end
(copyBegin == 0 && copyEnd <= (int)numPixels) // copied the beginning
);
int zeroBegin = copyBegin > 0 ? 0 : copyEnd-copyBegin;

View File

@ -21,7 +21,6 @@ the pitch without changing the tempo.
#include "ChangePitch.h"
#if USE_SBSMS
#include "sbsms.h"
#include <wx/valgen.h>
#endif

View File

@ -20,7 +20,7 @@
#if USE_SOUNDTOUCH
#if USE_SBSMS
#include "sbsms.h"
#include "../../../lib-src/header-substitutes/sbsms.h"
#include <wx/valgen.h>
#endif

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@
#define __AUDACITY_EFFECT_SBSMS__
#include "Effect.h"
#include "../../../lib-src/header-substitutes/sbsms.h"
#include "sbsms.h"
using namespace _sbsms_;
class LabelTrack;

View File

@ -26,8 +26,6 @@
#include "../ShuttleGui.h"
#include "../widgets/valnum.h"
#include "sbsms.h"
enum
{
ID_RatePercentChangeStart = 10000,

View File

@ -203,7 +203,7 @@ NoteTrackVRulerMenuTable &NoteTrackVRulerMenuTable::Instance()
return instance;
}
void NoteTrackVRulerMenuTable::InitMenu(Menu *pMenu, void *pUserData)
void NoteTrackVRulerMenuTable::InitMenu(Menu *WXUNUSED(pMenu), void *pUserData)
{
mpData = static_cast<InitMenuData*>(pUserData);
}
@ -247,7 +247,7 @@ UIHandle::Result NoteTrackVZoomHandle::Release
return RefreshNone;
const wxMouseEvent &event = evt.event;
const bool shiftDown = event.ShiftDown();
//const bool shiftDown = event.ShiftDown();
const bool rightUp = event.RightUp();

View File

@ -131,7 +131,7 @@ public:
// Convenience wrapper for the above
template<void (Scrubber::*pfn)(const CommandContext&)>
void Thunk(wxCommandEvent &dummy)
void Thunk(wxCommandEvent &)
{ (this->*pfn)(*GetActiveProject()); }
// A string to put in the leftmost part of the status bar

View File

@ -16,7 +16,7 @@
void wxTabTraversalWrapperCharHook(wxKeyEvent &event);
template <typename Base>
class wxTabTraversalWrapper : public Base
class AUDACITY_DLL_API wxTabTraversalWrapper : public Base
{
public:
template <typename... Args>
@ -32,7 +32,7 @@ public:
}
};
class wxPanelWrapper : public wxTabTraversalWrapper<wxPanel>
class AUDACITY_DLL_API wxPanelWrapper : public wxTabTraversalWrapper<wxPanel>
{
public:
// Constructors

View File

@ -121,7 +121,7 @@ bool XMLValueChecker::IsGoodIntForRange(const wxString & strInt, const wxString
if( lenStrInt < 1 )
return false;
int offset = (strInt[0] == '-') ?1:0;
size_t offset = (strInt[0] == '-') ?1:0;
if( lenStrInt <= offset )
return false;// string too short, no digits in it.
@ -134,7 +134,7 @@ bool XMLValueChecker::IsGoodIntForRange(const wxString & strInt, const wxString
return false; // not a digit
// All chars were digits.
if( (lenStrInt - offset) < lenMAXABS )
if( lenStrInt < (lenMAXABS + offset) )
return true; // too few digits to overflow.
// Numerical part is same length as strMAXABS