Added "/analyze" flag for compile in order to activate Code Analysis in Visual Studio 2008+. Resolved some of these warnings.

This commit is contained in:
Sorin Sbarnea
2009-12-21 16:52:47 +00:00
parent ba7ec582c3
commit 9face38556
12 changed files with 1419 additions and 1381 deletions

View File

@@ -17,6 +17,7 @@
#include "CConfig.h"
#include "CHotkeyOptions.h"
#include "CStringUtil.h"
#include "CLog.h"
#include "LaunchUtil.h"
#include "resource.h"
@@ -713,7 +714,10 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
BYTE keyState[256];
UINT virtualKey = (UINT)wParam;
UINT scanCode = (UINT)((lParam & 0x0ff0000u) >> 16);
GetKeyboardState(keyState);
if (!GetKeyboardState(keyState)) {
LOG((CLOG_WARN "GetKeyboardState failed on CHotkeyOptions::CConditionDialog::getChar"));
return kKeyNone;
}
// reset modifier state
keyState[VK_SHIFT] = 0;
@@ -730,7 +734,7 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
// translate virtual key to character
int n;
KeyID id;
KeyID id = kKeyNone;
if (CArchMiscWindows::isWindows95Family()) {
// XXX -- how do we get characters not in Latin-1?
WORD ascii;
@@ -747,6 +751,10 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
ToUnicode_t s_ToUnicode = NULL;
if (s_ToUnicode == NULL) {
HMODULE userModule = GetModuleHandle("user32.dll");
if(userModule == NULL) {
LOG((CLOG_ERR "GetModuleHandle(\"user32.dll\") returned NULL"));
return kKeyNone;
}
s_ToUnicode =
(ToUnicode_t)GetProcAddress(userModule, "ToUnicode");
}
@@ -1355,8 +1363,10 @@ CHotkeyOptions::CActionDialog::getChar(WPARAM wParam, LPARAM lParam)
BYTE keyState[256];
UINT virtualKey = (UINT)wParam;
UINT scanCode = (UINT)((lParam & 0x0ff0000u) >> 16);
GetKeyboardState(keyState);
if (!GetKeyboardState(keyState)) {
LOG((CLOG_WARN "GetKeyboardState failed on CHotkeyOptions::CActionDialog::getChar"));
return kKeyNone;
}
// reset modifier state
keyState[VK_SHIFT] = 0;
keyState[VK_LSHIFT] = 0;
@@ -1389,6 +1399,10 @@ CHotkeyOptions::CActionDialog::getChar(WPARAM wParam, LPARAM lParam)
ToUnicode_t s_ToUnicode = NULL;
if (s_ToUnicode == NULL) {
HMODULE userModule = GetModuleHandle("user32.dll");
if(userModule==NULL) {
LOG((CLOG_ERR "GetModuleHandle(\"user32.dll\") returned NULL"));
return kKeyNone;
}
s_ToUnicode =
(ToUnicode_t)GetProcAddress(userModule, "ToUnicode");
}

View File

@@ -556,8 +556,8 @@ mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
// see if the configuration changed
if (isConfigNewer(s_configTime, s_userConfig)) {
CString message = getString(IDS_CONFIG_CHANGED);
if (askVerify(hwnd, message)) {
CString message2 = getString(IDS_CONFIG_CHANGED);
if (askVerify(hwnd, message2)) {
time_t configTime;
bool userConfig;
CConfig newConfig;
@@ -567,8 +567,8 @@ mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
s_lastConfig = ARG->m_config;
}
else {
message = getString(IDS_LOAD_FAILED);
showError(hwnd, message);
message2 = getString(IDS_LOAD_FAILED);
showError(hwnd, message2);
s_lastConfig = CConfig();
}
}

View File

@@ -601,6 +601,12 @@ parse(int argc, const char* const* argv)
assert(argv != NULL);
assert(argc >= 1);
if(ARG->m_pname != NULL
|| argv != NULL
|| argc >= 1) {
return;
}
// set defaults
ARG->m_name = ARCH->getHostName();

File diff suppressed because it is too large Load Diff