diff options
author | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:03:31 +0100 |
---|---|---|
committer | Goraf <22941576+Goraf@users.noreply.github.com> | 2017-11-13 15:07:33 +0100 |
commit | a7c24ca48995cf2bf436156302f96b91bf135409 (patch) | |
tree | 953835509ff1b778833e78fd7b74b05e05e77c84 /plugins/Db_autobackups | |
parent | 591ec17b1c99db7f120c22ca9fb20ae05fe78325 (diff) |
Code modernize ...
* replace 0/NULL with nullptr [using clang-tidy]
Diffstat (limited to 'plugins/Db_autobackups')
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 42 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/main.cpp | 6 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/options.cpp | 18 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/zip.cpp | 6 |
4 files changed, 36 insertions, 36 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 3438427ad8..7ae405fd26 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -10,8 +10,8 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_COMMAND:
{
wchar_t* ptszPath = (wchar_t*)PUGetPluginData(hWnd);
- if (ptszPath != 0)
- ShellExecute(0, L"open", ptszPath, NULL, NULL, SW_SHOW);
+ if (ptszPath != nullptr)
+ ShellExecute(nullptr, L"open", ptszPath, nullptr, nullptr, SW_SHOW);
PUDeletePopup(hWnd);
break;
@@ -31,7 +31,7 @@ void ShowPopup(wchar_t* ptszText, wchar_t* ptszHeader, wchar_t* ptszPath) wcsncpy_s(ppd.lptzText, ptszText, _TRUNCATE);
wcsncpy_s(ppd.lptzContactName, ptszHeader, _TRUNCATE);
- if (ptszPath != NULL)
+ if (ptszPath != nullptr)
ppd.PluginData = (void*)mir_wstrdup(ptszPath);
ppd.PluginWindowProc = DlgProcPopup;
ppd.lchIcon = IcoLib_GetIcon(iconList[0].szName);
@@ -62,8 +62,8 @@ wchar_t* DoubleSlash(wchar_t *sorce) wchar_t *ret, *r, *s;
ret = (wchar_t*)mir_alloc((MAX_PATH * sizeof(wchar_t)));
- if (ret == NULL)
- return NULL;
+ if (ret == nullptr)
+ return nullptr;
for (s = sorce, r = ret; *s && (r - ret) < (MAX_PATH - 1); s++, r++) {
if (*s != '\\')
*r = *s;
@@ -142,7 +142,7 @@ int Comp(const void *i, const void *j) int RotateBackups(wchar_t *backupfolder, wchar_t *dbname)
{
- backupFile *bf = NULL, *bftmp;
+ backupFile *bf = nullptr, *bftmp;
HANDLE hFind;
wchar_t backupfolderTmp[MAX_PATH];
WIN32_FIND_DATA FindFileData;
@@ -159,7 +159,7 @@ int RotateBackups(wchar_t *backupfolder, wchar_t *dbname) if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
bftmp = (backupFile*)mir_realloc(bf, ((i + 1) * sizeof(backupFile)));
- if (bftmp == NULL)
+ if (bftmp == nullptr)
goto err_out;
bf = bftmp;
wcsncpy_s(bf[i].Name, FindFileData.cFileName, _TRUNCATE);
@@ -183,12 +183,12 @@ int Backup(wchar_t *backup_filename) {
bool bZip = false;
wchar_t dbname[MAX_PATH], source_file[MAX_PATH] = { 0 }, dest_file[MAX_PATH];
- HWND progress_dialog = NULL;
+ HWND progress_dialog = nullptr;
SYSTEMTIME st;
Profile_GetNameW(_countof(dbname), dbname);
- if (backup_filename == NULL) {
+ if (backup_filename == nullptr) {
int err;
wchar_t *backupfolder, buffer[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = _countof(buffer);
@@ -214,10 +214,10 @@ int Backup(wchar_t *backup_filename) bZip = true;
}
if (!options.disable_popups)
- ShowPopup(dbname, TranslateT("Backup in progress"), NULL);
+ ShowPopup(dbname, TranslateT("Backup in progress"), nullptr);
if (!options.disable_progress)
- progress_dialog = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_COPYPROGRESS), 0, DlgProcProgress);
+ progress_dialog = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_COPYPROGRESS), nullptr, DlgProcProgress);
SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file..."));
@@ -235,15 +235,15 @@ int Backup(wchar_t *backup_filename) if (res) {
if (!bZip) { // Set the backup file to the current time for rotator's correct work
FILETIME ft;
- HANDLE hFile = CreateFile(dest_file, FILE_WRITE_ATTRIBUTES, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hFile = CreateFile(dest_file, FILE_WRITE_ATTRIBUTES, NULL, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
- SetFileTime(hFile, NULL, NULL, &ft);
+ SetFileTime(hFile, nullptr, nullptr, &ft);
CloseHandle(hFile);
}
SendDlgItemMessage(progress_dialog, IDC_PROGRESS, PBM_SETPOS, (WPARAM)(100), 0);
UpdateWindow(progress_dialog);
- db_set_dw(0, "AutoBackups", "LastBackupTimestamp", (DWORD)time(0));
+ db_set_dw(0, "AutoBackups", "LastBackupTimestamp", (DWORD)time(nullptr));
if (options.use_dropbox)
{
@@ -294,15 +294,15 @@ void BackupThread(void *backup_filename) void BackupStart(wchar_t *backup_filename)
{
- wchar_t *tm = NULL;
+ wchar_t *tm = nullptr;
LONG cur_state;
cur_state = InterlockedCompareExchange(&m_state, 1, 0);
if (cur_state != 0) { /* Backup allready in process. */
- ShowPopup(TranslateT("Database back up in process..."), TranslateT("Error"), NULL); /* Show error message :) */
+ ShowPopup(TranslateT("Database back up in process..."), TranslateT("Error"), nullptr); /* Show error message :) */
return;
}
- if (backup_filename != NULL)
+ if (backup_filename != nullptr)
tm = mir_wstrdup(backup_filename);
if (mir_forkthread(BackupThread, (void*)tm) == INVALID_HANDLE_VALUE) {
InterlockedExchange(&m_state, 0); /* Backup done. */
@@ -312,19 +312,19 @@ void BackupStart(wchar_t *backup_filename) VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- time_t t = time(NULL);
+ time_t t = time(nullptr);
time_t diff = t - (time_t)db_get_dw(0, "AutoBackups", "LastBackupTimestamp", 0);
if (diff > (time_t)(options.period * (options.period_type == PT_MINUTES ? 60 : (options.period_type == PT_HOURS ? (60 * 60) : (60 * 60 * 24)))))
- BackupStart(NULL);
+ BackupStart(nullptr);
}
int SetBackupTimer(void)
{
if (timer_id != 0) {
- KillTimer(0, timer_id);
+ KillTimer(nullptr, timer_id);
timer_id = 0;
}
if (options.backup_types & BT_PERIODIC)
- timer_id = SetTimer(0, 0, (1000 * 60), TimerProc);
+ timer_id = SetTimer(nullptr, 0, (1000 * 60), TimerProc);
return 0;
}
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index aad3eef30a..a0a2e37751 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -28,7 +28,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID) static INT_PTR ABService(WPARAM, LPARAM)
{
- BackupStart(NULL);
+ BackupStart(nullptr);
return 0;
}
@@ -90,7 +90,7 @@ static int ModulesLoad(WPARAM, LPARAM) options.use_dropbox = (BOOL)(db_get_b(0, "AutoBackups", "UseDropbox", 0) && ServiceExists(MS_DROPBOX_UPLOAD));
if (options.backup_types & BT_START)
- BackupStart(NULL);
+ BackupStart(nullptr);
return 0;
}
@@ -100,7 +100,7 @@ static int PreShutdown(WPARAM, LPARAM) {
if (options.backup_types & BT_EXIT) {
options.disable_popups = 1; // Don't try to show popups on exit
- BackupStart(NULL);
+ BackupStart(nullptr);
}
return 0;
}
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp index 575f39ab4b..068c2c5f89 100644 --- a/plugins/Db_autobackups/src/options.cpp +++ b/plugins/Db_autobackups/src/options.cpp @@ -8,11 +8,11 @@ Options options; HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle)
{
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
- TOOLTIPS_CLASS, NULL,
+ TOOLTIPS_CLASS, nullptr,
(WS_POPUP | TTS_NOPREFIX),
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
- hwndParent, NULL, g_hInstance, NULL);
+ hwndParent, nullptr, g_hInstance, nullptr);
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE));
@@ -221,7 +221,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP }
if (hPathTip)
- SetTimer(hwndDlg, 0, 3000, NULL);
+ SetTimer(hwndDlg, 0, 3000, nullptr);
return TRUE;
case WM_COMMAND:
@@ -277,7 +277,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP {
BROWSEINFO bi;
bi.hwndOwner = hwndDlg;
- bi.pidlRoot = 0;
+ bi.pidlRoot = nullptr;
bi.pszDisplayName = folder_buff;
bi.lpszTitle = TranslateT("Select backup folder");
bi.ulFlags = BIF_NEWDIALOGSTYLE;
@@ -286,7 +286,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP bi.iImage = 0;
LPCITEMIDLIST pidl = SHBrowseForFolder(&bi);
- if (pidl != 0) {
+ if (pidl != nullptr) {
SHGetPathFromIDList(pidl, folder_buff);
SetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff);
@@ -298,7 +298,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
}
case IDC_BUT_NOW:
- BackupStart(NULL);
+ BackupStart(nullptr);
break;
case IDC_CHK_NOPROG:
new_options.disable_progress = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOPROG);
@@ -362,8 +362,8 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int err = CreateDirectoryTreeW(backupfolder);
if (err != ERROR_ALREADY_EXISTS && err != 0) {
wchar_t msg_buff[512];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, msg_buff, 512, 0);
- MessageBox(0, msg_buff, TranslateT("Error creating backup folder"), MB_OK | MB_ICONERROR);
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, 0, msg_buff, 512, nullptr);
+ MessageBox(nullptr, msg_buff, TranslateT("Error creating backup folder"), MB_OK | MB_ICONERROR);
folder_ok = FALSE;
}
@@ -386,7 +386,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (hPathTip) {
KillTimer(hwndDlg, 0);
DestroyWindow(hPathTip);
- hPathTip = 0;
+ hPathTip = nullptr;
}
return FALSE;
}
diff --git a/plugins/Db_autobackups/src/zip.cpp b/plugins/Db_autobackups/src/zip.cpp index f3f37e187f..c4a2b145f1 100644 --- a/plugins/Db_autobackups/src/zip.cpp +++ b/plugins/Db_autobackups/src/zip.cpp @@ -3,7 +3,7 @@ int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std::function<bool(size_t)> &fnCallback)
{
- zipFile hZip = zipOpen2_64(_A2T(szDestPath), APPEND_STATUS_CREATE, NULL, NULL);
+ zipFile hZip = zipOpen2_64(_A2T(szDestPath), APPEND_STATUS_CREATE, nullptr, nullptr);
if (!hZip) return 1;
zip_fileinfo fi = { 0 };
@@ -13,10 +13,10 @@ int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std: {
ZipFile &zf = lstFiles[i];
- HANDLE hSrcFile = CreateFileA(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hSrcFile = CreateFileA(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hSrcFile != INVALID_HANDLE_VALUE)
{
- int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, NULL, 0, NULL, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
+ int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, nullptr, 0, nullptr, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
if (iOpenRes == ZIP_OK)
{
|