More warning fixes.

RageThreads.h is right now clear of
Effective Violations. It may be worth studying.
This commit is contained in:
Jason Felds
2011-03-14 15:30:04 -04:00
parent 68fe6b3a32
commit 8a7877f9d1
10 changed files with 63 additions and 74 deletions
+6 -14
View File
@@ -12,20 +12,12 @@ const int NUM_USER_GAME_TO_DEVICE_SLOTS = 2;
struct AutoMappingEntry struct AutoMappingEntry
{ {
AutoMappingEntry( int i, DeviceButton db, GameButton gb, bool b ) AutoMappingEntry( int i, DeviceButton db, GameButton gb, bool b ):
{ m_iSlotIndex(i), m_deviceButton(db),
m_iSlotIndex = i; m_gb(gb), m_bSecondController(b) {}
m_deviceButton = db; AutoMappingEntry(): m_iSlotIndex(-1),
m_gb = gb; m_deviceButton(DeviceButton_Invalid), m_gb(GameButton_Invalid),
m_bSecondController = b; m_bSecondController(false) {}
}
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; } bool IsEmpty() const { return m_deviceButton == DeviceButton_Invalid && m_gb == GameButton_Invalid; }
int m_iSlotIndex; int m_iSlotIndex;
+2 -5
View File
@@ -35,11 +35,8 @@ static Preference<RString> g_sSoundDrivers( "SoundDrivers", "" ); // "" == DEFAU
RageSoundManager *SOUNDMAN = NULL; RageSoundManager *SOUNDMAN = NULL;
RageSoundManager::RageSoundManager() RageSoundManager::RageSoundManager(): m_pDriver(NULL), m_fMixVolume(1.0f),
{ m_fVolumeOfNonCriticalSounds(1.0f) {}
m_fMixVolume = 1.0f;
m_fVolumeOfNonCriticalSounds = 1.0f;
}
static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" ); static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" );
void RageSoundManager::Init() void RageSoundManager::Init()
+2 -1
View File
@@ -34,7 +34,8 @@ bool RageSoundReader_Preload::PreloadSound( RageSoundReader *&pSound )
} }
RageSoundReader_Preload::RageSoundReader_Preload(): 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(); m_bBufferIs16Bit = g_bSoundPreload16bit.Get();
} }
+5 -10
View File
@@ -7,16 +7,11 @@
RageTexture::RageTexture( RageTextureID name ): RageTexture::RageTexture( RageTextureID name ):
m_ID(name) m_ID(name), m_iRefCount(1), m_bWasUsed(false),
{ m_iSourceWidth(0), m_iSourceHeight(0),
m_iRefCount = 1; m_iTextureWidth(0), m_iTextureHeight(0),
m_bWasUsed = false; m_iImageWidth(0), m_iImageHeight(0),
m_iFramesWide(1), m_iFramesHigh(1) {}
m_iSourceWidth = m_iSourceHeight = 0;
m_iTextureWidth = m_iTextureHeight = 0;
m_iImageWidth = m_iImageHeight = 0;
m_iFramesWide = m_iFramesHigh = 1;
}
RageTexture::~RageTexture() RageTexture::~RageTexture()
+4 -7
View File
@@ -36,11 +36,9 @@ namespace
map<RageTextureID, RageTexture*> m_mapPathToTexture; map<RageTextureID, RageTexture*> m_mapPathToTexture;
}; };
RageTextureManager::RageTextureManager() RageTextureManager::RageTextureManager():
{ m_iNoWarnAboutOddDimensions(0),
m_iNoWarnAboutOddDimensions = 0; m_TexturePolicy(RageTextureID::TEX_DEFAULT) {}
m_TexturePolicy = RageTextureID::TEX_DEFAULT;
}
RageTextureManager::~RageTextureManager() RageTextureManager::~RageTextureManager()
{ {
@@ -106,9 +104,8 @@ class RageTexture_Default: public RageTexture
{ {
public: public:
RageTexture_Default(): RageTexture_Default():
RageTexture( RageTextureID() ) RageTexture( RageTextureID() ), m_uTexHandle(0)
{ {
m_uTexHandle = 0;
m_iSourceWidth = m_iSourceHeight = 1; m_iSourceWidth = m_iSourceHeight = 1;
m_iTextureWidth = m_iTextureHeight = 1; m_iTextureWidth = m_iTextureHeight = 1;
m_iImageWidth = m_iImageHeight = 1; m_iImageWidth = m_iImageHeight = 1;
+10 -25
View File
@@ -206,18 +206,11 @@ static ThreadSlot *GetUnknownThreadSlot()
return g_pUnknownThreadSlot; return g_pUnknownThreadSlot;
} }
RageThread::RageThread() RageThread::RageThread(): m_pSlot(NULL), m_sName("unnamed") {}
{
m_pSlot = NULL;
m_sName = "unnamed";
}
RageThread::RageThread( const RageThread &cpy ) /* Copying a thread does not start the copy. */
{ RageThread::RageThread( const RageThread &cpy ):
/* Copying a thread does not start the copy. */ m_pSlot(NULL), m_sName(cpy.m_sName) {}
m_pSlot = NULL;
m_sName = cpy.m_sName;
}
RageThread::~RageThread() RageThread::~RageThread()
{ {
@@ -520,12 +513,9 @@ static set<int> *g_FreeMutexIDs = NULL;
#endif #endif
RageMutex::RageMutex( const RString &name ): 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 ) /* if( g_FreeMutexIDs == NULL )
{ {
@@ -659,7 +649,8 @@ LockMutex::LockMutex( RageMutex &pMutex, const char *file_, int line_ ):
mutex( pMutex ), mutex( pMutex ),
file( file_ ), file( file_ ),
line( line_ ), line( line_ ),
locked_at( RageTimer::GetTimeSinceStart() ) locked_at( RageTimer::GetTimeSinceStart() ),
locked(false) // ensure it gets locked inside.
{ {
mutex.Lock(); mutex.Lock();
locked = true; locked = true;
@@ -687,10 +678,7 @@ void LockMutex::Unlock()
} }
RageEvent::RageEvent( RString name ): RageEvent::RageEvent( RString name ):
RageMutex( name ) RageMutex( name ), m_pEvent(MakeEvent(m_pMutex)) {}
{
m_pEvent = MakeEvent( m_pMutex );
}
RageEvent::~RageEvent() RageEvent::~RageEvent()
{ {
@@ -732,10 +720,7 @@ bool RageEvent::WaitTimeoutSupported() const
} }
RageSemaphore::RageSemaphore( RString sName, int iInitialValue ): RageSemaphore::RageSemaphore( RString sName, int iInitialValue ):
m_sName( sName ) m_sName( sName ), m_pSema(MakeSemaphore( iInitialValue )) {}
{
m_pSema = MakeSemaphore( iInitialValue );
}
RageSemaphore::~RageSemaphore() RageSemaphore::~RageSemaphore()
{ {
+21
View File
@@ -46,6 +46,9 @@ private:
static bool s_bSystemSupportsTLS; static bool s_bSystemSupportsTLS;
static bool s_bIsShowingDialog; 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: private:
ThreadSlot *m_pSlot; ThreadSlot *m_pSlot;
// Swallow up warnings. If they must be used, define them.
RageThreadRegister& operator=(const RageThreadRegister& rhs);
RageThreadRegister(const RageThreadRegister& rhs);
}; };
namespace Checkpoints namespace Checkpoints
@@ -102,6 +108,10 @@ protected:
int m_LockCnt; int m_LockCnt;
void MarkLockedMutex(); 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. */ * This can only be called once. */
void Unlock(); 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__) #define LockMut(m) LockMutex UNIQUE_NAME(LocalLock) (m, __FILE__, __LINE__)
@@ -149,6 +163,9 @@ public:
void Signal(); void Signal();
void Broadcast(); void Broadcast();
bool WaitTimeoutSupported() const; bool WaitTimeoutSupported() const;
// Swallow up warnings. If they must be used, define them.
RageEvent& operator=(const RageEvent& rhs);
RageEvent(const RageEvent& rhs);
private: private:
EventImpl *m_pEvent; EventImpl *m_pEvent;
@@ -170,6 +187,10 @@ public:
private: private:
SemaImpl *m_pSema; SemaImpl *m_pSema;
RString m_sName; RString m_sName;
// Swallow up warnings. If they must be used, define them.
RageSemaphore& operator=(const RageSemaphore& rhs);
RageSemaphore(const RageSemaphore& rhs);
}; };
#endif #endif
+4 -9
View File
@@ -27,22 +27,17 @@ class AutoPtrCopyOnWrite
{ {
public: public:
/* This constructor only exists to make us work with STL containers. */ /* 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); ++(*m_iRefCount);
} }
+8 -2
View File
@@ -64,9 +64,15 @@ public:
mutable bool m_bRadarValuesCached; mutable bool m_bRadarValuesCached;
mutable RadarValues m_CachedRadarValues; 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() void Init()
{ {
+1 -1
View File
@@ -25,7 +25,7 @@ public:
static void Create( const RString &sDrivers, vector<InputHandler *> &apAdd ); static void Create( const RString &sDrivers, vector<InputHandler *> &apAdd );
static DriverList m_pDriverList; static DriverList m_pDriverList;
InputHandler() { m_iInputsSinceUpdate = 0; } InputHandler(): m_iInputsSinceUpdate(0) {}
virtual ~InputHandler() { } virtual ~InputHandler() { }
virtual void Update() { } virtual void Update() { }
virtual bool DevicesChanged() { return false; } virtual bool DevicesChanged() { return false; }