From d8f739f53c3be5bb3793085a09cd5ce2096fcbf4 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Thu, 3 Sep 2009 01:28:54 +0000 Subject: [PATCH] Misc --- src/common/classes/RefCounted.h | 2 +- src/common/classes/locks.cpp | 10 +++++----- src/common/fb_exception.cpp | 7 ++++--- src/common/thd.cpp | 5 ++--- src/common/thd.h | 1 + src/dsql/Parser.cpp | 2 +- src/jrd/gds.cpp | 16 ++++++++-------- src/jrd/isc_proto.h | 1 - src/jrd/os/win32/win9x_nt.h | 26 +++++++++++++------------- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/common/classes/RefCounted.h b/src/common/classes/RefCounted.h index 8efbefa0b5..575d861980 100644 --- a/src/common/classes/RefCounted.h +++ b/src/common/classes/RefCounted.h @@ -146,7 +146,7 @@ namespace Firebird return ptr; } - /* NS: you cannot have operator bool here. It creates ambiguity with + /* NS: you cannot have operator bool here. It creates ambiguity with operator T* with some of the compilers (at least VS2003) operator bool() const diff --git a/src/common/classes/locks.cpp b/src/common/classes/locks.cpp index ee87d1f7b8..bbb9440b32 100644 --- a/src/common/classes/locks.cpp +++ b/src/common/classes/locks.cpp @@ -46,14 +46,14 @@ namespace Firebird { // NS: This code is adapted from from KernelEx project, with the explicit // permission from the author. KernelEx project aims to provide Windows XP -// compatibility layer for Windows 98 and Windows ME. For futher information +// compatibility layer for Windows 98 and Windows ME. For further information // please refer to http://www.sourceforge.net/projects/kernelex/ static const K32OBJ_CRITICAL_SECTION = 4; static const TDBX_WIN98 = 0x50; static const TDBX_WINME = 0x80; -typedef struct _CRIT_SECT // Size = 0x20 +typedef struct _CRIT_SECT // Size = 0x20 { BYTE Type; // 00 = 4: K32_OBJECT_CRITICAL_SECTION int RecursionCount; // 04 initially 0, incremented on lock @@ -116,7 +116,7 @@ BOOL WINAPI TryEnterCriticalSection_Win9X(CRITICAL_SECTION* cs) WIN_CRITICAL_SECTION* mycs = (WIN_CRITICAL_SECTION*) cs; if (mycs->Type != K32OBJ_CRITICAL_SECTION) RaiseException(STATUS_ACCESS_VIOLATION, 0, 0, NULL); - + return TryEnterCrst(mycs->crit); } @@ -133,12 +133,12 @@ TryEnterCS::TryEnterCS() // Win9X support #ifdef WIN9X_SUPPORT OSVERSIONINFO OsVersionInfo; - + OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx((LPOSVERSIONINFO) &OsVersionInfo)) { if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && - OsVersionInfo.dwMajorVersion == 4) + OsVersionInfo.dwMajorVersion == 4) { // Windows 98 if (OsVersionInfo.dwMinorVersion == 10) diff --git a/src/common/fb_exception.cpp b/src/common/fb_exception.cpp index f4f500b375..fed5eb1dd0 100644 --- a/src/common/fb_exception.cpp +++ b/src/common/fb_exception.cpp @@ -62,7 +62,7 @@ private: if (thread != currTID) { HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, false, thread); - // commented exit code check - looks like OS does not return handle + // commented exit code check - looks like OS does not return handle // for already exited thread //DWORD exitCode = STILL_ACTIVE; if (hThread) @@ -70,7 +70,7 @@ private: //GetExitCodeThread(hThread, &exitCode); CloseHandle(hThread); } - + //if ((!hThread) || (exitCode != STILL_ACTIVE)) if (!hThread) { @@ -79,6 +79,7 @@ private: } } #endif + return thread == currTID; } }; @@ -406,7 +407,7 @@ fatal_exception::fatal_exception(const char* message) : { isc_arg_gds, isc_random, - isc_arg_string, + isc_arg_string, (ISC_STATUS)(IPTR) message, isc_arg_end }; diff --git a/src/common/thd.cpp b/src/common/thd.cpp index 40a880b2ed..6057497c6f 100644 --- a/src/common/thd.cpp +++ b/src/common/thd.cpp @@ -172,7 +172,6 @@ void makeKey() } } - void initThreadCleanup() { int err = pthread_once(&keyOnce, makeKey); @@ -243,7 +242,7 @@ void ThreadCleanup::remove(FPTR_VOID_PTR cleanup, void* arg) delete toDelete; } -#else //USE_POSIX_THREADS +#else // USE_POSIX_THREADS ThreadCleanup** ThreadCleanup::findCleanup(FPTR_VOID_PTR, void*) { @@ -262,4 +261,4 @@ void ThreadCleanup::remove(FPTR_VOID_PTR, void*) { } -#endif //USE_POSIX_THREADS +#endif // USE_POSIX_THREADS diff --git a/src/common/thd.h b/src/common/thd.h index 3f13c02fd3..931f45f733 100644 --- a/src/common/thd.h +++ b/src/common/thd.h @@ -43,6 +43,7 @@ public: static void add(FPTR_VOID_PTR cleanup, void* arg); static void remove(FPTR_VOID_PTR cleanup, void* arg); static void destructor(void*); + private: FPTR_VOID_PTR function; void* argument; diff --git a/src/dsql/Parser.cpp b/src/dsql/Parser.cpp index dfbcd5328b..b9f6d66597 100644 --- a/src/dsql/Parser.cpp +++ b/src/dsql/Parser.cpp @@ -140,7 +140,7 @@ void Parser::transformString(const char* start, unsigned length, string& dest) } *p = '\''; - fb_assert(p <= buffer.begin() + newSize); + fb_assert(p < buffer.begin() + newSize); pos = s + mark.length; } diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 188be3d71b..348382044f 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -3681,26 +3681,26 @@ public: #ifdef WIN9X_SUPPORT // shell32.dll version 5.0 and later supports SHGetFolderPath entry point HMODULE hShFolder = LoadLibrary("shell32.dll"); - PFNSHGETFOLDERPATHA pfnSHGetFolderPath = + PFNSHGETFOLDERPATHA pfnSHGetFolderPath = (PFNSHGETFOLDERPATHA) GetProcAddress(hShFolder, "SHGetFolderPathA"); - if (!pfnSHGetFolderPath) + if (!pfnSHGetFolderPath) { // For old OS versions fall back to shfolder.dll FreeLibrary(hShFolder); hShFolder = LoadLibrary("shfolder.dll"); - pfnSHGetFolderPath = + pfnSHGetFolderPath = (PFNSHGETFOLDERPATHA) GetProcAddress(hShFolder, "SHGetFolderPathA"); } char cmnData[MAXPATHLEN]; if (pfnSHGetFolderPath && - pfnSHGetFolderPath(NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, - SHGFP_TYPE_CURRENT, cmnData) == S_OK) + pfnSHGetFolderPath(NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, + SHGFP_TYPE_CURRENT, cmnData) == S_OK) { PathUtils::concatPath(lockPrefix, cmnData, LOCKDIR); } - else + else { // If shfolder.dll is missing or API fails fall back to using old style location for locks lockPrefix = prefix; @@ -3712,8 +3712,8 @@ public: Firebird::system_call_failed::raise("SHGetSpecialFolderPath"); } PathUtils::concatPath(lockPrefix, cmnData, LOCKDIR); -#endif -#endif +#endif // WIN9X_SUPPORT +#endif // WIN_NT } lockPrefix.copyTo(fb_prefix_lock_val, sizeof(fb_prefix_lock_val)); fb_prefix_lock = fb_prefix_lock_val; diff --git a/src/jrd/isc_proto.h b/src/jrd/isc_proto.h index 7fdac86b07..8cbfc03140 100644 --- a/src/jrd/isc_proto.h +++ b/src/jrd/isc_proto.h @@ -45,4 +45,3 @@ struct _SECURITY_ATTRIBUTES* ISC_get_security_desc(); #endif #endif // JRD_ISC_PROTO_H - diff --git a/src/jrd/os/win32/win9x_nt.h b/src/jrd/os/win32/win9x_nt.h index f5f90786a8..f3c1dd3748 100644 --- a/src/jrd/os/win32/win9x_nt.h +++ b/src/jrd/os/win32/win9x_nt.h @@ -50,9 +50,9 @@ struct LocksArrayItem { }; Firebird::SortedArray< - LocksArrayItem, + LocksArrayItem, Firebird::InlineStorage, - HANDLE, + HANDLE, LocksArrayItem > file_locks_9X(*getDefaultMemoryPool()); // This header can be included in winnt.h @@ -70,10 +70,10 @@ HANDLE CreateFile_9X( dwShareMode &= ~FILE_SHARE_DELETE; HANDLE file = CreateFileA( - lpFileName, - dwDesiredAccess, - dwShareMode, - lpSecurityAttributes, + lpFileName, + dwDesiredAccess, + dwShareMode, + lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); @@ -84,7 +84,7 @@ HANDLE CreateFile_9X( MutexLockGuard sync(file_locks_mutex); file_locks_9X.add( LocksArrayItem( - file, + file, new Firebird::Mutex())); } @@ -92,7 +92,7 @@ HANDLE CreateFile_9X( return file; } -BOOL CloseHandle_9X(HANDLE hObject) +BOOL CloseHandle_9X(HANDLE hObject) { if (!ISC_is_WinNT()) { MutexLockGuard sync(file_locks_mutex); @@ -111,9 +111,9 @@ BOOL ReadFile_9X( LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, - LPOVERLAPPED lpOverlapped) + LPOVERLAPPED lpOverlapped) { - if (ISC_is_WinNT()) + if (ISC_is_WinNT()) return ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped); Firebird::Mutex* fileMutex = NULL; @@ -130,7 +130,7 @@ BOOL ReadFile_9X( MutexLockGuard sync(*fileMutex); if (lpOverlapped != NULL) { - const DWORD ret = SetFilePointer(hFile, lpOverlapped->Offset, + const DWORD ret = SetFilePointer(hFile, lpOverlapped->Offset, (PLONG)&lpOverlapped->OffsetHigh, FILE_BEGIN); if (ret == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) return 0; @@ -152,7 +152,7 @@ BOOL WriteFile_9X( LPOVERLAPPED lpOverlapped ) { - if (ISC_is_WinNT()) + if (ISC_is_WinNT()) return WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped); Firebird::Mutex* fileMutex = NULL; @@ -169,7 +169,7 @@ BOOL WriteFile_9X( MutexLockGuard sync(*fileMutex); if (lpOverlapped != NULL) { - const DWORD ret = SetFilePointer(hFile, lpOverlapped->Offset, + const DWORD ret = SetFilePointer(hFile, lpOverlapped->Offset, (PLONG)&lpOverlapped->OffsetHigh, FILE_BEGIN); if (ret == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) return 0;