From ea16804751eec498e34a3048a295a1dfafbc1612 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Fri, 5 Jun 2020 00:51:32 +0200 Subject: [PATCH] Replace NULL by nullptr in all C++ files We keep NULL in the pure C files in src/csync/std and test/csync. We also replace Doxygen documentation referring to "NULL" to "\c nullptr" (formatted as code). Signed-off-by: Stephan Beyer --- .../windows/OCContextMenu/OCContextMenu.cpp | 4 +-- .../OCContextMenu/OCContextMenuFactory.cpp | 4 +-- .../OCContextMenu/OCContextMenuRegHandler.cpp | 30 ++++++++-------- .../windows/OCContextMenu/RegDelnode.h | 8 ++--- .../windows/OCContextMenu/dllmain.cpp | 4 +-- .../windows/OCOverlays/DllMain.cpp | 2 +- .../windows/OCOverlays/OCOverlay.cpp | 2 +- .../windows/OCOverlays/OCOverlayFactory.cpp | 6 ++-- .../OCOverlayRegistrationHandler.cpp | 36 +++++++++---------- .../windows/OCUtil/CommunicationSocket.cpp | 8 ++--- .../windows/OCUtil/RegistryUtil.cpp | 8 ++--- .../windows/OCUtil/RemotePathChecker.cpp | 10 +++--- .../qtlockedfile/qtlockedfile_win.cpp | 4 +-- src/common/filesystembase.cpp | 22 ++++++------ src/common/filesystembase.h | 2 +- src/common/utility.cpp | 2 +- src/common/utility_mac.cpp | 12 +++---- src/common/utility_win.cpp | 2 +- src/csync/csync.h | 4 +-- src/csync/csync_reconcile.cpp | 2 +- src/csync/csync_update.cpp | 4 +-- src/csync/std/c_utf8.cpp | 8 ++--- src/csync/std/c_utf8.h | 2 +- src/csync/vio/csync_vio_local_win.cpp | 18 +++++----- .../cloudproviders/cloudproviderwrapper.cpp | 2 +- src/gui/folderman.h | 2 +- src/gui/folderwatcher_mac.cpp | 6 ++-- src/gui/folderwatcher_win.cpp | 12 +++---- .../csync/csync_tests/check_csync_exclude.cpp | 4 +-- test/csync/csync_tests/check_csync_misc.cpp | 2 +- test/csync/csync_tests/check_csync_update.cpp | 16 ++++----- test/csync/csync_tests/check_csync_util.cpp | 2 +- test/csync/encoding_tests/check_encoding.cpp | 8 ++--- test/csync/vio_tests/check_vio.cpp | 6 ++-- test/csync/vio_tests/check_vio_ext.cpp | 8 ++--- test/testnextcloudpropagator.cpp | 2 +- 36 files changed, 137 insertions(+), 137 deletions(-) diff --git a/shell_integration/windows/OCContextMenu/OCContextMenu.cpp b/shell_integration/windows/OCContextMenu/OCContextMenu.cpp index 9e9052211..a5cab4ff1 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenu.cpp +++ b/shell_integration/windows/OCContextMenu/OCContextMenu.cpp @@ -81,14 +81,14 @@ IFACEMETHODIMP OCContextMenu::Initialize( return E_INVALIDARG; } - FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + FORMATETC fe = { CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stm; if (SUCCEEDED(pDataObj->GetData(&fe, &stm))) { // Get an HDROP handle. HDROP hDrop = static_cast(GlobalLock(stm.hGlobal)); if (hDrop) { - UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); + UINT nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, nullptr, 0); for (UINT i = 0; i < nFiles; ++i) { // Get the path of the file. wchar_t buffer[MAX_PATH]; diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp b/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp index 006a0091a..13eb904a9 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp +++ b/shell_integration/windows/OCContextMenu/OCContextMenuFactory.cpp @@ -65,7 +65,7 @@ IFACEMETHODIMP OCContextMenuFactory::CreateInstance(IUnknown *pUnkOuter, REFIID HRESULT hr = CLASS_E_NOAGGREGATION; // pUnkOuter is used for aggregation. We do not support it in the sample. - if (pUnkOuter == NULL) { + if (pUnkOuter == nullptr) { hr = E_OUTOFMEMORY; // Create the COM component. @@ -88,4 +88,4 @@ IFACEMETHODIMP OCContextMenuFactory::LockServer(BOOL fLock) InterlockedDecrement(&g_cDllRef); } return S_OK; -} \ No newline at end of file +} diff --git a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp b/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp index 1bbfc6605..6c04734da 100644 --- a/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp +++ b/shell_integration/windows/OCContextMenu/OCContextMenuRegHandler.cpp @@ -24,16 +24,16 @@ namespace { HRESULT SetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PCWSTR pszData) { HRESULT hr; - HKEY hKey = NULL; + HKEY hKey = nullptr; // Creates the specified registry key. If the key already exists, the // function opens it. hr = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0, - NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL)); + nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &hKey, nullptr)); if (SUCCEEDED(hr)) { - if (pszData != NULL) + if (pszData != nullptr) { // Set the specified value of the key. DWORD cbData = lstrlen(pszData) * sizeof(*pszData); @@ -50,7 +50,7 @@ HRESULT SetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PCWSTR HRESULT GetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PWSTR pszData, DWORD cbData) { HRESULT hr; - HKEY hKey = NULL; + HKEY hKey = nullptr; // Try to open the specified registry key. hr = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, pszSubKey, 0, @@ -59,8 +59,8 @@ HRESULT GetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PWSTR if (SUCCEEDED(hr)) { // Get the data for the specified value name. - hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, NULL, - NULL, reinterpret_cast(pszData), &cbData)); + hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, nullptr, + nullptr, reinterpret_cast(pszData), &cbData)); RegCloseKey(hKey); } @@ -72,7 +72,7 @@ HRESULT GetHKCRRegistryKeyAndValue(PCWSTR pszSubKey, PCWSTR pszValueName, PWSTR HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel) { - if (pszModule == NULL || pszThreadModel == NULL) + if (pszModule == nullptr || pszThreadModel == nullptr) { return E_INVALIDARG; } @@ -88,7 +88,7 @@ HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CL hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID); if (SUCCEEDED(hr)) { - hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszFriendlyName); + hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, pszFriendlyName); // Create the HKCR\CLSID\{}\InprocServer32 key. if (SUCCEEDED(hr)) @@ -99,7 +99,7 @@ HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CL { // Set the default value of the InprocServer32 key to the // path of the COM module. - hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, pszModule); + hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, pszModule); if (SUCCEEDED(hr)) { // Set the threading model of the component. @@ -136,7 +136,7 @@ HRESULT OCContextMenuRegHandler::UnregisterInprocServer(const CLSID& clsid) HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName) { - if (pszFileType == NULL) + if (pszFileType == nullptr) { return E_INVALIDARG; } @@ -154,7 +154,7 @@ HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( if (*pszFileType == L'.') { wchar_t szDefaultVal[260]; - hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal, + hr = GetHKCRRegistryKeyAndValue(pszFileType, nullptr, szDefaultVal, sizeof(szDefaultVal)); // If the key exists and its default value is not empty, use the @@ -171,7 +171,7 @@ HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( if (SUCCEEDED(hr)) { // Set the default value of the key. - hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, szCLSID); + hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, szCLSID); } return hr; @@ -180,7 +180,7 @@ HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler( HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler( PCWSTR pszFileType, PCWSTR pszFriendlyName) { - if (pszFileType == NULL) + if (pszFileType == nullptr) { return E_INVALIDARG; } @@ -195,7 +195,7 @@ HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler( if (*pszFileType == L'.') { wchar_t szDefaultVal[260]; - hr = GetHKCRRegistryKeyAndValue(pszFileType, NULL, szDefaultVal, + hr = GetHKCRRegistryKeyAndValue(pszFileType, nullptr, szDefaultVal, sizeof(szDefaultVal)); // If the key exists and its default value is not empty, use the @@ -215,4 +215,4 @@ HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler( } return hr; -} \ No newline at end of file +} diff --git a/shell_integration/windows/OCContextMenu/RegDelnode.h b/shell_integration/windows/OCContextMenu/RegDelnode.h index 633745b62..f79d1dcca 100644 --- a/shell_integration/windows/OCContextMenu/RegDelnode.h +++ b/shell_integration/windows/OCContextMenu/RegDelnode.h @@ -58,8 +58,8 @@ HRESULT RegDelnodeRecurse(HKEY hKeyRoot, LPTSTR lpSubKey) // Enumerate the keys dwSize = MAX_PATH; - lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, - NULL, NULL, &ftWrite); + lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, nullptr, + nullptr, nullptr, &ftWrite); if (lResult == ERROR_SUCCESS) { @@ -73,8 +73,8 @@ HRESULT RegDelnodeRecurse(HKEY hKeyRoot, LPTSTR lpSubKey) dwSize = MAX_PATH; - lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, - NULL, NULL, &ftWrite); + lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, nullptr, + nullptr, nullptr, &ftWrite); } while (lResult == ERROR_SUCCESS); } diff --git a/shell_integration/windows/OCContextMenu/dllmain.cpp b/shell_integration/windows/OCContextMenu/dllmain.cpp index 088dea767..8cd31fea4 100644 --- a/shell_integration/windows/OCContextMenu/dllmain.cpp +++ b/shell_integration/windows/OCContextMenu/dllmain.cpp @@ -22,7 +22,7 @@ // {841A0AAD-AA11-4B50-84D9-7F8E727D77D7} static const GUID CLSID_FileContextMenuExt = { 0x841a0aad, 0xaa11, 0x4b50, { 0x84, 0xd9, 0x7f, 0x8e, 0x72, 0x7d, 0x77, 0xd7 } }; -HINSTANCE g_hInst = NULL; +HINSTANCE g_hInst = nullptr; long g_cDllRef = 0; BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) @@ -105,4 +105,4 @@ STDAPI DllUnregisterServer(void) } return hr; -} \ No newline at end of file +} diff --git a/shell_integration/windows/OCOverlays/DllMain.cpp b/shell_integration/windows/OCOverlays/DllMain.cpp index 02166f591..00195b6e5 100644 --- a/shell_integration/windows/OCOverlays/DllMain.cpp +++ b/shell_integration/windows/OCOverlays/DllMain.cpp @@ -17,7 +17,7 @@ #include "OCOverlayRegistrationHandler.h" #include "OCOverlayFactory.h" -HINSTANCE instanceHandle = NULL; +HINSTANCE instanceHandle = nullptr; long dllReferenceCount = 0; diff --git a/shell_integration/windows/OCOverlays/OCOverlay.cpp b/shell_integration/windows/OCOverlays/OCOverlay.cpp index dd03a8664..f7ff64f5b 100644 --- a/shell_integration/windows/OCOverlays/OCOverlay.cpp +++ b/shell_integration/windows/OCOverlays/OCOverlay.cpp @@ -82,7 +82,7 @@ IFACEMETHODIMP OCOverlay::QueryInterface(REFIID riid, void **ppv) else { hr = E_NOINTERFACE; - *ppv = NULL; + *ppv = nullptr; } if (*ppv) diff --git a/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp b/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp index 1a317dae1..34b22f539 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp +++ b/shell_integration/windows/OCOverlays/OCOverlayFactory.cpp @@ -43,7 +43,7 @@ IFACEMETHODIMP OCOverlayFactory::QueryInterface(REFIID riid, void **ppv) else { hResult = E_NOINTERFACE; - *ppv = NULL; + *ppv = nullptr; } return hResult; @@ -70,7 +70,7 @@ IFACEMETHODIMP OCOverlayFactory::CreateInstance( { HRESULT hResult = CLASS_E_NOAGGREGATION; - if (pUnkOuter != NULL) { return hResult; } + if (pUnkOuter != nullptr) { return hResult; } hResult = E_OUTOFMEMORY; OCOverlay *lrOverlay = new (std::nothrow) OCOverlay(_state); @@ -90,4 +90,4 @@ IFACEMETHODIMP OCOverlayFactory::LockServer(BOOL fLock) InterlockedDecrement(&dllReferenceCount); } return S_OK; -} \ No newline at end of file +} diff --git a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp b/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp index 0ef83b84c..b10d64671 100644 --- a/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp +++ b/shell_integration/windows/OCOverlays/OCOverlayRegistrationHandler.cpp @@ -24,9 +24,9 @@ using namespace std; HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PCWSTR friendlyName) { HRESULT hResult; - HKEY shellOverlayKey = NULL; + HKEY shellOverlayKey = nullptr; // the key may not exist yet - hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &shellOverlayKey, NULL)); + hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &shellOverlayKey, nullptr)); if (!SUCCEEDED(hResult)) { hResult = RegCreateKey(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, &shellOverlayKey); if(!SUCCEEDED(hResult)) { @@ -34,8 +34,8 @@ HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PC } } - HKEY syncExOverlayKey = NULL; - hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(shellOverlayKey, friendlyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &syncExOverlayKey, NULL)); + HKEY syncExOverlayKey = nullptr; + hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(shellOverlayKey, friendlyName, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &syncExOverlayKey, nullptr)); if (!SUCCEEDED(hResult)) { return hResult; @@ -44,7 +44,7 @@ HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PC wchar_t stringCLSID[MAX_PATH]; StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID)); LPCTSTR value = stringCLSID; - hResult = RegSetValueEx(syncExOverlayKey, NULL, 0, REG_SZ, (LPBYTE)value, (DWORD)((wcslen(value)+1) * sizeof(TCHAR))); + hResult = RegSetValueEx(syncExOverlayKey, nullptr, 0, REG_SZ, (LPBYTE)value, (DWORD)((wcslen(value)+1) * sizeof(TCHAR))); if (!SUCCEEDED(hResult)) { return hResult; } @@ -55,14 +55,14 @@ HRESULT OCOverlayRegistrationHandler::MakeRegistryEntries(const CLSID& clsid, PC HRESULT OCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName) { HRESULT hResult; - HKEY shellOverlayKey = NULL; + HKEY shellOverlayKey = nullptr; hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_OVERLAY_KEY, 0, KEY_WRITE, &shellOverlayKey)); if (!SUCCEEDED(hResult)) { return hResult; } - HKEY syncExOverlayKey = NULL; + HKEY syncExOverlayKey = nullptr; hResult = HRESULT_FROM_WIN32(RegDeleteKey(shellOverlayKey, friendlyName)); if (!SUCCEEDED(hResult)) { return hResult; @@ -73,35 +73,35 @@ HRESULT OCOverlayRegistrationHandler::RemoveRegistryEntries(PCWSTR friendlyName) HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid) { - if (modulePath == NULL) { + if (modulePath == nullptr) { return E_FAIL; } wchar_t stringCLSID[MAX_PATH]; StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID)); HRESULT hResult; - HKEY hKey = NULL; + HKEY hKey = nullptr; hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, KEY_WRITE, &hKey)); if (!SUCCEEDED(hResult)) { return hResult; } - HKEY clsidKey = NULL; - hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(hKey, stringCLSID, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &clsidKey, NULL)); + HKEY clsidKey = nullptr; + hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(hKey, stringCLSID, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &clsidKey, nullptr)); if(!SUCCEEDED(hResult)) { return hResult; } - hResult = HRESULT_FROM_WIN32(RegSetValue(clsidKey, NULL, REG_SZ, friendlyName, (DWORD) wcslen(friendlyName))); + hResult = HRESULT_FROM_WIN32(RegSetValue(clsidKey, nullptr, REG_SZ, friendlyName, (DWORD) wcslen(friendlyName))); - HKEY inprocessKey = NULL; - hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_IN_PROCESS, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &inprocessKey, NULL)); + HKEY inprocessKey = nullptr; + hResult = HRESULT_FROM_WIN32(RegCreateKeyEx(clsidKey, REGISTRY_IN_PROCESS, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &inprocessKey, nullptr)); if(!SUCCEEDED(hResult)) { return hResult; } - hResult = HRESULT_FROM_WIN32(RegSetValue(inprocessKey, NULL, REG_SZ, modulePath, (DWORD) wcslen(modulePath))); + hResult = HRESULT_FROM_WIN32(RegSetValue(inprocessKey, nullptr, REG_SZ, modulePath, (DWORD) wcslen(modulePath))); if(!SUCCEEDED(hResult)) { return hResult; @@ -126,13 +126,13 @@ HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid) StringFromGUID2(clsid, stringCLSID, ARRAYSIZE(stringCLSID)); HRESULT hResult; - HKEY hKey = NULL; + HKEY hKey = nullptr; hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, REGISTRY_CLSID, 0, DELETE, &hKey)); if (!SUCCEEDED(hResult)) { return hResult; } - HKEY clsidKey = NULL; + HKEY clsidKey = nullptr; hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(hKey, stringCLSID, 0, DELETE, &clsidKey)); if(!SUCCEEDED(hResult)) { return hResult; @@ -149,4 +149,4 @@ HRESULT OCOverlayRegistrationHandler::UnregisterCOMObject(const CLSID& clsid) } return S_OK; -} \ No newline at end of file +} diff --git a/shell_integration/windows/OCUtil/CommunicationSocket.cpp b/shell_integration/windows/OCUtil/CommunicationSocket.cpp index b7dd64c32..f24b30ba6 100644 --- a/shell_integration/windows/OCUtil/CommunicationSocket.cpp +++ b/shell_integration/windows/OCUtil/CommunicationSocket.cpp @@ -73,7 +73,7 @@ bool CommunicationSocket::Close() bool CommunicationSocket::Connect(const std::wstring &pipename) { - _pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + _pipe = CreateFile(pipename.data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); if (_pipe == INVALID_HANDLE_VALUE) { return false; @@ -87,7 +87,7 @@ bool CommunicationSocket::SendMsg(const wchar_t* message) const auto utf8_msg = StringUtil::toUtf8(message); DWORD numBytesWritten = 0; - auto result = WriteFile( _pipe, utf8_msg.c_str(), DWORD(utf8_msg.size()), &numBytesWritten, NULL); + auto result = WriteFile( _pipe, utf8_msg.c_str(), DWORD(utf8_msg.size()), &numBytesWritten, nullptr); if (result) { return true; @@ -123,7 +123,7 @@ bool CommunicationSocket::ReadLine(wstring* response) DWORD numBytesRead = 0; DWORD totalBytesAvailable = 0; - if (!PeekNamedPipe(_pipe, NULL, 0, 0, &totalBytesAvailable, 0)) { + if (!PeekNamedPipe(_pipe, nullptr, 0, 0, &totalBytesAvailable, 0)) { Close(); return false; } @@ -131,7 +131,7 @@ bool CommunicationSocket::ReadLine(wstring* response) return false; } - if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, NULL)) { + if (!ReadFile(_pipe, resp_utf8.data(), DWORD(resp_utf8.size()), &numBytesRead, nullptr)) { Close(); return false; } diff --git a/shell_integration/windows/OCUtil/RegistryUtil.cpp b/shell_integration/windows/OCUtil/RegistryUtil.cpp index 5542ac4d6..fc8b125dc 100644 --- a/shell_integration/windows/OCUtil/RegistryUtil.cpp +++ b/shell_integration/windows/OCUtil/RegistryUtil.cpp @@ -38,9 +38,9 @@ bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, wstring { HRESULT hResult; - HKEY rootKey = NULL; + HKEY rootKey = nullptr; - hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, NULL, KEY_READ, &rootKey)); + hResult = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCWSTR)key, nullptr, KEY_READ, &rootKey)); if(!SUCCEEDED(hResult)) { @@ -49,8 +49,8 @@ bool RegistryUtil::ReadRegistry(const wchar_t* key, const wchar_t* name, wstring wchar_t value[SIZE]; DWORD value_length = SIZE; - - hResult = RegQueryValueEx(rootKey, (LPCWSTR)name, NULL, NULL, (LPBYTE)value, &value_length ); + + hResult = RegQueryValueEx(rootKey, (LPCWSTR)name, nullptr, nullptr, (LPBYTE)value, &value_length ); if(!SUCCEEDED(hResult)) { diff --git a/shell_integration/windows/OCUtil/RemotePathChecker.cpp b/shell_integration/windows/OCUtil/RemotePathChecker.cpp index 37caee182..99b46d3ba 100644 --- a/shell_integration/windows/OCUtil/RemotePathChecker.cpp +++ b/shell_integration/windows/OCUtil/RemotePathChecker.cpp @@ -83,7 +83,7 @@ void RemotePathChecker::workerThreadLoop() // We don't keep track of all files and can't know which file is currently visible // to the user, but at least reload the root dir so that any shortcut to the root // is updated without the user needing to refresh. - SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL); + SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), nullptr); } else if (StringUtil::begins_with(response, wstring(L"UNREGISTER_PATH:"))) { wstring responsePath = response.substr(16); // length of UNREGISTER_PATH: @@ -107,7 +107,7 @@ void RemotePathChecker::workerThreadLoop() } } for (auto& path : removedPaths) - SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, path.data(), NULL); + SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, path.data(), nullptr); } else if (StringUtil::begins_with(response, wstring(L"STATUS:")) || StringUtil::begins_with(response, wstring(L"BROADCAST:"))) { @@ -135,7 +135,7 @@ void RemotePathChecker::workerThreadLoop() it->second = state; } if (updateView) { - SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), NULL); + SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, responsePath.data(), nullptr); } } } @@ -151,7 +151,7 @@ void RemotePathChecker::workerThreadLoop() lock.unlock(); // Let explorer know about each invalidated cache entry that needs to get its icon removed. for (auto it = cache.begin(); it != cache.end(); ++it) { - SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, it->first.data(), NULL); + SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, it->first.data(), nullptr); } } @@ -168,7 +168,7 @@ RemotePathChecker::RemotePathChecker() : _stop(false) , _watchedDirectories(make_shared>()) , _connected(false) - , _newQueries(CreateEvent(NULL, FALSE, FALSE, NULL)) + , _newQueries(CreateEvent(nullptr, FALSE, FALSE, nullptr)) , _thread([this]{ this->workerThreadLoop(); }) { } diff --git a/src/3rdparty/qtlockedfile/qtlockedfile_win.cpp b/src/3rdparty/qtlockedfile/qtlockedfile_win.cpp index ae6286fce..d7d855bbf 100644 --- a/src/3rdparty/qtlockedfile/qtlockedfile_win.cpp +++ b/src/3rdparty/qtlockedfile/qtlockedfile_win.cpp @@ -94,7 +94,7 @@ bool QtLockedFile::lock(LockMode mode, bool block) QString mut_name = QString::fromLatin1(MUTEX_PREFIX) + fi.absoluteFilePath().toLower(); - m_mutex_hnd = CreateMutexW(NULL, FALSE, (TCHAR*)mut_name.utf16()); + m_mutex_hnd = CreateMutexW(nullptr, FALSE, (TCHAR*)mut_name.utf16()); if (m_mutex_hnd == 0) { qWarning("QtLockedFile::lock(): CreateMutex: %s", @@ -118,7 +118,7 @@ bool QtLockedFile::lock(LockMode mode, bool block) if (res == WAIT_TIMEOUT) { if (i) { // A failed nonblocking rw locking. Undo changes to semaphore. - if (ReleaseSemaphore(m_semaphore_hnd, i, NULL) == 0) { + if (ReleaseSemaphore(m_semaphore_hnd, i, nullptr) == 0) { qWarning("QtLockedFile::unlock(): ReleaseSemaphore: %s", errorCodeToString(GetLastError()).toLatin1().constData()); // Fall through diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index 9a7401cda..464c2edc6 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -147,8 +147,8 @@ bool FileSystem::rename(const QString &originFileName, if (!success) { wchar_t *string = 0; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&string, 0, NULL); + nullptr, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&string, 0, nullptr); error = QString::fromWCharArray(string); LocalFree((HLOCAL)string); @@ -216,8 +216,8 @@ bool FileSystem::uncheckedRenameReplace(const QString &originFileName, if (!ok) { wchar_t *string = 0; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&string, 0, NULL); + nullptr, ::GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&string, 0, nullptr); *errorString = QString::fromWCharArray(string); qCWarning(lcFileSystem) << "Renaming temp file to final failed: " << *errorString; @@ -248,7 +248,7 @@ bool FileSystem::openAndSeekFileSharedRead(QFile *file, QString *errorOrNull, qi DWORD creationDisp = OPEN_EXISTING; // Create the file handle. - SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; + SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), nullptr, FALSE }; QString fName = longWinPath(file->fileName()); HANDLE fileHandle = CreateFileW( @@ -258,7 +258,7 @@ bool FileSystem::openAndSeekFileSharedRead(QFile *file, QString *errorOrNull, qi &securityAtts, creationDisp, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); // Bail out on error. if (fileHandle == INVALID_HANDLE_VALUE) { @@ -352,8 +352,8 @@ QString FileSystem::fileSystemForPath(const QString &path) if (!GetVolumeInformationW( reinterpret_cast(drive.utf16()), - NULL, 0, - NULL, NULL, NULL, + nullptr, 0, + nullptr, nullptr, nullptr, fileSystemBuffer, fileSystemBufferSize)) { return QString(); } @@ -516,9 +516,9 @@ bool FileSystem::isFileLocked(const QString &fileName) wuri, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, - NULL); + nullptr); if (win_h == INVALID_HANDLE_VALUE) { /* could not be opened, so locked? */ @@ -543,7 +543,7 @@ bool FileSystem::isJunction(const QString &filename) { #ifdef Q_OS_WIN WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFileEx((const wchar_t *)filename.utf16(), FindExInfoBasic, &findData, FindExSearchNameMatch, NULL, 0); + HANDLE hFind = FindFirstFileEx((const wchar_t *)filename.utf16(), FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr, 0); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); return false; diff --git a/src/common/filesystembase.h b/src/common/filesystembase.h index d889930b6..c5bed6558 100644 --- a/src/common/filesystembase.h +++ b/src/common/filesystembase.h @@ -91,7 +91,7 @@ namespace FileSystem { */ bool OCSYNC_EXPORT rename(const QString &originFileName, const QString &destinationFileName, - QString *errorString = NULL); + QString *errorString = nullptr); /** * Rename the file \a originFileName to \a destinationFileName, and diff --git a/src/common/utility.cpp b/src/common/utility.cpp index 495032312..28f507696 100644 --- a/src/common/utility.cpp +++ b/src/common/utility.cpp @@ -215,7 +215,7 @@ qint64 Utility::freeDiskSpace(const QString &path) #elif defined(Q_OS_WIN) ULARGE_INTEGER freeBytes; freeBytes.QuadPart = 0L; - if (GetDiskFreeSpaceEx(reinterpret_cast(path.utf16()), &freeBytes, NULL, NULL)) { + if (GetDiskFreeSpaceEx(reinterpret_cast(path.utf16()), &freeBytes, nullptr, nullptr)) { return freeBytes.QuadPart; } #endif diff --git a/src/common/utility_mac.cpp b/src/common/utility_mac.cpp index 4d09db99b..befef0cbc 100644 --- a/src/common/utility_mac.cpp +++ b/src/common/utility_mac.cpp @@ -56,9 +56,9 @@ bool hasLaunchOnStartup_private(const QString &) CFStringRef appUrlRefString = CFURLGetString(urlRef); // no need for release for (int i = 0; i < CFArrayGetCount(itemsArray); i++) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(itemsArray, i); - CFURLRef itemUrlRef = NULL; + CFURLRef itemUrlRef = nullptr; - if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, NULL) == noErr && itemUrlRef) { + if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, nullptr) == noErr && itemUrlRef) { CFStringRef itemUrlString = CFURLGetString(itemUrlRef); if (CFStringCompare(itemUrlString, appUrlRefString, 0) == kCFCompareEqualTo) { returnValue = true; @@ -98,9 +98,9 @@ void setLaunchOnStartup_private(const QString &appName, const QString &guiName, CFStringRef appUrlRefString = CFURLGetString(urlRef); for (int i = 0; i < CFArrayGetCount(itemsArray); i++) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(itemsArray, i); - CFURLRef itemUrlRef = NULL; + CFURLRef itemUrlRef = nullptr; - if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, NULL) == noErr && itemUrlRef) { + if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, nullptr) == noErr && itemUrlRef) { CFStringRef itemUrlString = CFURLGetString(itemUrlRef); if (CFStringCompare(itemUrlString, appUrlRefString, 0) == kCFCompareEqualTo) { LSSharedFileListItemRemove(loginItems, item); // remove it! @@ -120,11 +120,11 @@ static bool hasDarkSystray_private() { bool returnValue = false; CFStringRef interfaceStyleKey = CFSTR("AppleInterfaceStyle"); - CFStringRef interfaceStyle = NULL; + CFStringRef interfaceStyle = nullptr; CFStringRef darkInterfaceStyle = CFSTR("Dark"); interfaceStyle = (CFStringRef)CFPreferencesCopyAppValue(interfaceStyleKey, kCFPreferencesCurrentApplication); - if (interfaceStyle != NULL) { + if (interfaceStyle != nullptr) { returnValue = (kCFCompareEqualTo == CFStringCompare(interfaceStyle, darkInterfaceStyle, 0)); CFRelease(interfaceStyle); } diff --git a/src/common/utility_win.cpp b/src/common/utility_win.cpp index 3a8c16fff..f8157a68a 100644 --- a/src/common/utility_win.cpp +++ b/src/common/utility_win.cpp @@ -57,7 +57,7 @@ static void setupFavLink_private(const QString &folder) /* Use new WINAPI functions */ PWSTR path; - if (SHGetKnownFolderPath(FOLDERID_Links, 0, NULL, &path) == S_OK) { + if (SHGetKnownFolderPath(FOLDERID_Links, 0, nullptr, &path) == S_OK) { QString links = QDir::fromNativeSeparators(QString::fromWCharArray(path)); linkName = QDir(links).filePath(folderDir.dirName() + QLatin1String(".lnk")); CoTaskMemFree(path); diff --git a/src/csync/csync.h b/src/csync/csync.h index 408693205..f23e9d21c 100644 --- a/src/csync/csync.h +++ b/src/csync/csync.h @@ -235,7 +235,7 @@ int OCSYNC_EXPORT csync_reconcile(CSYNC *ctx); * * @param ctx The csync context. * - * @return The userdata saved in the context, NULL if an error + * @return The userdata saved in the context, \c nullptr if an error * occurred. */ void *csync_get_userdata(CSYNC *ctx); @@ -257,7 +257,7 @@ int OCSYNC_EXPORT csync_set_userdata(CSYNC *ctx, void *userdata); * * @param ctx The csync context. * - * @return The authentication callback set or NULL if an error + * @return The authentication callback set or \c nullptr if an error * occurred. */ csync_auth_callback OCSYNC_EXPORT csync_get_auth_callback(CSYNC *ctx); diff --git a/src/csync/csync_reconcile.cpp b/src/csync/csync_reconcile.cpp index 371db2328..8b947c651 100644 --- a/src/csync/csync_reconcile.cpp +++ b/src/csync/csync_reconcile.cpp @@ -37,7 +37,7 @@ Q_LOGGING_CATEGORY(lcReconcile, "nextcloud.sync.csync.reconciler", QtInfoMsg) #include "inttypes.h" /* Check if a file is ignored because one parent is ignored. - * return the node of the ignored directoy if it's the case, or NULL if it is not ignored */ + * return the node of the ignored directoy if it's the case, or \c nullptr if it is not ignored */ static csync_file_stat_t *_csync_check_ignored(csync_s::FileMap *tree, const ByteArrayRef &path) { /* compute the size of the parent directory */ diff --git a/src/csync/csync_update.cpp b/src/csync/csync_update.cpp index f7320d9bd..7ddd203f3 100644 --- a/src/csync/csync_update.cpp +++ b/src/csync/csync_update.cpp @@ -63,8 +63,8 @@ static bool _csync_sameextension(const char *p1, const char *p2) { /* If the found extension contains a '/', it is because the . was in the folder name * => no extensions */ - if (e1 && strchr(e1, '/')) e1 = NULL; - if (e2 && strchr(e2, '/')) e2 = NULL; + if (e1 && strchr(e1, '/')) e1 = nullptr; + if (e2 && strchr(e2, '/')) e2 = nullptr; /* If none have extension, it is the same extension */ if (!e1 && !e2) diff --git a/src/csync/std/c_utf8.cpp b/src/csync/std/c_utf8.cpp index fe3b8ca20..4fb2c9273 100644 --- a/src/csync/std/c_utf8.cpp +++ b/src/csync/std/c_utf8.cpp @@ -53,10 +53,10 @@ QByteArray c_utf8_from_locale(const mbchar_t *wstr) size_t len; len = wcslen(wstr); /* Call once to get the required size. */ - size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr, OCC::Utility::convertSizeToInt(len), NULL, 0, NULL, NULL); + size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr, OCC::Utility::convertSizeToInt(len), nullptr, 0, nullptr, nullptr); if (size_needed > 0) { dst.resize(size_needed); - WideCharToMultiByte(CP_UTF8, 0, wstr, OCC::Utility::convertSizeToInt(len), dst.data(), size_needed, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, wstr, OCC::Utility::convertSizeToInt(len), dst.data(), size_needed, nullptr, nullptr); } return dst; #else @@ -91,12 +91,12 @@ mbchar_t* c_utf8_string_to_locale(const char *str) return nullptr; } #ifdef _WIN32 - mbchar_t *dst = NULL; + mbchar_t *dst = nullptr; size_t len; int size_needed; len = strlen(str); - size_needed = MultiByteToWideChar(CP_UTF8, 0, str, OCC::Utility::convertSizeToInt(len), NULL, 0); + size_needed = MultiByteToWideChar(CP_UTF8, 0, str, OCC::Utility::convertSizeToInt(len), nullptr, 0); if (size_needed > 0) { int size_char = (size_needed + 1) * sizeof(mbchar_t); dst = (mbchar_t*)c_malloc(size_char); diff --git a/src/csync/std/c_utf8.h b/src/csync/std/c_utf8.h index 6fbb8afe9..2bbe1d4bd 100644 --- a/src/csync/std/c_utf8.h +++ b/src/csync/std/c_utf8.h @@ -83,7 +83,7 @@ extern "C" { * * @param str The utf8 string to convert. * - * @return The malloced converted multibyte string or NULL on error. + * @return The malloced converted multibyte string or \c nullptr on error. * * @see c_free_locale_string() * @see c_utf8_from_locale() diff --git a/src/csync/vio/csync_vio_local_win.cpp b/src/csync/vio/csync_vio_local_win.cpp index 9955c230e..920cbf1fe 100644 --- a/src/csync/vio/csync_vio_local_win.cpp +++ b/src/csync/vio/csync_vio_local_win.cpp @@ -53,15 +53,15 @@ typedef struct dhandle_s { static int _csync_vio_local_stat_mb(const mbchar_t *uri, csync_file_stat_t *buf); csync_vio_handle_t *csync_vio_local_opendir(const char *name) { - dhandle_t *handle = NULL; - mbchar_t *dirname = NULL; + dhandle_t *handle = nullptr; + mbchar_t *dirname = nullptr; handle = (dhandle_t*)c_malloc(sizeof(dhandle_t)); // the file wildcard has to be attached size_t len_name = strlen(name); if( len_name ) { - char *h = NULL; + char *h = nullptr; // alloc an enough large buffer to take the name + '/*' + the closing zero. h = (char*)c_malloc(len_name+3); @@ -85,7 +85,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) { errno = EACCES; } SAFE_FREE(handle); - return NULL; + return nullptr; } handle->firstFind = 1; // Set a flag that there first fileinfo is available. @@ -97,10 +97,10 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) { } int csync_vio_local_closedir(csync_vio_handle_t *dhandle) { - dhandle_t *handle = NULL; + dhandle_t *handle = nullptr; int rc = -1; - if (dhandle == NULL) { + if (dhandle == nullptr) { errno = EBADF; return -1; } @@ -141,7 +141,7 @@ static time_t FileTimeToUnixTime(FILETIME *filetime, DWORD *remainder) std::unique_ptr csync_vio_local_readdir(csync_vio_handle_t *dhandle) { - dhandle_t *handle = NULL; + dhandle_t *handle = nullptr; std::unique_ptr file_stat; DWORD rem; @@ -234,9 +234,9 @@ static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf ULARGE_INTEGER FileIndex; h = CreateFileW( wuri, 0, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, - NULL ); + nullptr ); if( h == INVALID_HANDLE_VALUE ) { qCCritical(lcCSyncVIOLocal, "CreateFileW failed on %ls", wuri); errno = GetLastError(); diff --git a/src/gui/cloudproviders/cloudproviderwrapper.cpp b/src/gui/cloudproviders/cloudproviderwrapper.cpp index 3b520721a..0d2f2530f 100644 --- a/src/gui/cloudproviders/cloudproviderwrapper.cpp +++ b/src/gui/cloudproviders/cloudproviderwrapper.cpp @@ -286,7 +286,7 @@ activate_action_open (GSimpleAction *action, GVariant *parameter, gpointer user_ } if(g_str_equal(name, "showfile")) { - const gchar *path = g_variant_get_string (parameter, NULL); + const gchar *path = g_variant_get_string(parameter, nullptr); g_print("showfile => %s\n", path); showInFileManager(QString(path)); } diff --git a/src/gui/folderman.h b/src/gui/folderman.h index d4d311bec..8d81ace0d 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -87,7 +87,7 @@ public: */ QStringList findFileInLocalFolders(const QString &relPath, const AccountPtr acc); - /** Returns the folder by alias or NULL if no folder with the alias exists. */ + /** Returns the folder by alias or \c nullptr if no folder with the alias exists. */ Folder *folder(const QString &); /** diff --git a/src/gui/folderwatcher_mac.cpp b/src/gui/folderwatcher_mac.cpp index a28277fea..3fa10f7b1 100644 --- a/src/gui/folderwatcher_mac.cpp +++ b/src/gui/folderwatcher_mac.cpp @@ -86,13 +86,13 @@ void FolderWatcherPrivate::startWatching() qCDebug(lcFolderWatcher) << "FolderWatcherPrivate::startWatching()" << _folder; CFStringRef folderCF = CFStringCreateWithCharacters(0, reinterpret_cast(_folder.unicode()), _folder.length()); - CFArrayRef pathsToWatch = CFStringCreateArrayBySeparatingStrings(NULL, folderCF, CFSTR(":")); + CFArrayRef pathsToWatch = CFStringCreateArrayBySeparatingStrings(nullptr, folderCF, CFSTR(":")); - FSEventStreamContext ctx = { 0, this, NULL, NULL, NULL }; + FSEventStreamContext ctx = { 0, this, nullptr, nullptr, nullptr }; // TODO: Add kFSEventStreamCreateFlagFileEvents ? - _stream = FSEventStreamCreate(NULL, + _stream = FSEventStreamCreate(nullptr, &callback, &ctx, pathsToWatch, diff --git a/src/gui/folderwatcher_win.cpp b/src/gui/folderwatcher_win.cpp index 4adc6cd6c..4907b5adf 100644 --- a/src/gui/folderwatcher_win.cpp +++ b/src/gui/folderwatcher_win.cpp @@ -37,10 +37,10 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize, (wchar_t *)longPath.utf16(), FILE_LIST_DIRECTORY, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, - NULL, + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, - NULL); + nullptr); if (_directory == INVALID_HANDLE_VALUE) { DWORD errorCode = GetLastError(); @@ -72,7 +72,7 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE, &dwBytesReturned, &overlapped, - NULL)) { + nullptr)) { DWORD errorCode = GetLastError(); if (errorCode == ERROR_NOTIFY_ENUM_DIR) { qCDebug(lcFolderWatcher) << "The buffer for changes overflowed! Triggering a generic change and resizing"; @@ -156,14 +156,14 @@ void WatcherThread::closeHandle() { if (_directory) { CloseHandle(_directory); - _directory = NULL; + _directory = nullptr; } } void WatcherThread::run() { - _resultEvent = CreateEvent(NULL, true, false, NULL); - _stopEvent = CreateEvent(NULL, true, false, NULL); + _resultEvent = CreateEvent(nullptr, true, false, nullptr); + _stopEvent = CreateEvent(nullptr, true, false, nullptr); // If this buffer fills up before we've extracted its data we will lose // change information. Therefore start big. diff --git a/test/csync/csync_tests/check_csync_exclude.cpp b/test/csync/csync_tests/check_csync_exclude.cpp index 8425877b1..85efea368 100644 --- a/test/csync/csync_tests/check_csync_exclude.cpp +++ b/test/csync/csync_tests/check_csync_exclude.cpp @@ -86,7 +86,7 @@ static int teardown(void **state) { rc = system("rm -rf /tmp/check_csync2"); assert_int_equal(rc, 0); - *state = NULL; + *state = nullptr; return 0; } @@ -717,5 +717,5 @@ int torture_run_tests(void) cmocka_unit_test(T::check_csync_exclude_expand_escapes), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/csync_tests/check_csync_misc.cpp b/test/csync/csync_tests/check_csync_misc.cpp index 4d07d4335..fc7fea67e 100644 --- a/test/csync/csync_tests/check_csync_misc.cpp +++ b/test/csync/csync_tests/check_csync_misc.cpp @@ -50,6 +50,6 @@ int torture_run_tests(void) cmocka_unit_test(check_csync_normalize_etag), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/csync_tests/check_csync_update.cpp b/test/csync/csync_tests/check_csync_update.cpp index 11acf896a..a896905a2 100644 --- a/test/csync/csync_tests/check_csync_update.cpp +++ b/test/csync/csync_tests/check_csync_update.cpp @@ -50,7 +50,7 @@ static void statedb_create_metadata_table(sqlite3 *db) "contentChecksumTypeId INTEGER," "PRIMARY KEY(phash));"; - rc = sqlite3_exec(db, sql, NULL, NULL, NULL); + rc = sqlite3_exec(db, sql, nullptr, nullptr, nullptr); //const char *msg = sqlite3_errmsg(db); assert_int_equal( rc, SQLITE_OK ); @@ -58,7 +58,7 @@ static void statedb_create_metadata_table(sqlite3 *db) "id INTEGER PRIMARY KEY," "name TEXT UNIQUE" ");"; - rc = sqlite3_exec(db, sql, NULL, NULL, NULL); + rc = sqlite3_exec(db, sql, nullptr, nullptr, nullptr); assert_int_equal( rc, SQLITE_OK ); } } @@ -83,7 +83,7 @@ static void statedb_insert_metadata(sqlite3 *db) "4711"); char *errmsg = nullptr; - rc = sqlite3_exec(db, stmt, NULL, NULL, &errmsg); + rc = sqlite3_exec(db, stmt, nullptr, nullptr, &errmsg); sqlite3_free(stmt); assert_int_equal( rc, SQLITE_OK ); } @@ -129,8 +129,8 @@ static int setup_ftw(void **state) assert_int_equal(rc, 0); csync = new CSYNC("/tmp", new OCC::SyncJournalDb(TESTDB)); - sqlite3 *db = NULL; - rc = sqlite3_open_v2(TESTDB, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); + sqlite3 *db = nullptr; + rc = sqlite3_open_v2(TESTDB, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, nullptr); assert_int_equal(rc, SQLITE_OK); statedb_create_metadata_table(db); rc = sqlite3_close(db); @@ -153,8 +153,8 @@ static int teardown(void **state) delete csync; delete statedb; - *state = NULL; - + *state = nullptr; + return 0; } @@ -366,5 +366,5 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(check_csync_ftw_failing_fn, setup_ftw, teardown_rm), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/csync_tests/check_csync_util.cpp b/test/csync/csync_tests/check_csync_util.cpp index 11fae6c09..53be6b567 100644 --- a/test/csync/csync_tests/check_csync_util.cpp +++ b/test/csync/csync_tests/check_csync_util.cpp @@ -48,6 +48,6 @@ int torture_run_tests(void) cmocka_unit_test(check_csync_memstat), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/encoding_tests/check_encoding.cpp b/test/csync/encoding_tests/check_encoding.cpp index 372005e93..a28e9cc22 100644 --- a/test/csync/encoding_tests/check_encoding.cpp +++ b/test/csync/encoding_tests/check_encoding.cpp @@ -31,7 +31,7 @@ static void check_iconv_to_native_normalization(void **state) { - mbchar_t *out = NULL; + mbchar_t *out = nullptr; const char *in= "\x48\xc3\xa4"; // UTF8 #ifdef __APPLE__ const char *exp_out = "\x48\x61\xcc\x88"; // UTF-8-MAC @@ -94,7 +94,7 @@ static void check_to_multibyte(void **state) int rc = -1; mbchar_t *mb_string = c_utf8_path_to_locale( TESTSTRING ); - mbchar_t *mb_null = c_utf8_path_to_locale( NULL ); + mbchar_t *mb_null = c_utf8_path_to_locale( nullptr ); (void) state; @@ -103,7 +103,7 @@ static void check_to_multibyte(void **state) #else assert_string_equal(mb_string, TESTSTRING); #endif - assert_true( mb_null == NULL ); + assert_true( mb_null == nullptr ); assert_int_equal(rc, -1); c_free_locale_string(mb_string); @@ -178,6 +178,6 @@ int torture_run_tests(void) }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/vio_tests/check_vio.cpp b/test/csync/vio_tests/check_vio.cpp index 79e28ab1c..7d429f0a2 100644 --- a/test/csync/vio_tests/check_vio.cpp +++ b/test/csync/vio_tests/check_vio.cpp @@ -88,7 +88,7 @@ static int teardown(void **state) { rc = system("rm -rf /tmp/csync_test/"); assert_int_equal(rc, 0); - *state = NULL; + *state = nullptr; return 0; } @@ -135,7 +135,7 @@ static void check_csync_vio_closedir_null(void **state) CSYNC *csync = (CSYNC*)*state; int rc = 0; - rc = csync_vio_closedir(csync, NULL); + rc = csync_vio_closedir(csync, nullptr); assert_int_equal(rc, -1); } @@ -147,5 +147,5 @@ int torture_run_tests(void) cmocka_unit_test(check_csync_vio_closedir_null), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index e73c42424..afcb0c87f 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -95,7 +95,7 @@ static int setup_testenv(void **state) { /* --- initialize csync */ statevar *mystate = (statevar*)malloc( sizeof(statevar) ); - mystate->result = NULL; + mystate->result = nullptr; mystate->csync = new CSYNC("/tmp/check_csync1", new OCC::SyncJournalDb("")); @@ -134,7 +134,7 @@ static int teardown(void **state) { rc = wipe_testdir(); assert_int_equal(rc, 0); - *state = NULL; + *state = nullptr; return 0; } @@ -277,7 +277,7 @@ static void create_file( const char *path, const char *name, const char *content assert_int_equal( 0, hFile==INVALID_HANDLE_VALUE ); int len = strlen(content); - mbchar_t *dst = NULL; + mbchar_t *dst = nullptr; dst = c_utf8_string_to_locale(content); WriteFile(hFile, dst, len * sizeof(mbchar_t), &dwWritten, 0); @@ -462,5 +462,5 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/testnextcloudpropagator.cpp b/test/testnextcloudpropagator.cpp index dc2e476ad..443d3a430 100644 --- a/test/testnextcloudpropagator.cpp +++ b/test/testnextcloudpropagator.cpp @@ -22,7 +22,7 @@ class TestNextcloudPropagator : public QObject private slots: void testUpdateErrorFromSession() { -// NextcloudPropagator propagator( NULL, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase); + //OwncloudPropagator propagator(nullptr, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase); QVERIFY( true ); } -- 2.30.2