From 60bcd7aea2cbfeffdc3093926ef5e9ca4b8eabb9 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 26 Feb 2016 14:41:17 -0500 Subject: [PATCH 1/5] Fix warnings for unused variables and functions --- src/AudacityApp.cpp | 2 ++ src/AudioIO.cpp | 1 + src/Menus.cpp | 2 ++ src/Project.cpp | 1 + src/Sequence.cpp | 2 ++ src/TrackArtist.cpp | 2 +- src/WaveTrack.cpp | 7 +++++++ src/blockfile/ODDecodeBlockFile.cpp | 1 + src/blockfile/SimpleBlockFile.cpp | 1 + src/commands/CommandManager.cpp | 4 ---- src/effects/Effect.cpp | 1 + src/effects/Effect.h | 3 +++ src/effects/Equalization.cpp | 1 + src/effects/NoiseReduction.cpp | 1 + src/effects/SBSMSEffect.cpp | 1 + src/effects/VST/VSTControlGTK.cpp | 2 ++ src/effects/ladspa/LadspaEffect.cpp | 3 +++ src/import/ImportFLAC.cpp | 1 + src/import/ImportOGG.cpp | 6 ++++++ src/prefs/WaveformSettings.cpp | 4 +--- src/toolbars/ControlToolBar.cpp | 1 + src/widgets/Meter.cpp | 5 +++++ 22 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 7c1739f9a..d3a6f4283 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -236,6 +236,7 @@ It handles initialization and termination by subclassing wxApp. DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE); DEFINE_EVENT_TYPE(EVT_LANGUAGE_CHANGE); +#if 0 #ifdef __WXGTK__ static void wxOnAssert(const wxChar *fileName, int lineNumber, const wxChar *msg) { @@ -252,6 +253,7 @@ static void wxOnAssert(const wxChar *fileName, int lineNumber, const wxChar *msg exit(0); } #endif +#endif static bool gInited = false; bool gIsQuitting = false; diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 9c6cf22c7..7cc7fac73 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -2332,6 +2332,7 @@ void AudioIO::StopStream() else bResult = track->InsertSilence(mT0, recordingOffset); // put silence in wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); } else { // recording into a NEW track diff --git a/src/Menus.cpp b/src/Menus.cpp index 1e430d01f..5fcd80ccf 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -4156,6 +4156,7 @@ void AudacityProject::OnPaste() tmp = mTrackFactory->NewWaveTrack( ((WaveTrack*)n)->GetSampleFormat(), ((WaveTrack*)n)->GetRate()); bool bResult = tmp->InsertSilence(0.0, msClipT1 - msClipT0); // MJS: Is this correct? wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); tmp->Flush(); bPastedSomething |= @@ -4292,6 +4293,7 @@ bool AudacityProject::HandlePasteNothingSelected() bool bResult = pNewTrack->Paste(0.0, pClip); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); mTracks->Add(pNewTrack); pNewTrack->SetSelected(true); diff --git a/src/Project.cpp b/src/Project.cpp index 8f30b22bb..f0a63746f 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -4658,6 +4658,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action ) bool bResult = merged->Paste( 0.0 , dest ); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); delete dest; } } diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 3a8ba1afd..6fc1c740d 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -418,11 +418,13 @@ bool Sequence::Copy(sampleCount s0, sampleCount s1, Sequence **dest) return false; int numBlocks = mBlock.size(); + int b0 = FindBlock(s0); const int b1 = FindBlock(s1 - 1); wxASSERT(b0 >= 0); wxASSERT(b0 < numBlocks); wxASSERT(b1 < numBlocks); + wxUnusedVar(numBlocks); wxASSERT(b0 <= b1); *dest = new Sequence(mDirManager, mSampleFormat); diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 2defc4b98..b15c5db9f 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -835,7 +835,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect) float minFreq, maxFreq; wt->GetSpectrumBounds(&minFreq, &maxFreq); - switch (wt->GetSpectrogramSettings().scaleType) { + switch (settings.scaleType) { default: wxASSERT(false); case SpectrogramSettings::stLinear: diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 6f65d7f45..34ab313b0 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -912,6 +912,7 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear if (i > 0) { bool bResult = MergeClips(GetClipIndex(clips[i - 1]), GetClipIndex(clip)); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); } break; } @@ -931,6 +932,7 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear if (i < clips.GetCount() - 1) { bool bResult = MergeClips(GetClipIndex(clip), GetClipIndex(clips[i + 1])); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); } break; } @@ -1170,9 +1172,11 @@ bool WaveTrack::SyncLockAdjust(double oldT1, double newT1) bool bResult = tmp->InsertSilence(0.0, newT1 - oldT1); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); tmp->Flush(); bResult = Paste(oldT1, tmp); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); delete tmp; } } @@ -1241,6 +1245,7 @@ bool WaveTrack::Paste(double t0, Track *src) Cut(t0, GetEndTime()+1.0/mRate, &tmp); bool bResult = Paste(t0 + insertDuration, tmp); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); delete tmp; } } else @@ -1545,12 +1550,14 @@ bool WaveTrack::Join(double t0, double t1) //printf("Adding %.6f seconds of silence\n"); bool bResult = newClip->InsertSilence(t, addedSilence); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); t += addedSilence; } //printf("Pasting at %.6f\n", t); bool bResult = newClip->Paste(t, clip); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); t = newClip->GetEndTime(); mClips.DeleteObject(clip); diff --git a/src/blockfile/ODDecodeBlockFile.cpp b/src/blockfile/ODDecodeBlockFile.cpp index b8380e20a..36d039f3e 100644 --- a/src/blockfile/ODDecodeBlockFile.cpp +++ b/src/blockfile/ODDecodeBlockFile.cpp @@ -339,6 +339,7 @@ int ODDecodeBlockFile::WriteODDecodeBlockFile() mFormat, NULL);//summaryData); wxASSERT(bSuccess); // TODO: Handle failure here by alert to user and undo partial op. + wxUnusedVar(bSuccess); mFileNameMutex.Unlock(); diff --git a/src/blockfile/SimpleBlockFile.cpp b/src/blockfile/SimpleBlockFile.cpp index 36335c340..fd5ad5751 100644 --- a/src/blockfile/SimpleBlockFile.cpp +++ b/src/blockfile/SimpleBlockFile.cpp @@ -111,6 +111,7 @@ SimpleBlockFile::SimpleBlockFile(wxFileName baseFileName, { bool bSuccess = WriteSimpleBlockFile(sampleData, sampleLen, format, NULL); wxASSERT(bSuccess); // TODO: Handle failure here by alert to user and undo partial op. + wxUnusedVar(bSuccess); } if (useCache) { diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index 577cd2d1d..734152b52 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -971,8 +971,6 @@ void CommandManager::Enable(const wxString &name, bool enabled) void CommandManager::EnableUsingFlags(wxUint32 flags, wxUint32 mask) { - unsigned int i; - for(const auto &entry : mCommandList) { if (entry->multi && entry->index != 0) continue; @@ -1158,8 +1156,6 @@ bool CommandManager::HandleMenuID(int id, wxUint32 flags, wxUint32 mask) /// code to run. bool CommandManager::HandleTextualCommand(wxString & Str, wxUint32 flags, wxUint32 mask) { - unsigned int i; - // Linear search for now... for (const auto &entry : mCommandList) { diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 85421630a..de2b8be4c 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1731,6 +1731,7 @@ bool Effect::ProcessTrack(int count, return false; } wxASSERT(processed == curBlockSize); + wxUnusedVar(processed); // Bump to next input buffer position if (inputRemaining) diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 363c4f505..b56997978 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -684,6 +684,9 @@ inline long TrapLong(long x, long min, long max) #define ReadBasic(type, name) \ type name; \ + wxUnusedVar(MIN_ ##name); \ + wxUnusedVar(MAX_ ##name); \ + wxUnusedVar(SCL_ ##name); \ if (!parms.ReadAndVerify(KEY_ ## name, &name, DEF_ ## name)) \ return false; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 3947a202e..ec88ffc84 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -1204,6 +1204,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t, //put the processed audio in bool bResult = t->Paste(clipStartEndTimes[i].first, toClipOutput); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); //if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this //This is not true when the selection is fully contained within one clip (second half of conditional) if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first || diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index c42afe57c..6fc1b643a 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -1336,6 +1336,7 @@ bool EffectNoiseReduction::Worker::ProcessOne outputTrack->HandleClear(tLen, outputTrack->GetEndTime(), false, false); bool bResult = track->ClearAndPaste(t0, t0 + tLen, &*outputTrack, true, false); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); } return bLoopSuccess; diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index 6682e8979..fe9c813a9 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -416,6 +416,7 @@ bool EffectSBSMS::Process() leftTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputLeftTrack, true, false, GetTimeWarper()); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); if(rightTrack) { diff --git a/src/effects/VST/VSTControlGTK.cpp b/src/effects/VST/VSTControlGTK.cpp index f4b447c8a..cfe1a6020 100644 --- a/src/effects/VST/VSTControlGTK.cpp +++ b/src/effects/VST/VSTControlGTK.cpp @@ -13,11 +13,13 @@ #include "VSTControl.h" +#if 0 static int trappedErrorCode = 0; static int X11TrapHandler(Display *, XErrorEvent *err) { return 0; } +#endif VSTControl::VSTControl() : VSTControlBase() diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 826c9a317..1f18ba841 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1409,6 +1409,8 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) wxString bound; float lower = 0.0; float upper = 1.0; + + /* bool haslo = false; bool hashi = false; bool forceint = false; @@ -1431,6 +1433,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) upper *= mSampleRate; forceint = true; } + */ // Limit to the UI precision lower = ceilf(lower * 1000000.0) / 1000000.0; diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 74dc8c713..4c22afd6b 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -476,6 +476,7 @@ int FLACImportFileHandle::Import(TrackFactory *trackFactory, if(!useOD) res = (mFile->process_until_end_of_stream() != 0); #endif + wxUnusedVar(res); //add the task to the ODManager if(useOD) diff --git a/src/import/ImportOGG.cpp b/src/import/ImportOGG.cpp index 5bb3971d9..a90919e6d 100644 --- a/src/import/ImportOGG.cpp +++ b/src/import/ImportOGG.cpp @@ -173,6 +173,12 @@ wxString OggImportPlugin::GetPluginFormatDescription() ImportFileHandle *OggImportPlugin::Open(const wxString &filename) { + // Suppress some compiler warnings about unused global variables in the library header + wxUnusedVar(OV_CALLBACKS_DEFAULT); + wxUnusedVar(OV_CALLBACKS_NOCLOSE); + wxUnusedVar(OV_CALLBACKS_STREAMONLY); + wxUnusedVar(OV_CALLBACKS_STREAMONLY_NOCLOSE); + OggVorbis_File *vorbisFile = new OggVorbis_File; wxFFile *file = new wxFFile(filename, wxT("rb")); diff --git a/src/prefs/WaveformSettings.cpp b/src/prefs/WaveformSettings.cpp index c86a86da9..af9402409 100644 --- a/src/prefs/WaveformSettings.cpp +++ b/src/prefs/WaveformSettings.cpp @@ -70,10 +70,8 @@ WaveformSettings& WaveformSettings::defaults() return instance; } -bool WaveformSettings::Validate(bool quiet) +bool WaveformSettings::Validate(bool /* quiet */) { - quiet; - scaleType = ScaleType( std::max(0, std::min(int(stNumScaleTypes) - 1, int(scaleType))) ); diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 35a268fa1..ebec43aaa 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -889,6 +889,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt) wt->Clear(t1, t0); bool bResult = wt->Paste(t1, newTrack); wxASSERT(bResult); // TO DO: Actually handle this. + wxUnusedVar(bResult); delete newTrack; } newRecordingTracks.Add(wt); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index d27bba583..77721c2f5 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -237,6 +237,11 @@ Meter::Meter(AudacityProject *project, mIcon(NULL), mAccSilent(false) { + // Suppress warnings about the header file + wxUnusedVar(SpeakerMenu_xpm); + wxUnusedVar(MicMenu_xpm); + wxUnusedVar(PrefStyles); + mStyle = mDesiredStyle; mIsFocused = false; From 1398d1a9532b4491c547d0931a938ba7315cb77c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 26 Feb 2016 14:41:45 -0500 Subject: [PATCH 2/5] Fix warnings for ambiguous else --- src/DirManager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DirManager.cpp b/src/DirManager.cpp index 5e6232db9..7c71d2cc8 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -583,7 +583,9 @@ wxFileName DirManager::MakeBlockFilePath(const wxString &value) { dir.AppendDir(middir); if(!dir.DirExists() && !dir.Mkdir(0777,wxPATH_MKDIR_FULL)) + { // need braces to avoid compiler warning about ambiguous else, see the macro wxLogSysError(_("mkdir in DirManager::MakeBlockFilePath failed.")); + } } return dir; } @@ -1219,8 +1221,10 @@ bool DirManager::EnsureSafeFilename(wxFileName fName) wxFile testFile(renamedFileName.GetFullPath(), wxFile::write); if (!testFile.IsOpened()) { - wxLogSysError(_("Unable to open/create test file."), + { // need braces to avoid compiler warning about ambiguous else, see the macro + wxLogSysError(_("Unable to open/create test file."), renamedFileName.GetFullPath().c_str()); + } return false; } @@ -1229,8 +1233,10 @@ bool DirManager::EnsureSafeFilename(wxFileName fName) if (!wxRemoveFile(renamedFileName.GetFullPath())) { /* i18n-hint: %s is the name of a file.*/ - wxLogSysError(_("Unable to remove '%s'."), + { // need braces to avoid compiler warning about ambiguous else, see the macro + wxLogSysError(_("Unable to remove '%s'."), renamedFileName.GetFullPath().c_str()); + } return false; } From dfc84d030c3fbe10bb587419f2a18d46627c8765 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 26 Feb 2016 14:43:33 -0500 Subject: [PATCH 3/5] Fix warnings for out-of-order initializers, with in-class member initializers --- src/Menus.h | 2 +- src/Project.cpp | 40 +---------------- src/Project.h | 74 +++++++++++++++---------------- src/Sequence.cpp | 4 -- src/Sequence.h | 4 +- src/prefs/PrefsDialog.cpp | 2 - src/prefs/PrefsDialog.h | 4 +- src/prefs/SpectrogramSettings.cpp | 12 ++--- src/prefs/SpectrogramSettings.h | 8 ++-- 9 files changed, 51 insertions(+), 99 deletions(-) diff --git a/src/Menus.h b/src/Menus.h index f6ead01bd..1497b894d 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -327,7 +327,7 @@ void OnMixAndRenderToNewTrack(); void HandleMixAndRender(bool toNewTrack); private: -SelectedRegion mRegionSave; + SelectedRegion mRegionSave{}; public: void OnSelectionSave(); void OnSelectionRestore(); diff --git a/src/Project.cpp b/src/Project.cpp index f0a63746f..f123fa901 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -789,8 +789,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size) : wxFrame(parent, id, wxT("Audacity"), pos, size), - mRegionSave(), - mLastPlayMode(normalPlay), mRate((double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), AudioIO::GetOptimalSupportedSampleRate())), mDefaultFormat((sampleFormat) gPrefs-> Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample)), @@ -799,43 +797,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))), mBandwidthSelectionFormatName(gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT(""))), mUndoManager(safenew UndoManager), - mDirty(false), - mRuler(NULL), - mTrackPanel(NULL), - mTrackFactory(NULL), - mAutoScrolling(false), - mActive(true), - mHistoryWindow(NULL), - mLyricsWindow(NULL), - mMixerBoard(NULL), - mMixerBoardFrame(NULL), - mFreqWindow(NULL), - mContrastDialog(NULL), - mAliasMissingWarningDialog(NULL), - mPlaybackMeter(NULL), - mCaptureMeter(NULL), - mToolManager(NULL), - mbBusyImporting(false), - mAudioIOToken(-1), - mIsDeleting(false), - mTracksFitVerticallyZoomed(false), //lda - mShowId3Dialog(true), //lda - mLastFocusedWindow(NULL), - mKeyboardCaptureHandler(NULL), - mImportXMLTagHandler(NULL), - mAutoSaving(false), - mIsRecovered(false), - mIsCapturing(false), - mRecordingRecoveryHandler(NULL), - mImportedDependencies(false), - mWantSaveCompressed(false), - mLastEffect(wxEmptyString), - mTimerRecordCanceled(false), - mMenuClose(false), - mShownOnce(false), - mbInitializingScrollbar(false), - mViewInfo(0.0, 1.0, ZoomInfo::GetDefaultZoom()), - mIsBeingDeleted(false) + mViewInfo(0.0, 1.0, ZoomInfo::GetDefaultZoom()) { // Note that the first field of the status bar is a dummy, and it's width is set // to zero latter in the code. This field is needed for wxWidgets 2.8.12 because diff --git a/src/Project.h b/src/Project.h index 505477e46..7003409f9 100644 --- a/src/Project.h +++ b/src/Project.h @@ -473,7 +473,7 @@ public: void WriteXMLHeader(XMLWriter &xmlFile); - PlayMode mLastPlayMode; + PlayMode mLastPlayMode{ normalPlay }; ViewInfo mViewInfo; // Audio IO callback methods @@ -553,7 +553,7 @@ public: // History/Undo manager std::unique_ptr mUndoManager; - bool mDirty; + bool mDirty{ false }; // Commands @@ -568,39 +568,39 @@ public: wxStatusBar *mStatusBar; - AdornedRulerPanel *mRuler; - TrackPanel *mTrackPanel; - TrackFactory *mTrackFactory; + AdornedRulerPanel *mRuler{}; + TrackPanel *mTrackPanel{}; + TrackFactory *mTrackFactory{}; wxPanel * mMainPanel; wxScrollBar *mHsbar; wxScrollBar *mVsbar; - bool mAutoScrolling; - bool mActive; + bool mAutoScrolling{ false }; + bool mActive{ true }; bool mIconized; - HistoryWindow *mHistoryWindow; - LyricsWindow* mLyricsWindow; - MixerBoard* mMixerBoard; - MixerBoardFrame* mMixerBoardFrame; + HistoryWindow *mHistoryWindow{}; + LyricsWindow* mLyricsWindow{}; + MixerBoard* mMixerBoard{}; + MixerBoardFrame* mMixerBoardFrame{}; - FreqWindow *mFreqWindow; - ContrastDialog *mContrastDialog; + FreqWindow *mFreqWindow{}; + ContrastDialog *mContrastDialog{}; // dialog for missing alias warnings - wxDialog *mAliasMissingWarningDialog; + wxDialog *mAliasMissingWarningDialog{}; - bool mShownOnce; + bool mShownOnce{ false }; // Project owned meters - Meter *mPlaybackMeter; - Meter *mCaptureMeter; + Meter *mPlaybackMeter{}; + Meter *mCaptureMeter{}; public: - ToolManager *mToolManager; + ToolManager *mToolManager{}; bool mShowSplashScreen; wxString mHelpPref; wxString mSoloPref; - bool mbBusyImporting; // used to fix bug 584 + bool mbBusyImporting{ false }; // used to fix bug 584 void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; } wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; } @@ -615,12 +615,12 @@ public: #define kAudacitySortByName (1 << 2) void SortTracks(int flags); - int mAudioIOToken; + int mAudioIOToken{ -1 }; - bool mIsDeleting; - bool mTracksFitVerticallyZoomed; //lda + bool mIsDeleting{ false }; + bool mTracksFitVerticallyZoomed{ false }; //lda bool mNormalizeOnLoad; //lda - bool mShowId3Dialog; //lda + bool mShowId3Dialog{ true }; //lda bool mEmptyCanBeDirty; bool mSelectAllOnNone; @@ -630,33 +630,33 @@ public: bool mLockPlayRegion; // See AudacityProject::OnActivate() for an explanation of this. - wxWindow *mLastFocusedWindow; + wxWindow *mLastFocusedWindow{}; - ImportXMLTagHandler* mImportXMLTagHandler; + ImportXMLTagHandler* mImportXMLTagHandler{}; // Last auto-save file name and path (empty if none) wxString mAutoSaveFileName; // Are we currently auto-saving or not? - bool mAutoSaving; + bool mAutoSaving{ false }; // Has this project been recovered from an auto-saved version - bool mIsRecovered; + bool mIsRecovered{ false }; // The auto-save data dir the project has been recovered from wxString mRecoveryAutoSaveDataDir; // The handler that handles recovery of tags - RecordingRecoveryHandler* mRecordingRecoveryHandler; + RecordingRecoveryHandler* mRecordingRecoveryHandler{}; // Dependencies have been imported and a warning should be shown on save - bool mImportedDependencies; + bool mImportedDependencies{ false }; - bool mWantSaveCompressed; + bool mWantSaveCompressed{ false }; wxArrayString mStrOtherNamesArray; // used to make sure compressed file names are unique // Last effect applied to this project - PluginID mLastEffect; + PluginID mLastEffect{}; // The screenshot class needs to access internals friend class ScreenshotCommand; @@ -664,18 +664,18 @@ public: wxRect mNormalizedWindowState; //flag for cancellation of timer record. - bool mTimerRecordCanceled; + bool mTimerRecordCanceled{ false }; // Are we currently closing as the result of a menu command? - bool mMenuClose; + bool mMenuClose{ false }; - bool mbInitializingScrollbar; + bool mbInitializingScrollbar{ false }; // Flag that we're recoding. - bool mIsCapturing; + bool mIsCapturing{ false }; // Keyboard capture - wxWindow *mKeyboardCaptureHandler; + wxWindow *mKeyboardCaptureHandler{}; double mSeekShort; double mSeekLong; @@ -683,7 +683,7 @@ public: wxLongLong mLastSelectionAdjustment; // See explanation in OnCloseWindow - bool mIsBeingDeleted; + bool mIsBeingDeleted{ false }; // CommandManager needs to use private methods friend class CommandManager; diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 6fc1c740d..096244cfa 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -55,10 +55,8 @@ int Sequence::sMaxDiskBlockSize = 1048576; Sequence::Sequence(DirManager * projDirManager, sampleFormat format) : mDirManager(projDirManager) , mSampleFormat(format) - , mNumSamples(0) , mMinSamples(sMaxDiskBlockSize / SAMPLE_SIZE(mSampleFormat) / 2) , mMaxSamples(mMinSamples * 2) - , mErrorOpening(false) { mDirManager->Ref(); } @@ -68,11 +66,9 @@ Sequence::Sequence(DirManager * projDirManager, sampleFormat format) // from one project to another Sequence::Sequence(const Sequence &orig, DirManager *projDirManager) : mDirManager(projDirManager) - , mNumSamples(0) , mSampleFormat(orig.mSampleFormat) , mMinSamples(orig.mMinSamples) , mMaxSamples(orig.mMaxSamples) - , mErrorOpening(false) { mDirManager->Ref(); diff --git a/src/Sequence.h b/src/Sequence.h index 1cfd0bd6c..1749bf6f0 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -222,12 +222,12 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{ BlockArray mBlock; sampleFormat mSampleFormat; - sampleCount mNumSamples; + sampleCount mNumSamples{ 0 }; sampleCount mMinSamples; // min samples per block sampleCount mMaxSamples; // max samples per block - bool mErrorOpening; + bool mErrorOpening{ false }; ///To block the Delete() method against the ODCalcSummaryTask::Update() method ODLock mDeleteUpdateMutex; diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index b61d32460..cf2903217 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -204,8 +204,6 @@ PrefsDialog::PrefsDialog wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , mFactories(factories) -, mCategories(NULL) -, mUniquePage(NULL) , mTitlePrefix(titlePrefix) { wxASSERT(factories.size() > 0); diff --git a/src/prefs/PrefsDialog.h b/src/prefs/PrefsDialog.h index 7e2f7bb06..7550d5862 100644 --- a/src/prefs/PrefsDialog.h +++ b/src/prefs/PrefsDialog.h @@ -76,8 +76,8 @@ class PrefsDialog /* not final */ : public wxDialog private: void RecordExpansionState(); - wxTreebook *mCategories; - PrefsPanel *mUniquePage; + wxTreebook *mCategories{}; + PrefsPanel *mUniquePage{}; Factories &mFactories; const wxString mTitlePrefix; diff --git a/src/prefs/SpectrogramSettings.cpp b/src/prefs/SpectrogramSettings.cpp index 31d6e68f6..8f80a290b 100644 --- a/src/prefs/SpectrogramSettings.cpp +++ b/src/prefs/SpectrogramSettings.cpp @@ -57,10 +57,6 @@ SpectrogramSettings::Globals } SpectrogramSettings::SpectrogramSettings() - : hFFT(0) - , window(0) - , dWindow(0) - , tWindow(0) { LoadPrefs(); } @@ -93,10 +89,10 @@ SpectrogramSettings::SpectrogramSettings(const SpectrogramSettings &other) #endif // Do not copy these! - , hFFT(0) - , window(0) - , tWindow(0) - , dWindow(0) + , hFFT{} + , window{} + , tWindow{} + , dWindow{} { } diff --git a/src/prefs/SpectrogramSettings.h b/src/prefs/SpectrogramSettings.h index d5a66eaf0..b51e8a505 100644 --- a/src/prefs/SpectrogramSettings.h +++ b/src/prefs/SpectrogramSettings.h @@ -139,12 +139,12 @@ public: #ifdef EXPERIMENTAL_USE_REALFFTF // Variables used for computing the spectrum - mutable FFTParam *hFFT; - mutable float *window; + mutable FFTParam *hFFT{}; + mutable float *window{}; // Two other windows for computing reassigned spectrogram - mutable float *tWindow; // Window times time parameter - mutable float *dWindow; // Derivative of window + mutable float *tWindow{}; // Window times time parameter + mutable float *dWindow{}; // Derivative of window #endif }; From 3cc4754ac7bed10e6ace906a10a9705b20b113f5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 26 Feb 2016 14:44:31 -0500 Subject: [PATCH 4/5] Fix warnings for nonexhaustive switches on enumerations --- src/TrackArtist.cpp | 2 ++ src/export/ExportFFmpeg.cpp | 6 ++++++ src/import/ImportFLAC.cpp | 3 +++ src/ondemand/ODDecodeFlacTask.cpp | 3 +++ 4 files changed, 14 insertions(+) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index b15c5db9f..941c5ce01 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -471,6 +471,8 @@ void TrackArtist::DrawTrack(const Track * t, case WaveTrack::Spectrum: DrawSpectrum(wt, dc, rect, selectedRegion, zoomInfo); break; + default: + wxASSERT(false); } #if defined(__WXMAC__) diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index f310d1e09..c1f577f36 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -589,6 +589,12 @@ static int encode_audio(AVCodecContext *avctx, AVPacket *pkt, int16_t *audio_sam case AV_SAMPLE_FMT_FLTP: ((float*)(frame->data[ch]))[i] = audio_samples[ch + i*avctx->channels] / 32767.; break; + case AV_SAMPLE_FMT_NONE: + case AV_SAMPLE_FMT_DBL: + case AV_SAMPLE_FMT_DBLP: + case AV_SAMPLE_FMT_NB: + wxASSERT(false); + break; } } } diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 4c22afd6b..2003456b1 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -215,6 +215,9 @@ void MyFLACFile::metadata_callback(const FLAC__StreamMetadata *metadata) case FLAC__METADATA_TYPE_PICTURE: // ignore pictures case FLAC__METADATA_TYPE_UNDEFINED: // do nothing with this either break; + + case FLAC__MAX_METADATA_TYPE: // suppress compiler warning + wxASSERT(false); } } diff --git a/src/ondemand/ODDecodeFlacTask.cpp b/src/ondemand/ODDecodeFlacTask.cpp index b42fffa1d..7b2277d8c 100644 --- a/src/ondemand/ODDecodeFlacTask.cpp +++ b/src/ondemand/ODDecodeFlacTask.cpp @@ -79,6 +79,9 @@ void ODFLACFile::metadata_callback(const FLAC__StreamMetadata *metadata) case FLAC__METADATA_TYPE_PICTURE: // ignore pictures case FLAC__METADATA_TYPE_UNDEFINED: // do nothing with this either break; + + case FLAC__MAX_METADATA_TYPE: // suppress compiler warning + break; } } From 60f2322055756e8cacfe96530a12c63e9694482c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 26 Feb 2016 14:45:09 -0500 Subject: [PATCH 5/5] Fix warnings for returning false instead of null --- src/effects/vamp/LoadVamp.cpp | 2 +- src/import/ImportFLAC.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index 2c73e1d73..038a26f85 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -266,7 +266,7 @@ Plugin *VampEffectsModule::FindPlugin(const wxString & path, Plugin *vp = PluginLoader::getInstance()->loadPlugin(key, 48000); // rate doesn't matter here if (!vp) { - return false; + return nullptr; } // We limit the listed plugin outputs to those whose results can diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index 2003456b1..84be29987 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -299,7 +299,7 @@ ImportFileHandle *FLACImportPlugin::Open(const wxString &filename) int cnt; wxFile binaryFile; if (!binaryFile.Open(filename)) { - return false; // File not found + return nullptr; // File not found } #ifdef USE_LIBID3TAG @@ -316,7 +316,7 @@ ImportFileHandle *FLACImportPlugin::Open(const wxString &filename) if (cnt == wxInvalidOffset || strncmp(buf, FLAC_HEADER, 4) != 0) { // File is not a FLAC file - return false; + return nullptr; } // Open the file for import @@ -325,7 +325,7 @@ ImportFileHandle *FLACImportPlugin::Open(const wxString &filename) bool success = handle->Init(); if (!success) { delete handle; - return NULL; + return nullptr; } return handle;