Fix C4189 and C4100 Warnings

C4189 is 'Local variable initialised but not used'
C4100 is 'Unreferenced parameter'

Fixed some other warnings, e.g. about empty if, too.
This commit is contained in:
James Crook 2018-10-10 19:09:10 +01:00
parent 66c861315f
commit 657159d542
30 changed files with 82 additions and 53 deletions

View File

@ -585,6 +585,8 @@ void DerivativeOfWindowFunc(int whichFunction, size_t NumSamples, bool extraSamp
// There are deltas at the ends
const double multiplier = 2 * M_PI / NumSamples;
static const double coeff0 = 0.54, coeff1 = -0.46 * multiplier;
// TODO This code should be more explicit about the precision it intends.
// For now we get C4305 warnings, truncation from 'const double' to 'float'
in[0] *= coeff0;
if (!extraSample)
--NumSamples;

View File

@ -2569,7 +2569,7 @@ bool LabelTrack::PasteOver(double t, const Track * src)
if (! result )
// THROW_INCONSISTENCY_EXCEPTION; // ?
;
(void)0;// intentionally do nothing
return result;
}
@ -2587,7 +2587,7 @@ void LabelTrack::Paste(double t, const Track *src)
if ( !bOk )
// THROW_INCONSISTENCY_EXCEPTION; // ?
;
(void)0;// intentionally do nothing
}
// This repeats the labels in a time interval a specified number of times.

View File

@ -332,7 +332,7 @@ bool InvertMatrix(const Matrix& input, Matrix& Minv)
continue;
if (fabs(M[j][i]) > 0) {
// Subtract a multiple of row i from row j
double factor = M[j][i];
factor = M[j][i];
for(unsigned k = 0; k < N; k++) {
M[j][k] -= (M[i][k] * factor);
Minv[j][k] -= (Minv[i][k] * factor);

View File

@ -5702,7 +5702,7 @@ void MenuCommandHandler::OnPaste(const CommandContext &context)
bool bPastedSomething = false;
auto pC = clipTrackRange.begin();
size_t nnChannels, ncChannels;
size_t nnChannels=0, ncChannels=0;
while (*pN && *pC) {
auto n = *pN;
auto c = *pC;
@ -6852,6 +6852,8 @@ void MenuCommandHandler::OnSelectClipBoundary(AudacityProject &project, bool nex
MenuCommandHandler::FoundClip MenuCommandHandler::FindNextClip
(AudacityProject &project, const WaveTrack* wt, double t0, double t1)
{
(void)project;//Compiler food.
FoundClip result{};
result.waveTrack = wt;
const auto clips = wt->SortedClipArray();
@ -6888,6 +6890,8 @@ MenuCommandHandler::FoundClip MenuCommandHandler::FindNextClip
MenuCommandHandler::FoundClip MenuCommandHandler::FindPrevClip
(AudacityProject &project, const WaveTrack* wt, double t0, double t1)
{
(void)project;//Compiler food.
FoundClip result{};
result.waveTrack = wt;
const auto clips = wt->SortedClipArray();
@ -7276,7 +7280,6 @@ void MenuCommandHandler::OnZoomFit(const CommandContext &context)
{
auto &project = context.project;
auto &viewInfo = project.GetViewInfo();
auto &selectedRegion = viewInfo.selectedRegion;
auto tracks = project.GetTracks();
const double start = viewInfo.bScrollBeyondZero
@ -7973,7 +7976,6 @@ void MenuCommandHandler::OnCursorTrackEnd(const CommandContext &context)
auto &selectedRegion = project.GetViewInfo().selectedRegion;
double kWayOverToLeft = std::numeric_limits<double>::lowest();
double thisEndOffset = 0.0;
auto trackRange = tracks->Selected();
if (trackRange.empty())

View File

@ -107,7 +107,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
}
/* create the destination track (NEW track) */
if (numWaves == TrackList::Channels(first).size())
if (numWaves == (int)TrackList::Channels(first).size())
oneinput = true;
// only one input track (either 1 mono or one linked stereo pair)

View File

@ -612,7 +612,7 @@ void NoteTrack::Paste(double t, const Track *src)
if ( !bOk )
// THROW_INCONSISTENCY_EXCEPTION; // ?
;
(void)0;// intentionally do nothing
}
void NoteTrack::Silence(double t0, double t1)

View File

@ -313,7 +313,7 @@ wxAccStatus CheckListAx::GetSelections( wxVariant * WXUNUSED(selections) )
}
// Returns a state constant.
wxAccStatus CheckListAx::GetState( int childId, long *state )
wxAccStatus CheckListAx::GetState( int childId, long *pState )
{
int flag = wxACC_STATE_SYSTEM_FOCUSABLE;
@ -347,7 +347,7 @@ wxAccStatus CheckListAx::GetState( int childId, long *state )
}
}
*state = flag;
*pState = flag;
return wxACC_OK;
}
@ -1947,7 +1947,7 @@ void PluginManager::Load()
}
// Doing the deletion within the search loop risked skipping some items,
// hence the delayed delete.
for (int i = 0; i < groupsToDelete.Count(); i++) {
for (unsigned int i = 0; i < groupsToDelete.Count(); i++) {
registry.DeleteGroup(groupsToDelete[i]);
}
registry.SetPath("");

View File

@ -403,6 +403,7 @@ size_t EnumSetting::Find( const wxString &value ) const
void EnumSetting::Migrate( wxString &value )
{
(void)value;// Compiler food
}
bool EnumSetting::Write( const wxString &value )

View File

@ -128,7 +128,7 @@ void TimeTrack::Paste(double t, const Track * src)
if (! bOk )
// THROW_INCONSISTENCY_EXCEPTION // ?
;
(void)0;// intentionally do nothing.
}
void TimeTrack::Silence(double WXUNUSED(t0), double WXUNUSED(t1))

View File

@ -1899,17 +1899,19 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
}
}
// TODO Add a comment to say what this loop does.
// Possily make it into a subroutine.
for (unsigned ii = 0; ii < nPortions; ++ii) {
WavePortion &portion = portions[ii];
const bool showIndividualSamples = portion.averageZoom > threshold1;
const bool showPoints = portion.averageZoom > threshold2;
wxRect& rect = portion.rect;
rect.Intersect(mid);
wxASSERT(rect.width >= 0);
wxRect& rectPortion = portion.rect;
rectPortion.Intersect(mid);
wxASSERT(rectPortion.width >= 0);
float *useMin = 0, *useMax = 0, *useRms = 0;
int *useBl = 0;
WaveDisplay fisheyeDisplay(rect.width);
WaveDisplay fisheyeDisplay(rectPortion.width);
int skipped = 0, skippedLeft = 0, skippedRight = 0;
if (portion.inFisheye) {
if (!showIndividualSamples) {
@ -1917,12 +1919,12 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
const auto numSamples = clip->GetNumSamples();
// Get wave display data for different magnification
int jj = 0;
for (; jj < rect.width; ++jj) {
for (; jj < rectPortion.width; ++jj) {
const double time =
zoomInfo.PositionToTime(jj, -leftOffset) - tOffset;
const auto sample = (sampleCount)floor(time * rate + 0.5);
if (sample < 0) {
++rect.x;
++rectPortion.x;
++skippedLeft;
continue;
}
@ -1931,9 +1933,9 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
fisheyeDisplay.where[jj - skippedLeft] = sample;
}
skippedRight = rect.width - jj;
skippedRight = rectPortion.width - jj;
skipped = skippedRight + skippedLeft;
rect.width -= skipped;
rectPortion.width -= skipped;
// where needs a sentinel
if (jj > 0)
@ -1941,7 +1943,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
1 + fisheyeDisplay.where[jj - skippedLeft - 1];
fisheyeDisplay.width -= skipped;
// Get a wave display for the fisheye, uncached.
if (rect.width > 0)
if (rectPortion.width > 0)
if (!clip->GetWaveDisplay(
fisheyeDisplay, t0, -1.0, // ignored
isLoadingOD))
@ -1962,9 +1964,9 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
leftOffset += skippedLeft;
if (rect.width > 0) {
if (rectPortion.width > 0) {
if (!showIndividualSamples) {
std::vector<double> vEnv2(rect.width);
std::vector<double> vEnv2(rectPortion.width);
double *const env2 = &vEnv2[0];
clip->GetEnvelope()->GetValues
( tOffset,
@ -1973,8 +1975,8 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
// and then interpolate the display
0, // 1.0 / rate,
env2, rect.width, leftOffset, zoomInfo );
DrawMinMaxRMS(dc, rect, env2,
env2, rectPortion.width, leftOffset, zoomInfo );
DrawMinMaxRMS(dc, rectPortion, env2,
zoomMin, zoomMax,
dB, dBRange,
useMin, useMax, useRms, useBl,
@ -1986,14 +1988,14 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
auto target = dynamic_cast<SampleHandle*>(context.target.get());
highlight = target && target->GetTrack().get() == track;
#endif
DrawIndividualSamples(dc, leftOffset, rect, zoomMin, zoomMax,
DrawIndividualSamples(dc, leftOffset, rectPortion, zoomMin, zoomMax,
dB, dBRange,
clip, zoomInfo,
bigPoints, showPoints, muted, highlight);
}
}
leftOffset += rect.width + skippedRight;
leftOffset += rectPortion.width + skippedRight;
}
if (drawEnvelope) {

View File

@ -1752,6 +1752,7 @@ void TrackPanel::DrawOutside
void TrackPanel::DrawOutsideOfTrack
(TrackPanelDrawingContext &context, const Track * t, const wxRect & rect)
{
(void)t;// Compiler food
auto dc = &context.dc;
// Fill in area outside of the track

View File

@ -24,6 +24,7 @@ TrackPanelResizerCell::TrackPanelResizerCell( std::shared_ptr<Track> pTrack )
std::vector<UIHandlePtr> TrackPanelResizerCell::HitTest
(const TrackPanelMouseState &st, const AudacityProject *pProject)
{
(void)pProject;// Compiler food
std::vector<UIHandlePtr> results;
auto pTrack = mpTrack.lock();
if (pTrack) {

View File

@ -1175,7 +1175,7 @@ void SpecCache::Populate
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (auto xx = lowerBoundX; xx < upperBoundX; ++xx) {
for (xx = lowerBoundX; xx < upperBoundX; ++xx) {
float *const results = &freq[nBins * xx];
for (size_t ii = 0; ii < nBins; ++ii) {
float &power = results[ii];

View File

@ -1360,7 +1360,7 @@ void WaveTrack::Paste(double t0, const Track *src)
if( !bOk )
// THROW_INCONSISTENCY_EXCEPTION; // ?
;
(void)0;// Empty if intentional.
}
void WaveTrack::Silence(double t0, double t1)

View File

@ -107,7 +107,6 @@ int ExecCommand2(wxString *pIn, wxString *pOut)
CommandBuilder builder(*pIn);
if (builder.WasValid())
{
AudacityProject *project = GetActiveProject();
OldStyleCommandPointer cmd = builder.GetCommand();
AppCommandEvent ev;
ev.SetCommand(cmd);

View File

@ -230,6 +230,7 @@ bool SelectTracksCommand::Apply(const CommandContext &context)
// Add 0.01 so we are free of rounding errors in comparisons.
constexpr double fudge = 0.01;
for (auto channel : channels) {
(void)channel;// compiler food
double track = index + fudge + term;
bool sel = first <= track && track <= last;
if( mMode == 0 ){ // Set

View File

@ -345,6 +345,7 @@ void ContrastDialog::OnGetForeground(wxCommandEvent & /*event*/)
AudacityProject *p = GetActiveProject();
for ( auto t : p->GetTracks()->Selected< const WaveTrack >() ) {
(void)t;// Compiler food;
mForegroundStartT->SetValue(p->mViewInfo.selectedRegion.t0());
mForegroundEndT->SetValue(p->mViewInfo.selectedRegion.t1());
}
@ -360,6 +361,7 @@ void ContrastDialog::OnGetBackground(wxCommandEvent & /*event*/)
AudacityProject *p = GetActiveProject();
for ( auto t : p->GetTracks()->Selected< const WaveTrack >() ) {
(void)t;// Compiler food;
mBackgroundStartT->SetValue(p->mViewInfo.selectedRegion.t0());
mBackgroundEndT->SetValue(p->mViewInfo.selectedRegion.t1());
}

View File

@ -194,7 +194,7 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
// PRL: I don't think that matters, the sequence of storage of clips in the track
// is not elsewhere assumed to be by time
{
for (auto it = revClips.rbegin(), end = revClips.rend(); it != end; ++it)
for (auto it = revClips.rbegin(), revEnd = revClips.rend(); it != revEnd; ++it)
track->AddClip(std::move(*it));
}

View File

@ -1838,10 +1838,10 @@ bool LV2Effect::TransferDataToWindow()
return true;
}
for (size_t i = 0, cnt = mGroups.GetCount(); i < cnt; i++)
for (size_t i = 0, groupCount = mGroups.GetCount(); i < GroupCount; i++)
{
const auto & params = mGroupMap[mGroups[i]];
for (size_t pi = 0, cnt = params.size(); pi < cnt; pi++)
for (size_t pi = 0, ParamCount = params.size(); pi < ParamCount; pi++)
{
int p = params[pi];
LV2Port & ctrl = mControls[p];

View File

@ -2134,7 +2134,7 @@ bool NyquistEffect::ParseProgram(wxInputStream & stream)
// The trick is that xgettext will not consider such lines comments
// and will extract the strings they contain
(line[0] == wxT(';') ||
(dollar = (line[0] == wxT('$')))))
((dollar = (line[0] == wxT('$'))))))
{
Tokenizer tzer;
unsigned nLines = 1;

View File

@ -1775,7 +1775,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
if (ofmt->audio_codec == id)
{
wxString ofmtname = wxString::FromUTF8(ofmt->name);
bool found = false;
found = false;
for (unsigned int i = 0; i < FromList.GetCount(); i++)
{
if (ofmtname.Cmp(FromList[i]) == 0)

View File

@ -388,8 +388,10 @@ namespace
break;
case TWINDOW:
NewWindowFunc(windowType, windowSize, extra, window.get() + padding);
for (int ii = padding, multiplier = -(int)windowSize / 2; ii < (int)endOfWindow; ++ii, ++multiplier)
window[ii] *= multiplier;
{
for (int ii = padding, multiplier = -(int)windowSize / 2; ii < (int)endOfWindow; ++ii, ++multiplier)
window[ii] *= multiplier;
}
break;
case DWINDOW:
DerivativeOfWindowFunc(windowType, windowSize, extra, window.get() + padding);

View File

@ -876,6 +876,7 @@ void ToolBar::OnErase( wxEraseEvent & WXUNUSED(event) )
//
void ToolBar::OnPaint( wxPaintEvent & event )
{
(void)event;// compiler food.
//wxPaintDC dc( (wxWindow *) event.GetEventObject() );
wxPaintDC dc( this );
// Start with a clean background

View File

@ -192,12 +192,12 @@ UIHandle::Result StretchHandle::Drag
const wxMouseEvent &event = evt.event;
const int x = event.m_x;
Track *clickedTrack;
Track *clickedTrack=nullptr;
if (evt.pCell)
clickedTrack =
static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack().get();
if (clickedTrack == NULL && mpTrack != NULL)
if (clickedTrack == nullptr && mpTrack != nullptr)
clickedTrack = mpTrack.get();
Stretch(pProject, x, mLeftEdge, clickedTrack);
return RefreshAll;

View File

@ -935,7 +935,6 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &)
Track *const focused = project->GetTrackPanel()->GetFocusedTrack();
const bool hasFocus = channels.contains( focused );
auto first = *channels.begin();
auto partner = *channels.rbegin();
SplitStereo(false);

View File

@ -79,8 +79,8 @@ UIHandlePtr GainSliderHandle::HitTest
if ( TrackInfo::HideTopItem( rect, sliderRect))
return {};
if (sliderRect.Contains(state.m_x, state.m_y)) {
wxRect sliderRect;
TrackInfo::GetGainRect(rect.GetTopLeft(), sliderRect);
wxRect sliderRect2;
TrackInfo::GetGainRect(rect.GetTopLeft(), sliderRect2);
auto sliderFn =
[]( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
return TrackInfo::GainSlider
@ -88,7 +88,7 @@ UIHandlePtr GainSliderHandle::HitTest
const_cast<TrackPanel*>(pProject->GetTrackPanel()));
};
auto result =
std::make_shared<GainSliderHandle>( sliderFn, sliderRect, pTrack );
std::make_shared<GainSliderHandle>( sliderFn, sliderRect2, pTrack );
result = AssignUIHandlePtr(holder, result);
return result;

View File

@ -50,7 +50,7 @@ std::vector<UIHandlePtr> WaveTrack::DetailedHitTest
// Some special targets are not drawn in spectrogram,
// so don't hit them in such views.
else if (isWaveform) {
UIHandlePtr result;
if (NULL != (result = CutlineHandle::HitTest(
mCutlineHandle, st.state, st.rect,
pProject, Pointer<WaveTrack>(this))))

View File

@ -536,6 +536,8 @@ namespace {
const ViewInfo &viewInfo, wxCoord xx, ClipMoveState &state,
double tolerance, double &desiredSlideAmount )
{
(void)xx;// Compiler food
(void)viewInfo;// Compiler food
bool ok = true;
double firstTolerance = tolerance;

View File

@ -988,9 +988,7 @@ bool LWSlider::DoShowDialog(wxPoint pos)
if (pos == wxPoint(-1, -1)) {
dlg.Center();
}
float initialValue = mCurrentValue;
changed = (dlg.ShowModal() == wxID_OK);
if( changed )
value = dlg.Get();

View File

@ -2050,6 +2050,8 @@ public:
(const TrackPanelMouseState &state, const AudacityProject *pProject)
override
{
(void)pProject;// Compiler food
(void)state;// Compiler food
// May come here when recording is in progress, so hit tests are turned
// off.
wxString tooltip;
@ -2068,6 +2070,8 @@ public:
(const wxRect &rect,
wxWindow *pParent, wxPoint *pPosition) final override
{
(void)pParent;// Compiler food
(void)rect;// Compiler food
mParent->ShowContextMenu(mMenuChoice, pPosition);
return 0;
}
@ -2125,6 +2129,7 @@ protected:
Result Cancel(AudacityProject *pProject) override
{
(void)pProject;// Compiler food
return RefreshCode::DrawOverlays;
}
@ -2230,6 +2235,7 @@ protected:
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
{
(void)pProject;// Compiler food
if (event.event.LeftDClick()) {
// Restore default position on double click
TracksPrefs::SetPinnedHeadPositionPreference( 0.5, true );
@ -2255,6 +2261,9 @@ protected:
(const TrackPanelMouseState &state, const AudacityProject *pProject)
override
{
(void)pProject;// Compiler food
(void)state;// Compiler food
static wxCursor cursor{ wxCURSOR_SIZEWE };
return {
_( "Click and drag to adjust, double-click to reset" ),
@ -2274,6 +2283,7 @@ protected:
Result Cancel(AudacityProject *pProject) override
{
(void)pProject;// Compiler food
TracksPrefs::SetPinnedHeadPositionPreference( mOrigPreference );
return RefreshCode::DrawOverlays;
}
@ -2328,12 +2338,14 @@ std::vector<UIHandlePtr> AdornedRulerPanel::QPCell::HitTest
auto xx = state.state.m_x;
#ifdef EXPERIMENTAL_DRAGGABLE_PLAY_HEAD
// Allow click and drag on the play head even while recording
// Make this handle more prominent then the quick play handle
auto result = PlayheadHandle::HitTest( pProject, xx );
if (result) {
result = AssignUIHandlePtr( mPlayheadHolder, result );
results.push_back( result );
{
// Allow click and drag on the play head even while recording
// Make this handle more prominent then the quick play handle
auto result = PlayheadHandle::HitTest( pProject, xx );
if (result) {
result = AssignUIHandlePtr( mPlayheadHolder, result );
results.push_back( result );
}
}
#endif
@ -2461,6 +2473,7 @@ std::vector<UIHandlePtr> AdornedRulerPanel::ScrubbingCell::HitTest
(const TrackPanelMouseState &state,
const AudacityProject *pProject)
{
(void)pProject;// Compiler food
// Creation of overlays on demand here -- constructor of AdornedRulerPanel
// is too early to do it
mParent->CreateOverlays();
@ -3037,6 +3050,7 @@ auto AdornedRulerPanel::ScrubbingHandle::Preview
(const TrackPanelMouseState &state, const AudacityProject *pProject)
-> HitTestPreview
{
(void)state;// Compiler food
const auto &scrubber = pProject->GetScrubber();
auto message = ScrubbingMessage(scrubber, mClicked == Button::Left);
@ -3789,6 +3803,8 @@ void AdornedRulerPanel::ProcessUIHandleResult
(TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell,
unsigned refreshResult)
{
(void)pLatestCell;// Compiler food
(void)pClickedTrack;// Compiler food
if (refreshResult & RefreshCode::DrawOverlays)
DrawBothOverlays();
}