diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-10-14 16:57:24 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-16 14:19:22 +0000 |
commit | 08abfef116d893d6a062d432ff89e7af8b7b679d (patch) | |
tree | dc6f12f1669b40651a42b7a0556e264bc607a42b /desktop/win32 | |
parent | 1f9b6013e507ee4acb9374cee909f59139d52978 (diff) |
clang-cl loplugin: desktop
Change-Id: If2f5bfa6c05098c5362cd6c7b546520dc01ee821
Reviewed-on: https://gerrit.libreoffice.org/29871
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'desktop/win32')
-rw-r--r-- | desktop/win32/source/QuickStart/QuickStart.cxx | 23 | ||||
-rw-r--r-- | desktop/win32/source/QuickStart/StdAfx.h | 59 | ||||
-rw-r--r-- | desktop/win32/source/applauncher/launcher.cxx | 20 | ||||
-rw-r--r-- | desktop/win32/source/guiloader/genericloader.cxx | 10 | ||||
-rw-r--r-- | desktop/win32/source/guistdio/guistdio.inc | 52 | ||||
-rw-r--r-- | desktop/win32/source/loader.cxx | 10 | ||||
-rw-r--r-- | desktop/win32/source/officeloader/officeloader.cxx | 12 | ||||
-rw-r--r-- | desktop/win32/source/unoinfo.cxx | 4 |
8 files changed, 73 insertions, 117 deletions
diff --git a/desktop/win32/source/QuickStart/QuickStart.cxx b/desktop/win32/source/QuickStart/QuickStart.cxx index 5bf3fa6818bc..2c426be6c2bb 100644 --- a/desktop/win32/source/QuickStart/QuickStart.cxx +++ b/desktop/win32/source/QuickStart/QuickStart.cxx @@ -19,17 +19,32 @@ // QuickStart.cpp : Defines the entry point for the application. +#include <sal/config.h> + +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <shellapi.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif -#include "StdAfx.h" #include "resource.h" #include <systools/win32/uwinapi.h> #include <systools/win32/qswin32.h> + #include <stdio.h> +#include <stdlib.h> +#include <malloc.h> +#include <memory.h> +#include <tchar.h> bool SofficeRuns() { // check for soffice by searching the communication window - return ( FindWindowEx( NULL, NULL, QUICKSTART_CLASSNAME, NULL ) == NULL ) ? false : true; + return FindWindowEx( nullptr, nullptr, QUICKSTART_CLASSNAME, nullptr ) != nullptr; } bool launchSoffice( ) @@ -39,7 +54,7 @@ bool launchSoffice( ) char filename[_MAX_PATH + 1]; filename[_MAX_PATH] = 0; - GetModuleFileName( NULL, filename, _MAX_PATH ); // soffice resides in the same dir + GetModuleFileName( nullptr, filename, _MAX_PATH ); // soffice resides in the same dir char *p = strrchr( filename, '\\' ); if ( !p ) return false; @@ -72,7 +87,7 @@ int APIENTRY WinMain(HINSTANCE /*hInstance*/, { if ( 0 == strcmp( __argv[i], "--killtray" ) ) { - HWND hwndTray = FindWindow( QUICKSTART_CLASSNAME, NULL ); + HWND hwndTray = FindWindow( QUICKSTART_CLASSNAME, nullptr ); if ( hwndTray ) { diff --git a/desktop/win32/source/QuickStart/StdAfx.h b/desktop/win32/source/QuickStart/StdAfx.h deleted file mode 100644 index 74dcd6708b06..000000000000 --- a/desktop/win32/source/QuickStart/StdAfx.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently - - -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#ifdef _MSC_VER -#pragma once -#endif - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - - -// Windows Header Files: -#if defined _MSC_VER -#pragma warning(push, 1) -#endif -#include <windows.h> -#include <shellapi.h> -#if defined _MSC_VER -#pragma warning(pop) -#endif - -// C RunTime Header Files -#include <stdlib.h> -#include <malloc.h> -#include <memory.h> -#include <tchar.h> - -// Local Header Files - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/win32/source/applauncher/launcher.cxx b/desktop/win32/source/applauncher/launcher.cxx index 2aac505e80b7..029d1a17b28c 100644 --- a/desktop/win32/source/applauncher/launcher.cxx +++ b/desktop/win32/source/applauncher/launcher.cxx @@ -43,7 +43,7 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) LPTSTR lpCommandLine = GetCommandLine(); { - lpCommandLine = (LPTSTR)_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) ); + lpCommandLine = static_cast<LPTSTR>(_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) )); _tcscpy( lpCommandLine, GetCommandLine() ); _tcscat( lpCommandLine, _T(" ") ); @@ -59,7 +59,7 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) TCHAR szFileName[MAX_PATH]; TCHAR szExt[MAX_PATH]; - GetModuleFileName( NULL, szApplicationName, MAX_PATH ); + GetModuleFileName( nullptr, szApplicationName, MAX_PATH ); _tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt ); _tmakepath( szApplicationName, szDrive, szDir, _T("soffice"), _T(".exe") ); @@ -69,12 +69,12 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) BOOL fSuccess = CreateProcess( szApplicationName, lpCommandLine, - NULL, - NULL, + nullptr, + nullptr, TRUE, 0, - NULL, - NULL, + nullptr, + nullptr, &aStartupInfo, &aProcessInfo ); @@ -98,16 +98,16 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR)&lpMsgBuf, + reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, - NULL + nullptr ); // Display the string. - MessageBox( NULL, (LPCTSTR)lpMsgBuf, NULL, MB_OK | MB_ICONERROR ); + MessageBox( nullptr, static_cast<LPCTSTR>(lpMsgBuf), nullptr, MB_OK | MB_ICONERROR ); // Free the buffer. LocalFree( lpMsgBuf ); diff --git a/desktop/win32/source/guiloader/genericloader.cxx b/desktop/win32/source/guiloader/genericloader.cxx index 76ee748de1a4..5398610d396e 100644 --- a/desktop/win32/source/guiloader/genericloader.cxx +++ b/desktop/win32/source/guiloader/genericloader.cxx @@ -69,7 +69,7 @@ static int GenericMain() bool hasRedirect = tools::buildPath( redirect, szIniDirectory, szIniDirectory + iniDirLen, - MY_STRING(L"redirect.ini")) != NULL && + MY_STRING(L"redirect.ini")) != nullptr && (GetBinaryType(redirect, &dummy) || // cheaper check for file existence? GetLastError() != ERROR_FILE_NOT_FOUND); LPTSTR cl1 = GetCommandLine(); @@ -101,11 +101,11 @@ static int GenericMain() BOOL fSuccess = CreateProcess( szTargetFileName, cl2, - NULL, - NULL, + nullptr, + nullptr, TRUE, 0, - NULL, + nullptr, szIniDirectory, &aStartupInfo, &aProcessInfo ); @@ -127,7 +127,7 @@ static int GenericMain() { MSG msg; - PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ); + PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ); } } while ( WAIT_OBJECT_0 + 1 == dwWaitResult ); diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc index f918807ae9d5..d688db35f395 100644 --- a/desktop/win32/source/guistdio/guistdio.inc +++ b/desktop/win32/source/guistdio/guistdio.inc @@ -57,7 +57,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console) DWORD dwToRead = sizeof(aBuffer); BYTE * pBuffer = aBuffer; - while ( ReadFile( hReadPipe, pBuffer, dwToRead, &dwRead, NULL ) ) + while ( ReadFile( hReadPipe, pBuffer, dwToRead, &dwRead, nullptr ) ) { //If the previous ReadFile call read an odd number of bytes, then the last one was //put at the front of the buffer. We increase the number of read bytes by one to reflect @@ -66,13 +66,13 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console) dwRead++; //We must make sure that only complete wchar_t|s are written. WriteConsolse takes //the number of wchar_t|s as argument. ReadFile, however, reads bytes. - bIncompleteWchar = (dwRead % 2) ? true : false; + bIncompleteWchar = (dwRead % 2) != 0; if (bIncompleteWchar) { //To test this case, give aBuffer a small odd size, e.g. aBuffer[3] //The last byte, which is the incomplete wchar_t (half of it), will not be written. (void) WriteConsoleW( console, aBuffer, - (dwRead - 1) / 2, &dwWritten, NULL ); + (dwRead - 1) / 2, &dwWritten, nullptr ); //Move the last byte to the front of the buffer, so that it is the start of the //next string @@ -90,7 +90,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console) dwToRead = sizeof(aBuffer); pBuffer = aBuffer; (void) WriteConsoleW( console, - aBuffer, dwRead / 2, &dwWritten, NULL ); + aBuffer, dwRead / 2, &dwWritten, nullptr ); } } @@ -102,7 +102,7 @@ DWORD passOutputToConsole(HANDLE readPipe, HANDLE console) #ifdef UNOPKG DWORD WINAPI OutputThread( LPVOID pParam ) { - return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_OUTPUT_HANDLE )); + return passOutputToConsole(static_cast<HANDLE>(pParam), GetStdHandle( STD_OUTPUT_HANDLE )); } #else @@ -128,7 +128,7 @@ DWORD WINAPI OutputThread( LPVOID pParam ) #ifdef UNOPKG DWORD WINAPI ErrorThread( LPVOID pParam ) { - return passOutputToConsole((HANDLE)pParam, GetStdHandle( STD_ERROR_HANDLE )); + return passOutputToConsole(static_cast<HANDLE>(pParam), GetStdHandle( STD_ERROR_HANDLE )); } #else @@ -156,7 +156,7 @@ DWORD WINAPI ErrorThread( LPVOID pParam ) DWORD WINAPI InputThread( LPVOID pParam ) { DWORD dwRead = 0; - HANDLE hWritePipe = (HANDLE)pParam; + HANDLE hWritePipe = static_cast<HANDLE>(pParam); //We need to read in the complete input until we encounter a new line before //converting to Unicode. This is necessary because the input string can use @@ -167,19 +167,19 @@ DWORD WINAPI InputThread( LPVOID pParam ) //Characters may have one or multiple bytes and different byte ordering //can be used (little and big endian); int cNewLine = WideCharToMultiByte( - GetConsoleCP(), 0, L"\r\n", 2, NULL, 0, NULL, NULL); + GetConsoleCP(), 0, L"\r\n", 2, nullptr, 0, nullptr, nullptr); char * mbBuff = new char[cNewLine]; WideCharToMultiByte( - GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, NULL, NULL); + GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, nullptr, nullptr); const DWORD dwBufferSize = 256; - char* readBuf = (char*) malloc(dwBufferSize); + char* readBuf = static_cast<char*>(malloc(dwBufferSize)); int readAll = 0; DWORD curBufSize = dwBufferSize; while ( ReadFile( GetStdHandle( STD_INPUT_HANDLE ), readBuf + readAll, - curBufSize - readAll, &dwRead, NULL ) ) + curBufSize - readAll, &dwRead, nullptr ) ) { readAll += dwRead; int lastBufSize = curBufSize; @@ -187,7 +187,7 @@ DWORD WINAPI InputThread( LPVOID pParam ) if (readAll > curBufSize * 0.7) { curBufSize *= 2; - readBuf = (char *) realloc(readBuf, curBufSize); + readBuf = static_cast<char *>(realloc(readBuf, curBufSize)); } //If the buffer was filled completely then @@ -206,7 +206,7 @@ DWORD WINAPI InputThread( LPVOID pParam ) } //Obtain the size of the buffer for the converted string. int sizeWBuf = MultiByteToWideChar( - GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, NULL, 0); + GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, nullptr, 0); wchar_t * wideBuf = new wchar_t[sizeWBuf]; @@ -215,7 +215,7 @@ DWORD WINAPI InputThread( LPVOID pParam ) GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, wideBuf, sizeWBuf); DWORD dwWritten; - (void)WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, NULL ); + (void)WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, nullptr ); delete[] wideBuf; readAll = 0; @@ -297,7 +297,7 @@ int _tmain( int, _TCHAR ** ) HANDLE hOutputRead, hOutputWrite; - if ( CreatePipe( &hOutputRead, &hOutputWrite, NULL, 0 ) ) + if ( CreatePipe( &hOutputRead, &hOutputWrite, nullptr, 0 ) ) { HANDLE hTemp; @@ -312,7 +312,7 @@ int _tmain( int, _TCHAR ** ) HANDLE hErrorRead, hErrorWrite; - if ( CreatePipe( &hErrorRead, &hErrorWrite, NULL, 0 ) ) + if ( CreatePipe( &hErrorRead, &hErrorWrite, nullptr, 0 ) ) { HANDLE hTemp; @@ -327,7 +327,7 @@ int _tmain( int, _TCHAR ** ) HANDLE hInputRead, hInputWrite; - if ( CreatePipe( &hInputRead, &hInputWrite, NULL, 0 ) ) + if ( CreatePipe( &hInputRead, &hInputWrite, nullptr, 0 ) ) { HANDLE hTemp; @@ -342,7 +342,7 @@ int _tmain( int, _TCHAR ** ) TCHAR szModuleFileName[MAX_PATH]; - GetModuleFileName( NULL, szModuleFileName, MAX_PATH ); + GetModuleFileName( nullptr, szModuleFileName, MAX_PATH ); _TCHAR *lpLastDot = _tcsrchr( szModuleFileName, '.' ); if ( lpLastDot && 0 == _tcsicmp( lpLastDot, _T(".COM") ) ) { @@ -357,12 +357,12 @@ int _tmain( int, _TCHAR ** ) BOOL fSuccess = CreateProcess( szTargetFileName, GetCommandLine(), - NULL, - NULL, + nullptr, + nullptr, TRUE, 0, - NULL, - NULL, + nullptr, + nullptr, &aStartupInfo, &aProcessInfo ); @@ -381,14 +381,14 @@ int _tmain( int, _TCHAR ** ) DWORD dwOutputThreadId, dwErrorThreadId, dwInputThreadId; - HANDLE hOutputThread = CreateThread( NULL, 0, OutputThread, (LPVOID)hOutputRead, 0, &dwOutputThreadId ); - HANDLE hErrorThread = CreateThread( NULL, 0, OutputThread, (LPVOID)hErrorRead, 0, &dwErrorThreadId ); - HANDLE hInputThread = CreateThread( NULL, 0, InputThread, (LPVOID)hInputWrite, 0, &dwInputThreadId ); + HANDLE hOutputThread = CreateThread( nullptr, 0, OutputThread, static_cast<LPVOID>(hOutputRead), 0, &dwOutputThreadId ); + HANDLE hErrorThread = CreateThread( nullptr, 0, OutputThread, static_cast<LPVOID>(hErrorRead), 0, &dwErrorThreadId ); + HANDLE hInputThread = CreateThread( nullptr, 0, InputThread, static_cast<LPVOID>(hInputWrite), 0, &dwInputThreadId ); // Create thread that wait until child process entered input idle DWORD dwWaitForUIThreadId; - HANDLE hWaitForUIThread = CreateThread( NULL, 0, WaitForUIThread, (LPVOID)aProcessInfo.hProcess, 0, &dwWaitForUIThreadId ); + HANDLE hWaitForUIThread = CreateThread( nullptr, 0, WaitForUIThread, static_cast<LPVOID>(aProcessInfo.hProcess), 0, &dwWaitForUIThreadId ); HANDLE hObjects[] = { diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx index 95327fcdbfad..948d370987b5 100644 --- a/desktop/win32/source/loader.cxx +++ b/desktop/win32/source/loader.cxx @@ -36,12 +36,12 @@ namespace desktop_win32 { void getPaths(WCHAR * binPath, WCHAR * iniDirectory) { - if (!GetModuleFileNameW(NULL, iniDirectory, MAX_PATH)) { - LPWSTR buf = NULL; + if (!GetModuleFileNameW(nullptr, iniDirectory, MAX_PATH)) { + LPWSTR buf = nullptr; FormatMessageW( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, - GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, NULL); - MessageBoxW(NULL, buf, NULL, MB_OK | MB_ICONERROR); + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, + GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, nullptr); + MessageBoxW(nullptr, buf, nullptr, MB_OK | MB_ICONERROR); LocalFree(buf); TerminateProcess(GetCurrentProcess(), 255); } diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index ea442bd48de8..25277f1ff143 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -79,9 +79,9 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) DWORD dwExitCode = (DWORD)-1; BOOL fSuccess = FALSE; - LPTSTR lpCommandLine = NULL; + LPTSTR lpCommandLine = nullptr; int argc = 0; - LPTSTR * argv = NULL; + LPTSTR * argv = nullptr; bool bFirst = true; WCHAR cwd[MAX_PATH]; DWORD cwdLen = GetCurrentDirectoryW(MAX_PATH, cwd); @@ -159,11 +159,11 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) fSuccess = CreateProcess( szTargetFileName, lpCommandLine, - NULL, - NULL, + nullptr, + nullptr, TRUE, 0, - NULL, + nullptr, szIniDirectory, &aStartupInfo, &aProcessInfo ); @@ -183,7 +183,7 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) { MSG msg; - PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ); + PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ); } } while ( WAIT_OBJECT_0 + 1 == dwWaitResult ); diff --git a/desktop/win32/source/unoinfo.cxx b/desktop/win32/source/unoinfo.cxx index 5af29df90af7..4f8bbcc40be3 100644 --- a/desktop/win32/source/unoinfo.cxx +++ b/desktop/win32/source/unoinfo.cxx @@ -39,7 +39,7 @@ namespace { wchar_t * getBrandPath(wchar_t * path) { - DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH); + DWORD n = GetModuleFileNameW(nullptr, path, MAX_PATH); if (n == 0 || n >= MAX_PATH) { exit(EXIT_FAILURE); } @@ -59,7 +59,7 @@ void writePath( wchar_t path[MAX_PATH]; wchar_t * end = tools::buildPath( path, frontBegin, frontEnd, backBegin, backLength); - if (end == NULL) { + if (end == nullptr) { exit(EXIT_FAILURE); } std::size_t n = (end - path) * sizeof (wchar_t); |