From 8a7877f9d1ef9936856f4a37306d146919c8ca36 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Mon, 14 Mar 2011 15:30:04 -0400 Subject: [PATCH] More warning fixes. RageThreads.h is right now clear of Effective Violations. It may be worth studying. --- src/InputMapper.h | 20 +++++----------- src/RageSoundManager.cpp | 7 ++---- src/RageSoundReader_Preload.cpp | 3 ++- src/RageTexture.cpp | 15 ++++-------- src/RageTextureManager.cpp | 11 ++++----- src/RageThreads.cpp | 35 ++++++++-------------------- src/RageThreads.h | 21 +++++++++++++++++ src/RageUtil_AutoPtr.h | 13 ++++------- src/Trail.h | 10 ++++++-- src/arch/InputHandler/InputHandler.h | 2 +- 10 files changed, 63 insertions(+), 74 deletions(-) diff --git a/src/InputMapper.h b/src/InputMapper.h index 25f86c996c..cceaf2a5bf 100644 --- a/src/InputMapper.h +++ b/src/InputMapper.h @@ -12,20 +12,12 @@ const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2; struct AutoMappingEntry { - AutoMappingEntry( int i, DeviceButton db, GameButton gb, bool b ) - { - m_iSlotIndex = i; - m_deviceButton = db; - m_gb = gb; - m_bSecondController = b; - } - AutoMappingEntry() - { - m_iSlotIndex = -1; - m_deviceButton = DeviceButton_Invalid; - m_gb = GameButton_Invalid; - m_bSecondController = false; - } + AutoMappingEntry( int i, DeviceButton db, GameButton gb, bool b ): + m_iSlotIndex(i), m_deviceButton(db), + m_gb(gb), m_bSecondController(b) {} + AutoMappingEntry(): m_iSlotIndex(-1), + m_deviceButton(DeviceButton_Invalid), m_gb(GameButton_Invalid), + m_bSecondController(false) {} bool IsEmpty() const { return m_deviceButton == DeviceButton_Invalid && m_gb == GameButton_Invalid; } int m_iSlotIndex; diff --git a/src/RageSoundManager.cpp b/src/RageSoundManager.cpp index a389f9d641..77034bd1e0 100644 --- a/src/RageSoundManager.cpp +++ b/src/RageSoundManager.cpp @@ -35,11 +35,8 @@ static Preference g_sSoundDrivers( "SoundDrivers", "" ); // "" == DEFAU RageSoundManager *SOUNDMAN = NULL; -RageSoundManager::RageSoundManager() -{ - m_fMixVolume = 1.0f; - m_fVolumeOfNonCriticalSounds = 1.0f; -} +RageSoundManager::RageSoundManager(): m_pDriver(NULL), m_fMixVolume(1.0f), + m_fVolumeOfNonCriticalSounds(1.0f) {} static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" ); void RageSoundManager::Init() diff --git a/src/RageSoundReader_Preload.cpp b/src/RageSoundReader_Preload.cpp index 04dae7c10b..2358681331 100644 --- a/src/RageSoundReader_Preload.cpp +++ b/src/RageSoundReader_Preload.cpp @@ -34,7 +34,8 @@ bool RageSoundReader_Preload::PreloadSound( RageSoundReader *&pSound ) } RageSoundReader_Preload::RageSoundReader_Preload(): - m_Buffer( new RString ) + m_Buffer( new RString ), m_bBufferIs16Bit(false), + m_iPosition(0), m_iSampleRate(0), m_iChannels(0), m_fRate(0.0f) { m_bBufferIs16Bit = g_bSoundPreload16bit.Get(); } diff --git a/src/RageTexture.cpp b/src/RageTexture.cpp index c1eed7d324..ecad7eb785 100644 --- a/src/RageTexture.cpp +++ b/src/RageTexture.cpp @@ -7,16 +7,11 @@ RageTexture::RageTexture( RageTextureID name ): - m_ID(name) -{ - m_iRefCount = 1; - m_bWasUsed = false; - - m_iSourceWidth = m_iSourceHeight = 0; - m_iTextureWidth = m_iTextureHeight = 0; - m_iImageWidth = m_iImageHeight = 0; - m_iFramesWide = m_iFramesHigh = 1; -} + m_ID(name), m_iRefCount(1), m_bWasUsed(false), + m_iSourceWidth(0), m_iSourceHeight(0), + m_iTextureWidth(0), m_iTextureHeight(0), + m_iImageWidth(0), m_iImageHeight(0), + m_iFramesWide(1), m_iFramesHigh(1) {} RageTexture::~RageTexture() diff --git a/src/RageTextureManager.cpp b/src/RageTextureManager.cpp index 9cdb2570ee..9e3af1eed5 100644 --- a/src/RageTextureManager.cpp +++ b/src/RageTextureManager.cpp @@ -36,11 +36,9 @@ namespace map m_mapPathToTexture; }; -RageTextureManager::RageTextureManager() -{ - m_iNoWarnAboutOddDimensions = 0; - m_TexturePolicy = RageTextureID::TEX_DEFAULT; -} +RageTextureManager::RageTextureManager(): + m_iNoWarnAboutOddDimensions(0), + m_TexturePolicy(RageTextureID::TEX_DEFAULT) {} RageTextureManager::~RageTextureManager() { @@ -106,9 +104,8 @@ class RageTexture_Default: public RageTexture { public: RageTexture_Default(): - RageTexture( RageTextureID() ) + RageTexture( RageTextureID() ), m_uTexHandle(0) { - m_uTexHandle = 0; m_iSourceWidth = m_iSourceHeight = 1; m_iTextureWidth = m_iTextureHeight = 1; m_iImageWidth = m_iImageHeight = 1; diff --git a/src/RageThreads.cpp b/src/RageThreads.cpp index 3f3caf6305..0d6e1044a0 100644 --- a/src/RageThreads.cpp +++ b/src/RageThreads.cpp @@ -206,18 +206,11 @@ static ThreadSlot *GetUnknownThreadSlot() return g_pUnknownThreadSlot; } -RageThread::RageThread() -{ - m_pSlot = NULL; - m_sName = "unnamed"; -} +RageThread::RageThread(): m_pSlot(NULL), m_sName("unnamed") {} -RageThread::RageThread( const RageThread &cpy ) -{ - /* Copying a thread does not start the copy. */ - m_pSlot = NULL; - m_sName = cpy.m_sName; -} +/* Copying a thread does not start the copy. */ +RageThread::RageThread( const RageThread &cpy ): + m_pSlot(NULL), m_sName(cpy.m_sName) {} RageThread::~RageThread() { @@ -520,12 +513,9 @@ static set *g_FreeMutexIDs = NULL; #endif RageMutex::RageMutex( const RString &name ): - m_sName( name ) + m_sName( name ), m_pMutex( MakeMutex (this ) ), + m_LockedBy(GetInvalidThreadId()), m_LockCnt(0) { - m_pMutex = MakeMutex( this ); - m_LockedBy = GetInvalidThreadId(); - m_LockCnt = 0; - /* if( g_FreeMutexIDs == NULL ) { @@ -659,7 +649,8 @@ LockMutex::LockMutex( RageMutex &pMutex, const char *file_, int line_ ): mutex( pMutex ), file( file_ ), line( line_ ), - locked_at( RageTimer::GetTimeSinceStart() ) + locked_at( RageTimer::GetTimeSinceStart() ), + locked(false) // ensure it gets locked inside. { mutex.Lock(); locked = true; @@ -687,10 +678,7 @@ void LockMutex::Unlock() } RageEvent::RageEvent( RString name ): - RageMutex( name ) -{ - m_pEvent = MakeEvent( m_pMutex ); -} + RageMutex( name ), m_pEvent(MakeEvent(m_pMutex)) {} RageEvent::~RageEvent() { @@ -732,10 +720,7 @@ bool RageEvent::WaitTimeoutSupported() const } RageSemaphore::RageSemaphore( RString sName, int iInitialValue ): - m_sName( sName ) -{ - m_pSema = MakeSemaphore( iInitialValue ); -} + m_sName( sName ), m_pSema(MakeSemaphore( iInitialValue )) {} RageSemaphore::~RageSemaphore() { diff --git a/src/RageThreads.h b/src/RageThreads.h index 3de42782d1..86f7f55313 100644 --- a/src/RageThreads.h +++ b/src/RageThreads.h @@ -46,6 +46,9 @@ private: static bool s_bSystemSupportsTLS; static bool s_bIsShowingDialog; + + // Swallow up warnings. If they must be used, define them. + RageThread& operator=(const RageThread& rhs); }; /** @@ -61,6 +64,9 @@ public: private: ThreadSlot *m_pSlot; + // Swallow up warnings. If they must be used, define them. + RageThreadRegister& operator=(const RageThreadRegister& rhs); + RageThreadRegister(const RageThreadRegister& rhs); }; namespace Checkpoints @@ -102,6 +108,10 @@ protected: int m_LockCnt; void MarkLockedMutex(); +private: + // Swallow up warnings. If they must be used, define them. + RageMutex& operator=(const RageMutex& rhs); + RageMutex(const RageMutex& rhs); }; /** @@ -128,6 +138,10 @@ public: * * This can only be called once. */ void Unlock(); +private: + // Swallow up warnings. If they must be used, define them. + LockMutex& operator=(const LockMutex& rhs); + LockMutex(const LockMutex& rhs); }; #define LockMut(m) LockMutex UNIQUE_NAME(LocalLock) (m, __FILE__, __LINE__) @@ -149,6 +163,9 @@ public: void Signal(); void Broadcast(); bool WaitTimeoutSupported() const; + // Swallow up warnings. If they must be used, define them. + RageEvent& operator=(const RageEvent& rhs); + RageEvent(const RageEvent& rhs); private: EventImpl *m_pEvent; @@ -170,6 +187,10 @@ public: private: SemaImpl *m_pSema; RString m_sName; + + // Swallow up warnings. If they must be used, define them. + RageSemaphore& operator=(const RageSemaphore& rhs); + RageSemaphore(const RageSemaphore& rhs); }; #endif diff --git a/src/RageUtil_AutoPtr.h b/src/RageUtil_AutoPtr.h index 5b56eac08c..4cd03bdad6 100644 --- a/src/RageUtil_AutoPtr.h +++ b/src/RageUtil_AutoPtr.h @@ -27,22 +27,17 @@ class AutoPtrCopyOnWrite { public: /* This constructor only exists to make us work with STL containers. */ - inline AutoPtrCopyOnWrite() + inline AutoPtrCopyOnWrite(): m_pPtr(NULL), m_iRefCount(new int(1)) { - m_pPtr = NULL; - m_iRefCount = new int(1); } - explicit inline AutoPtrCopyOnWrite( T *p ) + explicit inline AutoPtrCopyOnWrite( T *p ): m_pPtr(p), m_iRefCount(new int(1)) { - m_pPtr = p; - m_iRefCount = new int(1); } - inline AutoPtrCopyOnWrite( const AutoPtrCopyOnWrite &rhs ) + inline AutoPtrCopyOnWrite( const AutoPtrCopyOnWrite &rhs ): + m_pPtr(rhs.m_pPtr), m_iRefCount(rhs.m_iRefCount) { - m_pPtr = rhs.m_pPtr; - m_iRefCount = rhs.m_iRefCount; ++(*m_iRefCount); } diff --git a/src/Trail.h b/src/Trail.h index f0f9fb040f..f69dd56faf 100644 --- a/src/Trail.h +++ b/src/Trail.h @@ -64,9 +64,15 @@ public: mutable bool m_bRadarValuesCached; mutable RadarValues m_CachedRadarValues; - Trail() + /** + * @brief Set up the Trail with default values. + * + * This used to call Init(), which is still available. */ + Trail(): m_StepsType(StepsType_Invalid), + m_CourseDifficulty(Difficulty_Invalid), + m_iSpecifiedMeter(-1), m_bRadarValuesCached(false) { - Init(); + m_vEntries.clear(); } void Init() { diff --git a/src/arch/InputHandler/InputHandler.h b/src/arch/InputHandler/InputHandler.h index 5bb41914e3..0eeed81982 100644 --- a/src/arch/InputHandler/InputHandler.h +++ b/src/arch/InputHandler/InputHandler.h @@ -25,7 +25,7 @@ public: static void Create( const RString &sDrivers, vector &apAdd ); static DriverList m_pDriverList; - InputHandler() { m_iInputsSinceUpdate = 0; } + InputHandler(): m_iInputsSinceUpdate(0) {} virtual ~InputHandler() { } virtual void Update() { } virtual bool DevicesChanged() { return false; }