diff options
author | Kissaki <kissaki@gmx.de> | 2011-10-03 16:46:48 +0400 |
---|---|---|
committer | Kissaki <kissaki@gmx.de> | 2011-10-09 16:01:58 +0400 |
commit | 5fe6801b1b2b652be8bd3244cfc6ae90b7466f16 (patch) | |
tree | b5c961a73d702b67baeff3e67a7db30720f9ab60 | |
parent | 683d39b26b5e8b1bd928b911790dc1d80be874a5 (diff) |
handle some cppcheck-found issues:
* uninitialized membervars,
* AudioOutput.cpp: fix delete on array to delete[]
* OSS.cpp: close file descriptor in false data case
* OverlayEditorScene.cpp: rm duplicate logic
* fix ifndef to match usage of declared variable
* member var initializations
* check for null (ds in d3d9 as some lines above),
* lower scope of var decl.,
* swap bufsize check and array dereference so check is before! deref,
* initialize member vars in constr.
-rw-r--r-- | overlay/HardHook.cpp | 2 | ||||
-rw-r--r-- | overlay/d3d9.cpp | 3 | ||||
-rw-r--r-- | overlay/lib.cpp | 6 | ||||
-rw-r--r-- | src/mumble/ASIOInput.cpp | 6 | ||||
-rw-r--r-- | src/mumble/AudioOutput.cpp | 6 | ||||
-rw-r--r-- | src/mumble/CoreAudio.cpp | 1 | ||||
-rw-r--r-- | src/mumble/DirectSound.cpp | 1 | ||||
-rw-r--r-- | src/mumble/G15LCDEngine_helper.cpp | 2 | ||||
-rw-r--r-- | src/mumble/G15LCDEngine_lglcd.cpp | 2 | ||||
-rw-r--r-- | src/mumble/Global.cpp | 1 | ||||
-rw-r--r-- | src/mumble/GlobalShortcut_unix.cpp | 3 | ||||
-rw-r--r-- | src/mumble/OSS.cpp | 2 | ||||
-rw-r--r-- | src/mumble/OverlayEditorScene.cpp | 2 | ||||
-rw-r--r-- | src/mumble/OverlayText.cpp | 20 | ||||
-rw-r--r-- | src/mumble/ServerHandler.cpp | 4 | ||||
-rw-r--r-- | src/mumble/WASAPI.cpp | 1 | ||||
-rw-r--r-- | src/murmur/DBus.cpp | 2 | ||||
-rw-r--r-- | src/murmur/DBus.h | 12 | ||||
-rw-r--r-- | src/murmur/ServerUser.cpp | 2 | ||||
-rw-r--r-- | src/murmur/UnixMurmur.cpp | 2 | ||||
-rw-r--r-- | src/murmur/main.cpp | 2 |
21 files changed, 51 insertions, 31 deletions
diff --git a/overlay/HardHook.cpp b/overlay/HardHook.cpp index e41810ce4..652bb18f9 100644 --- a/overlay/HardHook.cpp +++ b/overlay/HardHook.cpp @@ -34,7 +34,7 @@ void *HardHook::pCode = NULL; unsigned int HardHook::uiCode = 0; -HardHook::HardHook() { +HardHook::HardHook() : bTrampoline(false), call(0) { int i; baseptr = NULL; for (i=0;i<6;i++) diff --git a/overlay/d3d9.cpp b/overlay/d3d9.cpp index cf8b2ecdf..b2b1195a9 100644 --- a/overlay/d3d9.cpp +++ b/overlay/d3d9.cpp @@ -414,7 +414,8 @@ static HRESULT __stdcall myReset(IDirect3DDevice9 * idd, D3DPRESENT_PARAMETERS * HRESULT hr=oReset(idd, param); hhReset.inject(); - ds->createCleanState(); + if (ds) + ds->createCleanState(); return hr; } diff --git a/overlay/lib.cpp b/overlay/lib.cpp index 351c57048..a10d27cc7 100644 --- a/overlay/lib.cpp +++ b/overlay/lib.cpp @@ -493,7 +493,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { bBlackListed = TRUE; bMumble = TRUE; } else { - int i = 0; DWORD buffsize = MAX_PATH * 20; // Initial buffer size for registry operation bool usewhitelist; @@ -531,7 +530,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { if (usewhitelist) { bool onwhitelist = false; - while (buffer[pos] != 0 && pos < buffsize) { + while (pos < buffsize && buffer[pos] != 0) { if (_stricmp(procname, buffer + pos) == 0 || _stricmp(p+1, buffer + pos) == 0) { fods("Overlay enabled for whitelisted '%s'", buffer + pos); onwhitelist = true; @@ -546,7 +545,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { break; } } else { - while (buffer[pos] != 0 && pos < buffsize) { + while (pos < buffsize && buffer[pos] != 0) { if (_stricmp(procname, buffer + pos) == 0 || _stricmp(p+1, buffer + pos) == 0) { fods("Overlay blacklist entry found for '%s'", buffer + pos); bBlackListed = TRUE; @@ -558,6 +557,7 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID) { } else { // If there is no list in the registry fallback to using the default blacklist fods("Overlay fallback to default blacklist"); + int i = 0; while (overlayBlacklist[i]) { if (_stricmp(procname, overlayBlacklist[i]) == 0 || _stricmp(p+1, overlayBlacklist[i])==0) { fods("Overlay default blacklist entry found for '%s'", overlayBlacklist[i]); diff --git a/src/mumble/ASIOInput.cpp b/src/mumble/ASIOInput.cpp index 231535b2e..5cdb6d55c 100644 --- a/src/mumble/ASIOInput.cpp +++ b/src/mumble/ASIOInput.cpp @@ -68,6 +68,7 @@ class ASIOInit : public DeferInit { ASIOAudioInputRegistrar *airASIO; ConfigRegistrar *crASIO; public: + ASIOInit() : airASIO(NULL), crASIO(NULL) {} void initialize(); void destroy(); }; @@ -403,8 +404,6 @@ ASIOInput::ASIOInput() { abiInfo = NULL; aciInfo = NULL; - int i, idx; - // Sanity check things first. iNumMic=g.s.qlASIOmic.count(); @@ -465,7 +464,8 @@ ASIOInput::ASIOInput() { abiInfo = new ASIOBufferInfo[iNumMic + iNumSpeaker]; aciInfo = new ASIOChannelInfo[iNumMic + iNumSpeaker]; - idx = 0; + + int i, idx = 0; for (i=0;i<iNumMic;i++) { abiInfo[idx].isInput = true; abiInfo[idx].channelNum = g.s.qlASIOmic[i].toInt(); diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index e43084407..29537e7aa 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -849,9 +849,9 @@ void AudioOutput::removeBuffer(AudioOutputUser *aop) { } void AudioOutput::initializeMixer(const unsigned int *chanmasks, bool forceheadphone) { - delete fSpeakers; - delete bSpeakerPositional; - delete fSpeakerVolume; + delete[] fSpeakers; + delete[] bSpeakerPositional; + delete[] fSpeakerVolume; fSpeakers = new float[iChannels * 3]; bSpeakerPositional = new bool[iChannels]; diff --git a/src/mumble/CoreAudio.cpp b/src/mumble/CoreAudio.cpp index 8618a5d1f..52dd4a65e 100644 --- a/src/mumble/CoreAudio.cpp +++ b/src/mumble/CoreAudio.cpp @@ -55,6 +55,7 @@ class CoreAudioInit : public DeferInit { CoreAudioInputRegistrar *cairReg; CoreAudioOutputRegistrar *caorReg; public: + CoreAudioInit() : cairReg(NULL), caorReg(NULL) {} void initialize(); void destroy(); }; diff --git a/src/mumble/DirectSound.cpp b/src/mumble/DirectSound.cpp index 2580c50b7..e07002c98 100644 --- a/src/mumble/DirectSound.cpp +++ b/src/mumble/DirectSound.cpp @@ -65,6 +65,7 @@ class DirectSoundInit : public DeferInit { DXAudioInputRegistrar *airReg; DXAudioOutputRegistrar *aorReg; public: + DirectSoundInit() : airReg(NULL), aorReg(NULL) {} void initialize(); void destroy(); }; diff --git a/src/mumble/G15LCDEngine_helper.cpp b/src/mumble/G15LCDEngine_helper.cpp index fae92efe6..827cf08dc 100644 --- a/src/mumble/G15LCDEngine_helper.cpp +++ b/src/mumble/G15LCDEngine_helper.cpp @@ -121,7 +121,7 @@ void G15LCDEngineHelper::submitFrame(bool alert, unsigned char *buf, size_t len) /* -- */ -G15LCDDeviceHelper::G15LCDDeviceHelper(G15LCDEngineHelper *e) : LCDDevice() { +G15LCDDeviceHelper::G15LCDDeviceHelper(G15LCDEngineHelper *e) : LCDDevice(), bEnabled(false) { engine = e; } diff --git a/src/mumble/G15LCDEngine_lglcd.cpp b/src/mumble/G15LCDEngine_lglcd.cpp index 0d4916fe9..d192d97f1 100644 --- a/src/mumble/G15LCDEngine_lglcd.cpp +++ b/src/mumble/G15LCDEngine_lglcd.cpp @@ -99,7 +99,7 @@ QList<LCDDevice *> G15LCDEngineLGLCD::devices() const { /* -- */ -G15LCDDeviceLGLCD::G15LCDDeviceLGLCD(G15LCDEngineLGLCD *e) : LCDDevice() { +G15LCDDeviceLGLCD::G15LCDDeviceLGLCD(G15LCDEngineLGLCD *e) : LCDDevice(), bEnabled(false) { engine = e; } diff --git a/src/mumble/Global.cpp b/src/mumble/Global.cpp index 61f27a422..6b28abea2 100644 --- a/src/mumble/Global.cpp +++ b/src/mumble/Global.cpp @@ -73,6 +73,7 @@ Global::Global() { bPosTest = false; bInAudioWizard = false; iAudioPathTime = 0; + iAudioBandwidth = -1; iMaxBandwidth = -1; iCodecAlpha = 0; diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp index 48b0442c8..ebbb816c6 100644 --- a/src/mumble/GlobalShortcut_unix.cpp +++ b/src/mumble/GlobalShortcut_unix.cpp @@ -35,7 +35,8 @@ GlobalShortcutEngine *GlobalShortcutEngine::platformInit() { } GlobalShortcutX::GlobalShortcutX() { - bRunning=false; + iXIopcode = -1; + bRunning = false; display = NULL; diff --git a/src/mumble/OSS.cpp b/src/mumble/OSS.cpp index 1aca70e62..aae1615cb 100644 --- a/src/mumble/OSS.cpp +++ b/src/mumble/OSS.cpp @@ -297,6 +297,8 @@ void OSSOutput::run() { ival = AFMT_S16_NE; if ((ioctl(fd, SNDCTL_DSP_SETFMT, &ival) == -1) || (ival != AFMT_S16_NE)) { qWarning("OSSOutput: Failed to set sound format"); + if ((ival != AFMT_S16_NE)) + close(fd); return; } diff --git a/src/mumble/OverlayEditorScene.cpp b/src/mumble/OverlayEditorScene.cpp index 45d7f4f88..a0b7d72ae 100644 --- a/src/mumble/OverlayEditorScene.cpp +++ b/src/mumble/OverlayEditorScene.cpp @@ -197,8 +197,6 @@ void OverlayEditorScene::updateSelected() { updateAvatar(); else if (qgpiSelected == qgpiName) updateUserName(); - else if (qgpiSelected == qgpiAvatar) - updateAvatar(); else if (qgpiSelected == qgpiMuted) updateMuted(); } diff --git a/src/mumble/OverlayText.cpp b/src/mumble/OverlayText.cpp index 4dc14aed3..3d4e8ebdc 100644 --- a/src/mumble/OverlayText.cpp +++ b/src/mumble/OverlayText.cpp @@ -32,19 +32,27 @@ #include "Global.h" BasepointPixmap::BasepointPixmap() : - qpBasePoint(0, 0) { } + qpBasePoint(0, 0), + iAscent(-1), + iDescent(-1) { } BasepointPixmap::BasepointPixmap(const QPixmap& pm) : QPixmap(pm), - qpBasePoint(0, pm.height()) { } + qpBasePoint(0, pm.height()), + iAscent(-1), + iDescent(-1) { } BasepointPixmap::BasepointPixmap(int w, int h) : QPixmap(w, h), - qpBasePoint(0, h) { } + qpBasePoint(0, h), + iAscent(-1), + iDescent(-1) { } BasepointPixmap::BasepointPixmap(int w, int h, const QPoint& bp) : QPixmap(w, h), - qpBasePoint(bp) { } + qpBasePoint(bp), + iAscent(-1), + iDescent(-1) { } OverlayTextLine::OverlayTextLine(const QString& s, const QFont& f) : fEdgeFactor(0.05f), @@ -53,7 +61,9 @@ OverlayTextLine::OverlayTextLine(const QString& s, const QFont& f) : iCurWidth(-1), iCurHeight(-1), fBaseliningThreshold(0.5f), - bElided(false) { + bElided(false), + fXCorrection(0.0), + fYCorrection(0.0) { QFontMetrics fm(f); fAscent = static_cast<float>(fm.ascent()); fDescent = static_cast<float>(fm.descent()); diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 1f4ec2983..4fa8e447e 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -85,6 +85,10 @@ ServerHandler::ServerHandler() { cConnection.reset(); qusUdp = NULL; bStrong = false; + usPort = 0; + bUdp = true; + tConnectionTimeoutTimer = NULL; + uiVersion = 0; // For some strange reason, on Win32, we have to call supportsSsl before the cipher list is ready. qWarning("OpenSSL Support: %d (%s)", QSslSocket::supportsSsl(), SSLeay_version(SSLEAY_VERSION)); diff --git a/src/mumble/WASAPI.cpp b/src/mumble/WASAPI.cpp index 21ad99725..cdacb7eda 100644 --- a/src/mumble/WASAPI.cpp +++ b/src/mumble/WASAPI.cpp @@ -72,6 +72,7 @@ class WASAPIInit : public DeferInit { WASAPIInputRegistrar *wirReg; WASAPIOutputRegistrar *worReg; public: + WASAPIInit() : wirReg(NULL), worReg(NULL) { } void initialize(); void destroy(); }; diff --git a/src/murmur/DBus.cpp b/src/murmur/DBus.cpp index 8f6822e66..20addfdb3 100644 --- a/src/murmur/DBus.cpp +++ b/src/murmur/DBus.cpp @@ -738,7 +738,7 @@ ACLInfo::ACLInfo(const ChanACL *acl) { deny = acl->pDeny; } -GroupInfo::GroupInfo(const Group *g) { +GroupInfo::GroupInfo(const Group *g) : inherited(false) { name = g->qsName; inherit = g->bInherit; inheritable = g->bInheritable; diff --git a/src/murmur/DBus.h b/src/murmur/DBus.h index 98046ebc1..9a3e8e6df 100644 --- a/src/murmur/DBus.h +++ b/src/murmur/DBus.h @@ -49,7 +49,7 @@ struct PlayerInfo { bool mute, deaf, suppressed; bool selfMute, selfDeaf; int channel; - PlayerInfo() { }; + PlayerInfo() : session(0), mute(false), deaf(false), suppressed(false), selfMute(false), selfDeaf(false), channel(-1) { }; PlayerInfo(const User *); }; Q_DECLARE_METATYPE(PlayerInfo); @@ -59,7 +59,7 @@ struct PlayerInfoExtended : public PlayerInfo { QString name; int onlinesecs; int bytespersec; - PlayerInfoExtended() {}; + PlayerInfoExtended() : id(-1), onlinesecs(-1), bytespersec(-1) {}; PlayerInfoExtended(const User *); }; Q_DECLARE_METATYPE(PlayerInfoExtended); @@ -70,7 +70,7 @@ struct ChannelInfo { QString name; int parent; QList<int> links; - ChannelInfo() { }; + ChannelInfo() : id(-1), parent(-1) { }; ChannelInfo(const Channel *c); }; Q_DECLARE_METATYPE(ChannelInfo); @@ -80,7 +80,7 @@ struct GroupInfo { QString name; bool inherited, inherit, inheritable; QList<int> add, remove, members; - GroupInfo() { }; + GroupInfo() : inherited(false), inherit(false), inheritable(false) { }; GroupInfo(const Group *g); }; Q_DECLARE_METATYPE(GroupInfo); @@ -91,7 +91,7 @@ struct ACLInfo { int playerid; QString group; unsigned int allow, deny; - ACLInfo() { }; + ACLInfo() : applyHere(false), applySubs(false), inherited(false) { }; ACLInfo(const ChanACL *acl); }; Q_DECLARE_METATYPE(ACLInfo); @@ -100,7 +100,7 @@ Q_DECLARE_METATYPE(QList<ACLInfo>); struct BanInfo { unsigned int address; int bits; - BanInfo() { }; + BanInfo() : address(0), bits(0) { }; BanInfo(const Ban &); }; Q_DECLARE_METATYPE(BanInfo); diff --git a/src/murmur/ServerUser.cpp b/src/murmur/ServerUser.cpp index aacee597b..3af2be76a 100644 --- a/src/murmur/ServerUser.cpp +++ b/src/murmur/ServerUser.cpp @@ -35,7 +35,7 @@ #include "ServerUser.h" #include "Meta.h" -ServerUser::ServerUser(Server *p, QSslSocket *socket) : Connection(p, socket), User() { +ServerUser::ServerUser(Server *p, QSslSocket *socket) : Connection(p, socket), User(), s(NULL) { sState = ServerUser::Connected; sUdpSocket = INVALID_SOCKET; diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index 9e1c81c08..13b067ea6 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -36,7 +36,7 @@ QMutex *LimitTest::qm; QWaitCondition *LimitTest::qw; QWaitCondition *LimitTest::qstartw; -LimitTest::LimitTest() : QThread() { +LimitTest::LimitTest() : QThread(), tid(-1) { } void LimitTest::run() { diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp index b29d10c05..f70cc2ca1 100644 --- a/src/murmur/main.cpp +++ b/src/murmur/main.cpp @@ -196,7 +196,7 @@ int main(int argc, char **argv) { bool wipeSsl = false; bool wipeLogs = false; int sunum = 1; -#ifndef Q_OS_WIN +#ifdef Q_OS_UNIX bool readPw = false; #endif |