Skip to content

Commit 1ad8388

Browse files
committed
Replace a few more NULLs with nullptr
1 parent 1bf12c9 commit 1ad8388

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+258
-262
lines changed

icinga-app/icinga.cpp

+17-20
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int Main(void)
258258
|| command->GetImpersonationLevel() == ImpersonationLevel::ImpersonateRoot) {
259259
TCHAR szPath[MAX_PATH];
260260

261-
if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) {
261+
if (GetModuleFileName(nullptr, szPath, ARRAYSIZE(szPath))) {
262262
SHELLEXECUTEINFO sei = { sizeof(sei) };
263263
sei.lpVerb = _T("runas");
264264
sei.lpFile = "cmd.exe";
@@ -434,7 +434,7 @@ static int Main(void)
434434

435435
if (!command || vm.count("help")) {
436436
if (!command)
437-
CLICommand::ShowCommands(argc, argv, NULL);
437+
CLICommand::ShowCommands(argc, argv, nullptr);
438438

439439
std::cout << visibleDesc << std::endl
440440
<< "Report bugs at <https://github.com/Icinga/icinga2>" << std::endl
@@ -477,7 +477,7 @@ static int Main(void)
477477
}
478478

479479
if (getgid() != gr->gr_gid) {
480-
if (!vm.count("reload-internal") && setgroups(0, NULL) < 0) {
480+
if (!vm.count("reload-internal") && setgroups(0, nullptr) < 0) {
481481
Log(LogCritical, "cli")
482482
<< "setgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
483483
Log(LogCritical, "cli")
@@ -567,19 +567,16 @@ static int Main(void)
567567
#ifdef _WIN32
568568
static int SetupService(bool install, int argc, char **argv)
569569
{
570-
SC_HANDLE schSCManager = OpenSCManager(
571-
NULL,
572-
NULL,
573-
SC_MANAGER_ALL_ACCESS);
570+
SC_HANDLE schSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
574571

575-
if (NULL == schSCManager) {
572+
if (!schSCManager) {
576573
printf("OpenSCManager failed (%d)\n", GetLastError());
577574
return 1;
578575
}
579576

580577
TCHAR szPath[MAX_PATH];
581578

582-
if (!GetModuleFileName(NULL, szPath, MAX_PATH)) {
579+
if (!GetModuleFileName(nullptr, szPath, MAX_PATH)) {
583580
printf("Cannot install service (%d)\n", GetLastError());
584581
return 1;
585582
}
@@ -604,7 +601,7 @@ static int SetupService(bool install, int argc, char **argv)
604601

605602
SC_HANDLE schService = OpenService(schSCManager, "icinga2", SERVICE_ALL_ACCESS);
606603

607-
if (schService != NULL) {
604+
if (schService) {
608605
SERVICE_STATUS status;
609606
ControlService(schService, SERVICE_CONTROL_STOP, &status);
610607

@@ -634,13 +631,13 @@ static int SetupService(bool install, int argc, char **argv)
634631
SERVICE_DEMAND_START,
635632
SERVICE_ERROR_NORMAL,
636633
szArgs.CStr(),
637-
NULL,
638-
NULL,
639-
NULL,
634+
nullptr,
635+
nullptr,
636+
nullptr,
640637
scmUser.c_str(),
641-
NULL);
638+
nullptr);
642639

643-
if (schService == NULL) {
640+
if (!schService) {
644641
printf("CreateService failed (%d)\n", GetLastError());
645642
CloseServiceHandle(schSCManager);
646643
return 1;
@@ -662,7 +659,7 @@ static int SetupService(bool install, int argc, char **argv)
662659
printf("Service uninstalled successfully\n");
663660
} else {
664661
if (!ChangeServiceConfig(schService, SERVICE_NO_CHANGE, SERVICE_AUTO_START,
665-
SERVICE_ERROR_NORMAL, szArgs.CStr(), NULL, NULL, NULL, scmUser.c_str(), NULL, NULL)) {
662+
SERVICE_ERROR_NORMAL, szArgs.CStr(), nullptr, nullptr, nullptr, scmUser.c_str(), nullptr, nullptr)) {
666663
printf("ChangeServiceConfig failed (%d)\n", GetLastError());
667664
CloseServiceHandle(schService);
668665
CloseServiceHandle(schSCManager);
@@ -677,7 +674,7 @@ static int SetupService(bool install, int argc, char **argv)
677674
return 1;
678675
}
679676

680-
if (!StartService(schService, 0, NULL)) {
677+
if (!StartService(schService, 0, nullptr)) {
681678
printf("StartService failed (%d)\n", GetLastError());
682679
CloseServiceHandle(schService);
683680
CloseServiceHandle(schSCManager);
@@ -743,7 +740,7 @@ static VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
743740
l_SvcStatus.dwServiceSpecificExitCode = 0;
744741

745742
ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0);
746-
l_Job = CreateJobObject(NULL, NULL);
743+
l_Job = CreateJobObject(nullptr, nullptr);
747744

748745
for (;;) {
749746
LPSTR arg = argv[0];
@@ -765,7 +762,7 @@ static VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
765762

766763
char *uargs = strdup(args.CStr());
767764

768-
BOOL res = CreateProcess(NULL, uargs, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
765+
BOOL res = CreateProcess(nullptr, uargs, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi);
769766

770767
free(uargs);
771768

@@ -847,7 +844,7 @@ int main(int argc, char **argv)
847844
if (argc > 1 && strcmp(argv[1], "--scm") == 0) {
848845
SERVICE_TABLE_ENTRY dispatchTable[] = {
849846
{ "icinga2", ServiceMain },
850-
{ NULL, NULL }
847+
{ nullptr, nullptr }
851848
};
852849

853850
StartServiceCtrlDispatcher(dispatchTable);

icinga-installer/icinga-installer.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
static std::string GetIcingaInstallPath(void)
3232
{
3333
char szFileName[MAX_PATH];
34-
if (!GetModuleFileName(NULL, szFileName, sizeof(szFileName)))
34+
if (!GetModuleFileName(nullptr, szFileName, sizeof(szFileName)))
3535
return "";
3636

3737
if (!PathRemoveFileSpec(szFileName))
@@ -100,7 +100,7 @@ static bool PathExists(const std::string& path)
100100
static std::string GetIcingaDataPath(void)
101101
{
102102
char path[MAX_PATH];
103-
if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
103+
if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_COMMON_APPDATA, nullptr, 0, path)))
104104
throw std::runtime_error("SHGetFolderPath failed");
105105
return std::string(path) + "\\icinga2";
106106
}
@@ -133,7 +133,7 @@ static std::string GetNSISInstallPath(void)
133133
BYTE pvData[MAX_PATH];
134134
DWORD cbData = sizeof(pvData) - 1;
135135
DWORD lType;
136-
if (RegQueryValueEx(hKey, NULL, NULL, &lType, pvData, &cbData) == ERROR_SUCCESS && lType == REG_SZ) {
136+
if (RegQueryValueEx(hKey, nullptr, nullptr, &lType, pvData, &cbData) == ERROR_SUCCESS && lType == REG_SZ) {
137137
pvData[cbData] = '\0';
138138

139139
return (char *)pvData;
@@ -279,7 +279,7 @@ static int UninstallIcinga(void)
279279
*/
280280
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
281281
{
282-
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
282+
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
283283

284284
//AllocConsole();
285285
int rc;
@@ -291,7 +291,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
291291
} else if (strcmp(lpCmdLine, "upgrade-nsis") == 0) {
292292
rc = UpgradeNSIS();
293293
} else {
294-
MessageBox(NULL, "This application should only be run by the MSI installer package.", "Icinga 2 Installer", MB_ICONWARNING);
294+
MessageBox(nullptr, "This application should only be run by the MSI installer package.", "Icinga 2 Installer", MB_ICONWARNING);
295295
rc = 1;
296296
}
297297

icinga-studio/icinga-studio.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class IcingaStudio : public wxApp
4444

4545
std::string url = wUrl.ToStdString();
4646

47-
ConnectForm f(NULL, new Url(url));
47+
ConnectForm f(nullptr, new Url(url));
4848
if (f.ShowModal() != wxID_OK)
4949
return false;
5050

@@ -56,7 +56,7 @@ class IcingaStudio : public wxApp
5656
pUrl = new Url(argv[1].ToStdString());
5757
}
5858

59-
MainForm *m = new MainForm(NULL, pUrl);
59+
MainForm *m = new MainForm(nullptr, pUrl);
6060
m->Show();
6161

6262
return true;

0 commit comments

Comments
 (0)