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

@ -4,6 +4,7 @@ SET(VERSION_MINOR 3)
SET(VERSION_REV 5) SET(VERSION_REV 5)
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}") SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}")
# The check for 2.6 may be too strict (consider lowering). # The check for 2.6 may be too strict (consider lowering).
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7) CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7)
@ -38,4 +39,9 @@ INCLUDE(${cmake_dir}/CMakeLists_synergys.txt)
INCLUDE(${cmake_dir}/CMakeLists_launcher.txt) INCLUDE(${cmake_dir}/CMakeLists_launcher.txt)
# Setup the CPack config. # Setup the CPack config.
INCLUDE(${cmake_dir}/CMakeLists_cpack.txt) INCLUDE(${cmake_dir}/CMakeLists_cpack.txt)
# add /analyze in order to unconver potential bugs in the source code
# Details: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /analyze")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /analyze")

View File

@ -17,6 +17,7 @@
#include "CConfig.h" #include "CConfig.h"
#include "CHotkeyOptions.h" #include "CHotkeyOptions.h"
#include "CStringUtil.h" #include "CStringUtil.h"
#include "CLog.h"
#include "LaunchUtil.h" #include "LaunchUtil.h"
#include "resource.h" #include "resource.h"
@ -713,7 +714,10 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
BYTE keyState[256]; BYTE keyState[256];
UINT virtualKey = (UINT)wParam; UINT virtualKey = (UINT)wParam;
UINT scanCode = (UINT)((lParam & 0x0ff0000u) >> 16); 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 // reset modifier state
keyState[VK_SHIFT] = 0; keyState[VK_SHIFT] = 0;
@ -730,7 +734,7 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
// translate virtual key to character // translate virtual key to character
int n; int n;
KeyID id; KeyID id = kKeyNone;
if (CArchMiscWindows::isWindows95Family()) { if (CArchMiscWindows::isWindows95Family()) {
// XXX -- how do we get characters not in Latin-1? // XXX -- how do we get characters not in Latin-1?
WORD ascii; WORD ascii;
@ -747,6 +751,10 @@ CHotkeyOptions::CConditionDialog::getChar(WPARAM wParam, LPARAM lParam)
ToUnicode_t s_ToUnicode = NULL; ToUnicode_t s_ToUnicode = NULL;
if (s_ToUnicode == NULL) { if (s_ToUnicode == NULL) {
HMODULE userModule = GetModuleHandle("user32.dll"); HMODULE userModule = GetModuleHandle("user32.dll");
if(userModule == NULL) {
LOG((CLOG_ERR "GetModuleHandle(\"user32.dll\") returned NULL"));
return kKeyNone;
}
s_ToUnicode = s_ToUnicode =
(ToUnicode_t)GetProcAddress(userModule, "ToUnicode"); (ToUnicode_t)GetProcAddress(userModule, "ToUnicode");
} }
@ -1355,8 +1363,10 @@ CHotkeyOptions::CActionDialog::getChar(WPARAM wParam, LPARAM lParam)
BYTE keyState[256]; BYTE keyState[256];
UINT virtualKey = (UINT)wParam; UINT virtualKey = (UINT)wParam;
UINT scanCode = (UINT)((lParam & 0x0ff0000u) >> 16); 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 // reset modifier state
keyState[VK_SHIFT] = 0; keyState[VK_SHIFT] = 0;
keyState[VK_LSHIFT] = 0; keyState[VK_LSHIFT] = 0;
@ -1389,6 +1399,10 @@ CHotkeyOptions::CActionDialog::getChar(WPARAM wParam, LPARAM lParam)
ToUnicode_t s_ToUnicode = NULL; ToUnicode_t s_ToUnicode = NULL;
if (s_ToUnicode == NULL) { if (s_ToUnicode == NULL) {
HMODULE userModule = GetModuleHandle("user32.dll"); HMODULE userModule = GetModuleHandle("user32.dll");
if(userModule==NULL) {
LOG((CLOG_ERR "GetModuleHandle(\"user32.dll\") returned NULL"));
return kKeyNone;
}
s_ToUnicode = s_ToUnicode =
(ToUnicode_t)GetProcAddress(userModule, "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 // see if the configuration changed
if (isConfigNewer(s_configTime, s_userConfig)) { if (isConfigNewer(s_configTime, s_userConfig)) {
CString message = getString(IDS_CONFIG_CHANGED); CString message2 = getString(IDS_CONFIG_CHANGED);
if (askVerify(hwnd, message)) { if (askVerify(hwnd, message2)) {
time_t configTime; time_t configTime;
bool userConfig; bool userConfig;
CConfig newConfig; CConfig newConfig;
@ -567,8 +567,8 @@ mainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
s_lastConfig = ARG->m_config; s_lastConfig = ARG->m_config;
} }
else { else {
message = getString(IDS_LOAD_FAILED); message2 = getString(IDS_LOAD_FAILED);
showError(hwnd, message); showError(hwnd, message2);
s_lastConfig = CConfig(); s_lastConfig = CConfig();
} }
} }

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -672,8 +672,8 @@ CArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
myArgv.push_back(argv[0]); myArgv.push_back(argv[0]);
// get pointers // get pointers
for (size_t i = 0; i < args.size(); ++i) { for (size_t j = 0; j < args.size(); ++j) {
myArgv.push_back(args[i].c_str()); myArgv.push_back(args[j].c_str());
} }
// adjust argc/argv // adjust argc/argv

View File

@ -297,7 +297,7 @@ CArchMultithreadWindows::newThread(ThreadFunc func, void* data)
thread->m_userData = data; thread->m_userData = data;
// create thread // create thread
unsigned int id; unsigned int id = 0;
thread->m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, thread->m_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0,
threadFunc, (void*)thread, 0, &id)); threadFunc, (void*)thread, 0, &id));
thread->m_id = static_cast<DWORD>(id); thread->m_id = static_cast<DWORD>(id);

View File

@ -129,16 +129,19 @@ bool
CArchSystemWindows::isWOW64() const CArchSystemWindows::isWOW64() const
{ {
#if WINVER >= _WIN32_WINNT_WINXP #if WINVER >= _WIN32_WINNT_WINXP
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
LPFN_ISWOW64PROCESS fnIsWow64Process = HMODULE hModule = GetModuleHandle(TEXT("kernel32"));
(LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); if (!hModule) return FALSE;
BOOL bIsWow64 = FALSE; LPFN_ISWOW64PROCESS fnIsWow64Process =
if(NULL != fnIsWow64Process && (LPFN_ISWOW64PROCESS) GetProcAddress(hModule, "IsWow64Process");
fnIsWow64Process(GetCurrentProcess(), &bIsWow64) &&
bIsWow64) BOOL bIsWow64 = FALSE;
{ if(NULL != fnIsWow64Process &&
return true; fnIsWow64Process(GetCurrentProcess(), &bIsWow64) &&
bIsWow64)
{
return true;
} }
#endif #endif
return false; return false;

View File

@ -758,7 +758,8 @@ CMSWindowsDesks::deskThread(void* vdesk)
// a window on the primary screen with low-level hooks // a window on the primary screen with low-level hooks
// should never activate. // should never activate.
EnableWindow(desk->m_window, desk->m_lowLevel ? FALSE : TRUE); if (desk->m_window)
EnableWindow(desk->m_window, desk->m_lowLevel ? FALSE : TRUE);
} }
break; break;

View File

@ -868,7 +868,10 @@ void
CMSWindowsKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const CMSWindowsKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const
{ {
BYTE keyState[256]; BYTE keyState[256];
GetKeyboardState(keyState); if (!GetKeyboardState(keyState)) {
LOG((CLOG_ERR "GetKeyboardState returned false on pollPressedKeys"));
return;
}
for (KeyButton i = 1; i < 256; ++i) { for (KeyButton i = 1; i < 256; ++i) {
if ((keyState[i] & 0x80) != 0) { if ((keyState[i] & 0x80) != 0) {
pressedKeys.insert(i); pressedKeys.insert(i);

View File

@ -370,7 +370,7 @@ CMSWindowsScreen::openScreensaver(bool notify)
if (m_screensaverNotify) { if (m_screensaverNotify) {
m_desks->installScreensaverHooks(true); m_desks->installScreensaverHooks(true);
} }
else { else if (m_screensaver) {
m_screensaver->disable(); m_screensaver->disable();
} }
} }
@ -393,6 +393,7 @@ void
CMSWindowsScreen::screensaver(bool activate) CMSWindowsScreen::screensaver(bool activate)
{ {
assert(m_screensaver != NULL); assert(m_screensaver != NULL);
if (m_screensaver==NULL) return;
if (activate) { if (activate) {
m_screensaver->activate(); m_screensaver->activate();
@ -836,6 +837,10 @@ void
CMSWindowsScreen::sendClipboardEvent(CEvent::Type type, ClipboardID id) CMSWindowsScreen::sendClipboardEvent(CEvent::Type type, ClipboardID id)
{ {
CClipboardInfo* info = (CClipboardInfo*)malloc(sizeof(CClipboardInfo)); CClipboardInfo* info = (CClipboardInfo*)malloc(sizeof(CClipboardInfo));
if(info == NULL) {
LOG((CLOG_ERR "malloc failed on %s:%s", __FILE__, __LINE__ ));
return;
}
info->m_id = id; info->m_id = id;
info->m_sequenceNumber = m_sequenceNumber; info->m_sequenceNumber = m_sequenceNumber;
sendEvent(type, info); sendEvent(type, info);

View File

@ -87,11 +87,11 @@ CConfig::renameScreen(const CString& oldName,
// update alias targets // update alias targets
if (CStringUtil::CaselessCmp::equal(oldName, oldCanonical)) { if (CStringUtil::CaselessCmp::equal(oldName, oldCanonical)) {
for (CNameMap::iterator index = m_nameToCanonicalName.begin(); for (CNameMap::iterator iter = m_nameToCanonicalName.begin();
index != m_nameToCanonicalName.end(); ++index) { iter != m_nameToCanonicalName.end(); ++iter) {
if (CStringUtil::CaselessCmp::equal( if (CStringUtil::CaselessCmp::equal(
index->second, oldCanonical)) { iter->second, oldCanonical)) {
index->second = newName; iter->second = newName;
} }
} }
} }
@ -119,10 +119,10 @@ CConfig::removeScreen(const CString& name)
} }
// remove aliases (and canonical name) // remove aliases (and canonical name)
for (CNameMap::iterator index = m_nameToCanonicalName.begin(); for (CNameMap::iterator iter = m_nameToCanonicalName.begin();
index != m_nameToCanonicalName.end(); ) { iter != m_nameToCanonicalName.end(); ) {
if (index->second == canonical) { if (iter->second == canonical) {
m_nameToCanonicalName.erase(index++); m_nameToCanonicalName.erase(iter++);
} }
else { else {
++index; ++index;