From 8e8e483c5d801d659de3bc1e9a5f901625ccee27 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 19 Sep 2015 16:34:36 +0200 Subject: [PATCH] git-extra (WhoUses): fix compiler warnings Signed-off-by: Johannes Schindelin --- git-extra/sources/SystemInfo.cpp | 14 ++++++-------- git-extra/sources/SystemInfo.h | 2 ++ git-extra/sources/WhoUses.cpp | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/git-extra/sources/SystemInfo.cpp b/git-extra/sources/SystemInfo.cpp index 8f6f22e..095bda7 100644 --- a/git-extra/sources/SystemInfo.cpp +++ b/git-extra/sources/SystemInfo.cpp @@ -100,7 +100,7 @@ BOOL SystemInfoUtils::GetFsFileName( LPCTSTR lpDeviceFileName, //Mapped network drive char cDriveLetter; - DWORD dwParam; + int dwParam; TCHAR lpSharedName[0x1000]; @@ -166,7 +166,7 @@ BOOL SystemInfoUtils::GetDeviceFileName( LPCTSTR lpFsFileName, //Mapped network drive char cDriveLetter; - DWORD dwParam; + int dwParam; TCHAR lpSharedName[0x1000]; @@ -356,7 +356,7 @@ BOOL SystemThreadInformation::Refresh() SystemHandleInformation::SYSTEM_HANDLE& h = *iter; ti.ProcessId = h.ProcessID; - ti.ThreadHandle = (HANDLE)h.HandleNumber; + ti.ThreadHandle = (HANDLE)(DWORD_PTR)h.HandleNumber; // This is one of the threads we are lokking for if ( SystemHandleInformation::GetThreadId( ti.ThreadHandle, @@ -480,7 +480,7 @@ BOOL SystemHandleInformation::Refresh() else { // Type filtering - GetTypeToken( (HANDLE)pSysHandleInformation + GetTypeToken( (HANDLE)(DWORD_PTR)pSysHandleInformation ->Handles[i].HandleNumber, strType, pSysHandleInformation @@ -770,8 +770,6 @@ BOOL SystemHandleInformation::GetThreadId( HANDLE h, DWORD& threadID, DWORD proc //Process related functions BOOL SystemHandleInformation::GetProcessPath( HANDLE h, string& strPath, DWORD remoteProcessId ) { - h; strPath; remoteProcessId; - stringstream number; number << remoteProcessId; strPath = number.str(); @@ -999,7 +997,7 @@ BOOL SystemModuleInformation::Refresh() } // Everey process or just a particular one - if ( m_processId != -1 ) + if ( m_processId != (DWORD)-1 ) // For a particular one GetModuleListForProcess( m_processId ); else @@ -1067,7 +1065,7 @@ BOOL CALLBACK SystemWindowInformation::EnumerateWindows( HWND hwnd, LPARAM lPara GetWindowThreadProcessId(hwnd, &wi.ProcessId ) ; // Filtering by process ID - if ( _this->m_processId == -1 || _this->m_processId == wi.ProcessId ) + if ( _this->m_processId == (DWORD)-1 || _this->m_processId == wi.ProcessId ) { GetWindowText( hwnd, wi.Caption, MaxCaptionSize ); diff --git a/git-extra/sources/SystemInfo.h b/git-extra/sources/SystemInfo.h index 4392f65..48b901e 100644 --- a/git-extra/sources/SystemInfo.h +++ b/git-extra/sources/SystemInfo.h @@ -14,12 +14,14 @@ #error You need Windows NT to use this source code. Define WINNT! #endif +#ifdef _MSC_VER #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #pragma warning( disable : 4786 ) #pragma warning( disable : 4200 ) +#endif #include #include diff --git a/git-extra/sources/WhoUses.cpp b/git-extra/sources/WhoUses.cpp index 23a4b15..c363f3d 100644 --- a/git-extra/sources/WhoUses.cpp +++ b/git-extra/sources/WhoUses.cpp @@ -71,7 +71,7 @@ void WhoUsesModule( LPCTSTR lpFileName, BOOL bFullPathCheck ) processName = ""; _tprintf( _T("0x%04X %-20s %s\n"), - m.ProcessId, + (unsigned int)m.ProcessId, processName.c_str(), m.FullPath ); } @@ -125,7 +125,7 @@ void WhoUsesFile( LPCTSTR lpFileName, BOOL bFullPathCheck ) if ( INtDll::dwNTMajorVersion == 4 && _tcsicmp( processName.c_str(), _T("services.exe" ) ) == 0 ) continue; - hi.GetName( (HANDLE)h.HandleNumber, name, (DWORD)h.ProcessID ); + hi.GetName( (HANDLE)(DWORD_PTR)h.HandleNumber, name, (DWORD)h.ProcessID ); if ( bFullPathCheck ) bShow = _tcsicmp( name.c_str(), deviceFileName.c_str() ) == 0; @@ -141,7 +141,7 @@ void WhoUsesFile( LPCTSTR lpFileName, BOOL bFullPathCheck ) } _tprintf( _T("0x%04X %-20s %s\n"), - h.ProcessID, + (unsigned int)h.ProcessID, processName.c_str(), !bFullPathCheck ? fsFilePath.c_str() : lpFileName ); } @@ -158,13 +158,13 @@ void EnableDebugPriv( void ) if ( ! OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) ) { - _tprintf( _T("OpenProcessToken() failed, Error = %d SeDebugPrivilege is not available.\n") , GetLastError() ); + _tprintf( _T("OpenProcessToken() failed, Error = %d SeDebugPrivilege is not available.\n") , (int)GetLastError() ); return; } if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue ) ) { - _tprintf( _T("LookupPrivilegeValue() failed, Error = %d SeDebugPrivilege is not available.\n"), GetLastError() ); + _tprintf( _T("LookupPrivilegeValue() failed, Error = %d SeDebugPrivilege is not available.\n"), (int)GetLastError() ); CloseHandle( hToken ); return; } @@ -174,7 +174,7 @@ void EnableDebugPriv( void ) tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if ( ! AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof tkp, NULL, NULL ) ) - _tprintf( _T("AdjustTokenPrivileges() failed, Error = %d SeDebugPrivilege is not available.\n"), GetLastError() ); + _tprintf( _T("AdjustTokenPrivileges() failed, Error = %d SeDebugPrivilege is not available.\n"), (int)GetLastError() ); CloseHandle( hToken ); } @@ -249,7 +249,7 @@ int _tmain(int argc, TCHAR* argv[]) { if ( GetFullPathName( lpPath, _MAX_PATH, lpFilePath, NULL ) == 0 ) { - _tprintf( _T("GetFullPathName() failed. Error = %d\n"), GetLastError() ); + _tprintf( _T("GetFullPathName() failed. Error = %d\n"), (int)GetLastError() ); return -2; } }