From 974b7fe6dfa8935a2068365e416b8d886f9d2a32 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 30 Sep 2016 15:05:12 +0200 Subject: clang-cl loplugin: sal Change-Id: If04d3f07dc8bffac8887773b5424c09848cd8f1a Reviewed-on: https://gerrit.libreoffice.org/29404 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- sal/qa/osl/process/osl_process.cxx | 24 ++++++------------ sal/qa/osl/process/osl_process_child.cxx | 2 +- sal/qa/osl/security/osl_Security.cxx | 33 +++++++++++++------------ sal/qa/osl/setthreadname/test-setthreadname.cxx | 2 +- 4 files changed, 27 insertions(+), 34 deletions(-) (limited to 'sal/qa') diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index 2320fd6197f2..475b09750826 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -39,7 +39,7 @@ #if defined HAVE_VALGRIND_HEADERS #include -#else +#elif !defined _WIN32 #define RUNNING_ON_VALGRIND false #endif @@ -95,6 +95,8 @@ inline ::rtl::OUString getExecutablePath() typedef std::vector string_container_t; +#if !defined _WIN32 + class exclude : public std::unary_function { public: @@ -154,27 +156,13 @@ namespace } } -#ifdef _WIN32 - void read_parent_environment(string_container_t* env_container) - { - LPTSTR env = reinterpret_cast(GetEnvironmentStrings()); - LPTSTR p = env; - - while (size_t l = _tcslen(p)) - { - env_container->push_back(OString(p)); - p += l + 1; - } - FreeEnvironmentStrings(env); - tidy_container(*env_container); - } -#else void read_parent_environment(string_container_t* env_container) { for (int i = 0; nullptr != environ[i]; i++) env_container->push_back(OString(environ[i])); tidy_container(*env_container); } + #endif class Test_osl_executeProcess : public CppUnit::TestFixture @@ -222,6 +210,8 @@ public: return temp_file_path; } +#if !defined _WIN32 + void read_child_environment(string_container_t* env_container) { OString temp_file_name = OUStringToOString(OUString( @@ -419,6 +409,8 @@ public: ); } +#endif + void osl_execProc_test_batch() { oslProcess process; diff --git a/sal/qa/osl/process/osl_process_child.cxx b/sal/qa/osl/process/osl_process_child.cxx index 22ab319873a3..4688f4883e9f 100644 --- a/sal/qa/osl/process/osl_process_child.cxx +++ b/sal/qa/osl/process/osl_process_child.cxx @@ -58,7 +58,7 @@ void wait_for_seconds(char* time) void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size) { LPCWSTR strW = reinterpret_cast(_strW); - WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, nullptr, nullptr); } void dump_env(char* file_path) diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 1ebdbeae31af..8cd5f1257f62 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -370,17 +370,18 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, sal_Char PathA[_MAX_PATH]; if (RegOpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &hRegKey) == ERROR_SUCCESS) { - LONG lRet, lSize = sizeof(PathA); + LONG lRet; + DWORD lSize = sizeof(PathA); DWORD Type; - lRet = RegQueryValueEx(hRegKey, "AppData", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize); + lRet = RegQueryValueEx(hRegKey, "AppData", nullptr, &Type, reinterpret_cast(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) ); } - lRet = RegQueryValueEx(hRegKey, "Personal", NULL, &Type, ( unsigned char * )PathA, ( unsigned long * )&lSize); + lRet = RegQueryValueEx(hRegKey, "Personal", nullptr, &Type, reinterpret_cast(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", @@ -398,19 +399,19 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, DWORD dwSidBufferSize = INITIAL_SIZE; DWORD cchDomainName = 0; DWORD dwDomainBufferSize = INITIAL_SIZE; - WCHAR * wszDomainName = NULL; + WCHAR * wszDomainName = nullptr; SID_NAME_USE eSidType; DWORD dwErrorCode = 0; - LPCWSTR wszAccName = ( LPWSTR ) strUserName.getStr( ); + LPCWSTR wszAccName = strUserName.getStr( ); // Create buffers for the SID and the domain name. - PSID pSid = (PSID) new BYTE[dwSidBufferSize]; - CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= NULL ); + PSID pSid = static_cast(new BYTE[dwSidBufferSize]); + CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, dwSidBufferSize); wszDomainName = new WCHAR[dwDomainBufferSize]; - CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != NULL ); + CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != nullptr ); memset(wszDomainName, 0, dwDomainBufferSize*sizeof(WCHAR)); // Obtain the SID for the account name passed. @@ -420,7 +421,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, cbSid = dwSidBufferSize; cchDomainName = dwDomainBufferSize; if (LookupAccountNameW( - NULL, // Computer name. NULL for the local computer + nullptr, // Computer name. NULL for the local computer wszAccName, pSid, // Pointer to the SID buffer. Use NULL to get the size needed, &cbSid, // Size of the SID buffer needed. @@ -443,8 +444,8 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, // Reallocate memory for the SID buffer. wprintf(L"# The SID buffer was too small. It will be reallocated.\n"); FreeSid( pSid); - pSid = (PSID) new BYTE[cbSid]; - CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= NULL ); + pSid = static_cast(new BYTE[cbSid]); + CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, cbSid); dwSidBufferSize = cbSid; } @@ -454,7 +455,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, wprintf(L"# The domain name buffer was too small. It will be reallocated.\n"); delete [] wszDomainName; wszDomainName = new WCHAR[cchDomainName]; - CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= NULL ); + CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= nullptr ); memset(wszDomainName, 0, cchDomainName*sizeof(WCHAR)); dwDomainBufferSize = cchDomainName; } @@ -481,7 +482,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, dwSubAuthorities=std::min((int) *GetSidSubAuthorityCount(pSid), 5); /* buffer length: S-SID_REVISION- + identifierauthority- + subauthorities- + NULL */ - Ident=(sal_Char * )malloc(88*sizeof(sal_Char)); + Ident=static_cast(malloc(88*sizeof(sal_Char))); /* prepare S-SID_REVISION- */ dwSidSize=wsprintf(Ident, TEXT("S-%lu-"), dwSidRev); @@ -518,7 +519,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, strUserID = ::rtl::OUString::createFromAscii( Ident ); free(Ident); - delete [] reinterpret_cast(pSid); + delete [] static_cast(pSid); delete [] wszDomainName; /// check if logged in user is administrator: @@ -535,14 +536,14 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, &AdministratorsGroup); if(b) { - if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) + if (!CheckTokenMembership( nullptr, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } - isAdmin = ( sal_Bool )b; + isAdmin = b; #endif diff --git a/sal/qa/osl/setthreadname/test-setthreadname.cxx b/sal/qa/osl/setthreadname/test-setthreadname.cxx index d188b07214c7..600573008eba 100644 --- a/sal/qa/osl/setthreadname/test-setthreadname.cxx +++ b/sal/qa/osl/setthreadname/test-setthreadname.cxx @@ -41,7 +41,7 @@ public: void TestThread::run() { #if defined(_WIN32) - if (std::getenv("URE_TEST_SETTHREADNAME") != 0) { + if (std::getenv("URE_TEST_SETTHREADNAME") != nullptr) { // On Windows, setting thread names appears to only take effect when the // process is being debugged, so attach a debugger now: std::cout << "set: "; -- cgit