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 <s-beyer@gmx.net>
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<HDROP>(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];
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.
InterlockedDecrement(&g_cDllRef);
}
return S_OK;
-}
\ No newline at end of file
+}
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);
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,
if (SUCCEEDED(hr))
{
// Get the data for the specified value name.
- hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, NULL,
- NULL, reinterpret_cast<LPBYTE>(pszData), &cbData));
+ hr = HRESULT_FROM_WIN32(RegQueryValueEx(hKey, pszValueName, nullptr,
+ nullptr, reinterpret_cast<LPBYTE>(pszData), &cbData));
RegCloseKey(hKey);
}
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;
}
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\{<CLSID>}\InprocServer32 key.
if (SUCCEEDED(hr))
{
// 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.
HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler(
PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName)
{
- if (pszFileType == NULL)
+ if (pszFileType == nullptr)
{
return E_INVALIDARG;
}
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
if (SUCCEEDED(hr))
{
// Set the default value of the key.
- hr = SetHKCRRegistryKeyAndValue(szSubkey, NULL, szCLSID);
+ hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, szCLSID);
}
return hr;
HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler(
PCWSTR pszFileType, PCWSTR pszFriendlyName)
{
- if (pszFileType == NULL)
+ if (pszFileType == nullptr)
{
return E_INVALIDARG;
}
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
}
return hr;
-}
\ No newline at end of file
+}
// 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)
{
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);
}
// {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)
}
return hr;
-}
\ No newline at end of file
+}
#include "OCOverlayRegistrationHandler.h"
#include "OCOverlayFactory.h"
-HINSTANCE instanceHandle = NULL;
+HINSTANCE instanceHandle = nullptr;
long dllReferenceCount = 0;
else
{
hr = E_NOINTERFACE;
- *ppv = NULL;
+ *ppv = nullptr;
}
if (*ppv)
else
{
hResult = E_NOINTERFACE;
- *ppv = NULL;
+ *ppv = nullptr;
}
return hResult;
{
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);
InterlockedDecrement(&dllReferenceCount);
}
return S_OK;
-}
\ No newline at end of file
+}
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)) {
}
}
- 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;
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;
}
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;
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;
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;
}
return S_OK;
-}
\ No newline at end of file
+}
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;
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;
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;
}
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;
}
{
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))
{
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))
{
// 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:
}
}
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:"))) {
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);
}
}
}
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);
}
}
: _stop(false)
, _watchedDirectories(make_shared<const vector<wstring>>())
, _connected(false)
- , _newQueries(CreateEvent(NULL, FALSE, FALSE, NULL))
+ , _newQueries(CreateEvent(nullptr, FALSE, FALSE, nullptr))
, _thread([this]{ this->workerThreadLoop(); })
{
}
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",
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
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);
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;
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(
&securityAtts,
creationDisp,
FILE_ATTRIBUTE_NORMAL,
- NULL);
+ nullptr);
// Bail out on error.
if (fileHandle == INVALID_HANDLE_VALUE) {
if (!GetVolumeInformationW(
reinterpret_cast<LPCWSTR>(drive.utf16()),
- NULL, 0,
- NULL, NULL, NULL,
+ nullptr, 0,
+ nullptr, nullptr, nullptr,
fileSystemBuffer, fileSystemBufferSize)) {
return QString();
}
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? */
{
#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;
*/
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
#elif defined(Q_OS_WIN)
ULARGE_INTEGER freeBytes;
freeBytes.QuadPart = 0L;
- if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(path.utf16()), &freeBytes, NULL, NULL)) {
+ if (GetDiskFreeSpaceEx(reinterpret_cast<const wchar_t *>(path.utf16()), &freeBytes, nullptr, nullptr)) {
return freeBytes.QuadPart;
}
#endif
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;
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!
{
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);
}
/* 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);
*
* @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);
*
* @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);
#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 */
/* 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)
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
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);
*
* @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()
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);
errno = EACCES;
}
SAFE_FREE(handle);
- return NULL;
+ return nullptr;
}
handle->firstFind = 1; // Set a flag that there first fileinfo is available.
}
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;
}
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *dhandle) {
- dhandle_t *handle = NULL;
+ dhandle_t *handle = nullptr;
std::unique_ptr<csync_file_stat_t> file_stat;
DWORD rem;
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();
}
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));
}
*/
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 &);
/**
qCDebug(lcFolderWatcher) << "FolderWatcherPrivate::startWatching()" << _folder;
CFStringRef folderCF = CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(_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,
(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();
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";
{
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.
rc = system("rm -rf /tmp/check_csync2");
assert_int_equal(rc, 0);
- *state = NULL;
+ *state = nullptr;
return 0;
}
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);
}
cmocka_unit_test(check_csync_normalize_etag),
};
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, nullptr, nullptr);
}
"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 );
"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 );
}
}
"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 );
}
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);
delete csync;
delete statedb;
- *state = NULL;
-
+ *state = nullptr;
+
return 0;
}
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);
}
cmocka_unit_test(check_csync_memstat),
};
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, nullptr, nullptr);
}
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
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;
#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);
};
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, nullptr, nullptr);
}
rc = system("rm -rf /tmp/csync_test/");
assert_int_equal(rc, 0);
- *state = NULL;
+ *state = nullptr;
return 0;
}
CSYNC *csync = (CSYNC*)*state;
int rc = 0;
- rc = csync_vio_closedir(csync, NULL);
+ rc = csync_vio_closedir(csync, nullptr);
assert_int_equal(rc, -1);
}
cmocka_unit_test(check_csync_vio_closedir_null),
};
- return cmocka_run_group_tests(tests, NULL, NULL);
+ return cmocka_run_group_tests(tests, nullptr, nullptr);
}
/* --- initialize csync */
statevar *mystate = (statevar*)malloc( sizeof(statevar) );
- mystate->result = NULL;
+ mystate->result = nullptr;
mystate->csync = new CSYNC("/tmp/check_csync1", new OCC::SyncJournalDb(""));
rc = wipe_testdir();
assert_int_equal(rc, 0);
- *state = NULL;
+ *state = nullptr;
return 0;
}
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);
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);
}
private slots:
void testUpdateErrorFromSession()
{
-// NextcloudPropagator propagator( NULL, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase);
+ //OwncloudPropagator propagator(nullptr, QLatin1String("test1"), QLatin1String("test2"), new ProgressDatabase);
QVERIFY( true );
}