]> granicus.if.org Git - icinga2/commitdiff
Replace a few more NULLs with nullptr 5862/head
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 14 Dec 2017 14:37:20 +0000 (15:37 +0100)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 14 Dec 2017 14:37:20 +0000 (15:37 +0100)
66 files changed:
icinga-app/icinga.cpp
icinga-installer/icinga-installer.cpp
icinga-studio/icinga-studio.cpp
lib/base/application.cpp
lib/base/context.cpp
lib/base/exception.cpp
lib/base/exception.hpp
lib/base/fifo.cpp
lib/base/json.cpp
lib/base/loader.cpp
lib/base/networkstream.cpp
lib/base/objectlock.hpp
lib/base/objecttype.cpp
lib/base/primitivetype.hpp
lib/base/process.cpp
lib/base/scriptglobal.hpp
lib/base/serializer.cpp
lib/base/socket.hpp
lib/base/socketevents-epoll.cpp
lib/base/socketevents.cpp
lib/base/socketevents.hpp
lib/base/stacktrace.cpp
lib/base/stream.hpp
lib/base/streamlogger.cpp
lib/base/tcpsocket.cpp
lib/base/threadpool.hpp
lib/base/tlsstream.cpp
lib/base/tlsutility.cpp
lib/base/tlsutility.hpp
lib/base/type.cpp
lib/base/utility.cpp
lib/base/value.hpp
lib/cli/clicommand.hpp
lib/cli/consolecommand.cpp
lib/cli/daemoncommand.cpp
lib/cli/troubleshootcommand.cpp
lib/compat/compatlogger.cpp
lib/compat/statusdatawriter.cpp
lib/config/configcompilercontext.cpp
lib/config/expression.cpp
lib/config/expression.hpp
lib/db_ido/idochecktask.cpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp
lib/icinga/checkable-check.cpp
lib/icinga/checkable.hpp
lib/icinga/legacytimeperiod.cpp
lib/icinga/macroprocessor.cpp
lib/icinga/macroprocessor.hpp
lib/icinga/pluginutility.cpp
lib/livestatus/livestatusquery.cpp
lib/methods/clrchecktask.cpp
lib/methods/clusterzonechecktask.cpp
lib/methods/dummychecktask.cpp
lib/perfdata/graphitewriter.cpp
lib/perfdata/perfdatawriter.cpp
lib/remote/configobjectutility.cpp
lib/remote/consolehandler.cpp
lib/remote/eventqueue.cpp
lib/remote/eventshandler.cpp
lib/remote/filterutility.cpp
lib/remote/filterutility.hpp
lib/remote/httprequest.cpp
lib/remote/httpresponse.cpp
lib/remote/pkiutility.cpp
tools/mkclass/classcompiler.cpp

index 2dfe7154177f17597905e6a7f1e564efde22d4c4..95df3714ba62e3b71a80afa913b281c23c1518bb 100644 (file)
@@ -258,7 +258,7 @@ static int Main(void)
                                || command->GetImpersonationLevel() == ImpersonationLevel::ImpersonateRoot) {
                                TCHAR szPath[MAX_PATH];
 
-                               if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) { 
+                               if (GetModuleFileName(nullptr, szPath, ARRAYSIZE(szPath))) {
                                        SHELLEXECUTEINFO sei = { sizeof(sei) };
                                        sei.lpVerb = _T("runas");
                                        sei.lpFile = "cmd.exe";
@@ -434,7 +434,7 @@ static int Main(void)
 
                if (!command || vm.count("help")) {
                        if (!command)
-                               CLICommand::ShowCommands(argc, argv, NULL);
+                               CLICommand::ShowCommands(argc, argv, nullptr);
 
                        std::cout << visibleDesc << std::endl
                                << "Report bugs at <https://github.com/Icinga/icinga2>" << std::endl
@@ -477,7 +477,7 @@ static int Main(void)
                        }
 
                        if (getgid() != gr->gr_gid) {
-                               if (!vm.count("reload-internal") && setgroups(0, NULL) < 0) {
+                               if (!vm.count("reload-internal") && setgroups(0, nullptr) < 0) {
                                        Log(LogCritical, "cli")
                                            << "setgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
                                        Log(LogCritical, "cli")
@@ -567,19 +567,16 @@ static int Main(void)
 #ifdef _WIN32
 static int SetupService(bool install, int argc, char **argv)
 {
-       SC_HANDLE schSCManager = OpenSCManager(
-               NULL,
-               NULL,
-               SC_MANAGER_ALL_ACCESS);
+       SC_HANDLE schSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
 
-       if (NULL == schSCManager) {
+       if (!schSCManager) {
                printf("OpenSCManager failed (%d)\n", GetLastError());
                return 1;
        }
 
        TCHAR szPath[MAX_PATH];
 
-       if (!GetModuleFileName(NULL, szPath, MAX_PATH)) {
+       if (!GetModuleFileName(nullptr, szPath, MAX_PATH)) {
                printf("Cannot install service (%d)\n", GetLastError());
                return 1;
        }
@@ -604,7 +601,7 @@ static int SetupService(bool install, int argc, char **argv)
 
        SC_HANDLE schService = OpenService(schSCManager, "icinga2", SERVICE_ALL_ACCESS);
 
-       if (schService != NULL) {
+       if (schService) {
                SERVICE_STATUS status;
                ControlService(schService, SERVICE_CONTROL_STOP, &status);
 
@@ -634,13 +631,13 @@ static int SetupService(bool install, int argc, char **argv)
                        SERVICE_DEMAND_START,
                        SERVICE_ERROR_NORMAL,
                        szArgs.CStr(),
-                       NULL,
-                       NULL,
-                       NULL,
+                       nullptr,
+                       nullptr,
+                       nullptr,
                        scmUser.c_str(),
-                       NULL);
+                       nullptr);
 
-               if (schService == NULL) {
+               if (!schService) {
                        printf("CreateService failed (%d)\n", GetLastError());
                        CloseServiceHandle(schSCManager);
                        return 1;
@@ -662,7 +659,7 @@ static int SetupService(bool install, int argc, char **argv)
                printf("Service uninstalled successfully\n");
        } else {
                if (!ChangeServiceConfig(schService, SERVICE_NO_CHANGE, SERVICE_AUTO_START,
-                       SERVICE_ERROR_NORMAL, szArgs.CStr(), NULL, NULL, NULL, scmUser.c_str(), NULL, NULL)) {
+                       SERVICE_ERROR_NORMAL, szArgs.CStr(), nullptr, nullptr, nullptr, scmUser.c_str(), nullptr, nullptr)) {
                        printf("ChangeServiceConfig failed (%d)\n", GetLastError());
                        CloseServiceHandle(schService);
                        CloseServiceHandle(schSCManager);
@@ -677,7 +674,7 @@ static int SetupService(bool install, int argc, char **argv)
                        return 1;
                }
 
-               if (!StartService(schService, 0, NULL)) {
+               if (!StartService(schService, 0, nullptr)) {
                        printf("StartService failed (%d)\n", GetLastError());
                        CloseServiceHandle(schService);
                        CloseServiceHandle(schSCManager);
@@ -743,7 +740,7 @@ static VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
        l_SvcStatus.dwServiceSpecificExitCode = 0;
 
        ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0);
-       l_Job = CreateJobObject(NULL, NULL);
+       l_Job = CreateJobObject(nullptr, nullptr);
 
        for (;;) {
                LPSTR arg = argv[0];
@@ -765,7 +762,7 @@ static VOID WINAPI ServiceMain(DWORD argc, LPSTR *argv)
 
                char *uargs = strdup(args.CStr());
 
-               BOOL res = CreateProcess(NULL, uargs, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+               BOOL res = CreateProcess(nullptr, uargs, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi);
 
                free(uargs);
 
@@ -847,7 +844,7 @@ int main(int argc, char **argv)
        if (argc > 1 && strcmp(argv[1], "--scm") == 0) {
                SERVICE_TABLE_ENTRY dispatchTable[] = {
                        { "icinga2", ServiceMain },
-                       { NULL, NULL }
+                       { nullptr, nullptr }
                };
 
                StartServiceCtrlDispatcher(dispatchTable);
index 455ff28316d245ffc6f08c396f8e1ed7fb08cf37..91ca0d6bcc4b335109b0017336d26f6894028969 100644 (file)
@@ -31,7 +31,7 @@
 static std::string GetIcingaInstallPath(void)
 {
        char szFileName[MAX_PATH];
-       if (!GetModuleFileName(NULL, szFileName, sizeof(szFileName)))
+       if (!GetModuleFileName(nullptr, szFileName, sizeof(szFileName)))
                return "";
 
        if (!PathRemoveFileSpec(szFileName))
@@ -100,7 +100,7 @@ static bool PathExists(const std::string& path)
 static std::string GetIcingaDataPath(void)
 {
        char path[MAX_PATH];
-       if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
+       if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_COMMON_APPDATA, nullptr, 0, path)))
                throw std::runtime_error("SHGetFolderPath failed");
        return std::string(path) + "\\icinga2";
 }
@@ -133,7 +133,7 @@ static std::string GetNSISInstallPath(void)
                BYTE pvData[MAX_PATH];
                DWORD cbData = sizeof(pvData) - 1;
                DWORD lType;
-               if (RegQueryValueEx(hKey, NULL, NULL, &lType, pvData, &cbData) == ERROR_SUCCESS && lType == REG_SZ) {
+               if (RegQueryValueEx(hKey, nullptr, nullptr, &lType, pvData, &cbData) == ERROR_SUCCESS && lType == REG_SZ) {
                        pvData[cbData] = '\0';
 
                        return (char *)pvData;
@@ -279,7 +279,7 @@ static int UninstallIcinga(void)
 */
 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
 {
-       CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+       CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
 
        //AllocConsole();
        int rc;
@@ -291,7 +291,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
        } else if (strcmp(lpCmdLine, "upgrade-nsis") == 0) {
                rc = UpgradeNSIS();
        } else {
-               MessageBox(NULL, "This application should only be run by the MSI installer package.", "Icinga 2 Installer", MB_ICONWARNING);
+               MessageBox(nullptr, "This application should only be run by the MSI installer package.", "Icinga 2 Installer", MB_ICONWARNING);
                rc = 1;
        }
 
index 8bfe2e5496bafe318676d27b3277066eee5f5933..bd4cdc1fa90b665ea24ce6799f2448e365e7d08a 100644 (file)
@@ -44,7 +44,7 @@ public:
 
                        std::string url = wUrl.ToStdString();
 
-                       ConnectForm f(NULL, new Url(url));
+                       ConnectForm f(nullptr, new Url(url));
                        if (f.ShowModal() != wxID_OK)
                                return false;
 
@@ -56,7 +56,7 @@ public:
                        pUrl = new Url(argv[1].ToStdString());
                }
 
-               MainForm *m = new MainForm(NULL, pUrl);
+               MainForm *m = new MainForm(nullptr, pUrl);
                m->Show();
 
                return true;
index 1c7a7304179825c6184b0bfadb1427f0288fb0a5..790eae905f363c66c8c524ec12c14cc3ac942821 100644 (file)
@@ -54,7 +54,7 @@ using namespace icinga;
 REGISTER_TYPE(Application);
 
 boost::signals2::signal<void (void)> Application::OnReopenLogs;
-Application::Ptr Application::m_Instance = NULL;
+Application::Ptr Application::m_Instance = nullptr;
 bool Application::m_ShuttingDown = false;
 bool Application::m_RequestRestart = false;
 bool Application::m_RequestReopenLogs = false;
@@ -73,9 +73,9 @@ double Application::m_LastReloadFailed;
  */
 void Application::OnConfigLoaded(void)
 {
-       m_PidFile = NULL;
+       m_PidFile = nullptr;
 
-       ASSERT(m_Instance == NULL);
+       ASSERT(m_Instance == nullptr);
        m_Instance = this;
 }
 
@@ -115,7 +115,7 @@ void Application::Stop(bool runtimeRemoved)
 
 Application::~Application(void)
 {
-       m_Instance = NULL;
+       m_Instance = nullptr;
 }
 
 void Application::Exit(int rc)
@@ -151,7 +151,7 @@ void Application::InitializeBase(void)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_IGN;
-       sigaction(SIGPIPE, &sa, NULL);
+       sigaction(SIGPIPE, &sa, nullptr);
 #endif /* _WIN32 */
 
        Loader::ExecuteDeferredInitializers();
@@ -276,7 +276,7 @@ void Application::SetResourceLimits(void)
                        for (int i = 1; i < argc; i++)
                                new_argv[i + 1] = argv[i];
 
-                       new_argv[argc + 1] = NULL;
+                       new_argv[argc + 1] = nullptr;
 
                        (void) execvp(new_argv[0], new_argv);
                        perror("execvp");
@@ -465,7 +465,7 @@ String Application::GetExePath(const String& argv0)
 
 #ifndef _WIN32
        char buffer[MAXPATHLEN];
-       if (getcwd(buffer, sizeof(buffer)) == NULL) {
+       if (!getcwd(buffer, sizeof(buffer))) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("getcwd")
                    << boost::errinfo_errno(errno));
@@ -488,7 +488,7 @@ String Application::GetExePath(const String& argv0)
 
        if (!foundSlash) {
                const char *pathEnv = getenv("PATH");
-               if (pathEnv != NULL) {
+               if (pathEnv) {
                        std::vector<String> paths;
                        boost::algorithm::split(paths, pathEnv, boost::is_any_of(":"));
 
@@ -510,7 +510,7 @@ String Application::GetExePath(const String& argv0)
                }
        }
 
-       if (realpath(executablePath.CStr(), buffer) == NULL) {
+       if (!realpath(executablePath.CStr(), buffer)) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("realpath")
                    << boost::errinfo_errno(errno)
@@ -521,7 +521,7 @@ String Application::GetExePath(const String& argv0)
 #else /* _WIN32 */
        char FullExePath[MAXPATHLEN];
 
-       if (!GetModuleFileName(NULL, FullExePath, sizeof(FullExePath)))
+       if (!GetModuleFileName(nullptr, FullExePath, sizeof(FullExePath)))
                BOOST_THROW_EXCEPTION(win32_error()
                    << boost::errinfo_api_function("GetModuleFileName")
                    << errinfo_win32_error(GetLastError()));
@@ -632,7 +632,7 @@ void Application::AttachDebugger(const String& filename, bool interactive)
                                "gdb",
                                "-p",
                                my_pid_str,
-                               NULL
+                               nullptr
                        };
                        argv = const_cast<char **>(uargv);
                } else {
@@ -647,7 +647,7 @@ void Application::AttachDebugger(const String& filename, bool interactive)
                                "detach",
                                "-ex",
                                "quit",
-                               NULL
+                               nullptr
                        };
                        argv = const_cast<char **>(uargv);
                }
@@ -685,7 +685,7 @@ void Application::SigIntTermHandler(int signum)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_DFL;
-       sigaction(signum, &sa, NULL);
+       sigaction(signum, &sa, nullptr);
 
        Application::Ptr instance = Application::GetInstance();
 
@@ -718,7 +718,7 @@ void Application::SigAbrtHandler(int)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_DFL;
-       sigaction(SIGABRT, &sa, NULL);
+       sigaction(SIGABRT, &sa, nullptr);
 #endif /* _WIN32 */
 
        std::cerr << "Caught SIGABRT." << std::endl
@@ -778,14 +778,14 @@ BOOL WINAPI Application::CtrlHandler(DWORD type)
 
        instance->RequestShutdown();
 
-       SetConsoleCtrlHandler(NULL, FALSE);
+       SetConsoleCtrlHandler(nullptr, FALSE);
        return TRUE;
 }
 
 bool Application::IsProcessElevated(void) {
        BOOL fIsElevated = FALSE;
        DWORD dwError = ERROR_SUCCESS;
-       HANDLE hToken = NULL;
+       HANDLE hToken = nullptr;
 
        if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
                dwError = GetLastError();
@@ -801,13 +801,13 @@ bool Application::IsProcessElevated(void) {
 
        if (hToken) {
                CloseHandle(hToken);
-               hToken = NULL;
+               hToken = nullptr;
        }
 
        if (ERROR_SUCCESS != dwError) {
-               LPSTR mBuf = NULL;
+               LPSTR mBuf = nullptr;
                if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
-                       NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), mBuf, 0, NULL))
+                       nullptr, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), mBuf, 0, nullptr))
                        BOOST_THROW_EXCEPTION(std::runtime_error("Failed to format error message, last error was: " + dwError));
                else
                        BOOST_THROW_EXCEPTION(std::runtime_error(mBuf));
@@ -832,7 +832,7 @@ void Application::ExceptionHandler(void)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_DFL;
-       sigaction(SIGABRT, &sa, NULL);
+       sigaction(SIGABRT, &sa, nullptr);
 #endif /* _WIN32 */
 
        String fname = GetCrashReportFilename();
@@ -937,7 +937,7 @@ void Application::InstallExceptionHandlers(void)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = &Application::SigAbrtHandler;
-       sigaction(SIGABRT, &sa, NULL);
+       sigaction(SIGABRT, &sa, nullptr);
 #else /* _WIN32 */
        SetUnhandledExceptionFilter(&Application::SEHUnhandledExceptionFilter);
 #endif /* _WIN32 */
@@ -954,11 +954,11 @@ int Application::Run(void)
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = &Application::SigIntTermHandler;
-       sigaction(SIGINT, &sa, NULL);
-       sigaction(SIGTERM, &sa, NULL);
+       sigaction(SIGINT, &sa, nullptr);
+       sigaction(SIGTERM, &sa, nullptr);
 
        sa.sa_handler = &Application::SigUsr1Handler;
-       sigaction(SIGUSR1, &sa, NULL);
+       sigaction(SIGUSR1, &sa, nullptr);
 #else /* _WIN32 */
        SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
 #endif /* _WIN32 */
@@ -987,17 +987,17 @@ void Application::UpdatePidFile(const String& filename, pid_t pid)
 {
        ObjectLock olock(this);
 
-       if (m_PidFile != NULL)
+       if (m_PidFile)
                fclose(m_PidFile);
 
        /* There's just no sane way of getting a file descriptor for a
         * C++ ofstream which is why we're using FILEs here. */
        m_PidFile = fopen(filename.CStr(), "r+");
 
-       if (m_PidFile == NULL)
+       if (!m_PidFile)
                m_PidFile = fopen(filename.CStr(), "w");
 
-       if (m_PidFile == NULL) {
+       if (!m_PidFile) {
                Log(LogCritical, "Application")
                    << "Could not open PID file '" << filename << "'.";
                BOOST_THROW_EXCEPTION(std::runtime_error("Could not open PID file '" + filename + "'"));
@@ -1042,8 +1042,7 @@ void Application::ClosePidFile(bool unlink)
 {
        ObjectLock olock(this);
 
-       if (m_PidFile != NULL)
-       {
+       if (m_PidFile) {
                if (unlink) {
                        String pidpath = GetPidPath();
                        ::unlink(pidpath.CStr());
@@ -1052,7 +1051,7 @@ void Application::ClosePidFile(bool unlink)
                fclose(m_PidFile);
        }
 
-       m_PidFile = NULL;
+       m_PidFile = nullptr;
 }
 
 /**
@@ -1065,7 +1064,7 @@ pid_t Application::ReadPidFile(const String& filename)
 {
        FILE *pidfile = fopen(filename.CStr(), "r");
 
-       if (pidfile == NULL)
+       if (!pidfile)
                return 0;
 
 #ifndef _WIN32
index 98abfec4e42f6cd78499ee52a8d10ebc68e1cb05..dce0bf9b20ec56fac41aef555970503546697f86 100644 (file)
@@ -36,7 +36,7 @@ ContextFrame::~ContextFrame(void)
 
 std::list<String>& ContextFrame::GetFrames(void)
 {
-       if (l_Frames.get() == NULL)
+       if (!l_Frames.get())
                l_Frames.reset(new std::list<String>());
 
        return *l_Frames;
index 227bbfb954e0bd1ee8751b1ebb1756925e021269..5c01a0d6eeb5cfc7e61c9e50f37bba686bf5ade0 100644 (file)
@@ -56,7 +56,7 @@ inline void *cast_exception(void *obj, const std::type_info *src, const std::typ
        if (dst->__do_catch(src, &thrown_ptr, 1))
                return thrown_ptr;
        else
-               return NULL;
+               return nullptr;
 #else /* __GLIBCXX__ */
        const libcxx_type_info *srcInfo = static_cast<const libcxx_type_info *>(src);
        const libcxx_type_info *dstInfo = static_cast<const libcxx_type_info *>(dst);
@@ -66,7 +66,7 @@ inline void *cast_exception(void *obj, const std::type_info *src, const std::typ
        if (dstInfo->can_catch(srcInfo, adj))
                return adj;
        else
-               return NULL;
+               return nullptr;
 #endif /* __GLIBCXX__ */
 
 }
@@ -128,7 +128,7 @@ void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
                SetLastExceptionStack(stack);
 
 #ifndef NO_CAST_EXCEPTION
-               if (ex && boost::get_error_info<StackTraceErrorInfo>(*ex) == NULL)
+               if (ex && !boost::get_error_info<StackTraceErrorInfo>(*ex))
                        *ex << StackTraceErrorInfo(stack);
        }
 #endif /* NO_CAST_EXCEPTION */
@@ -137,7 +137,7 @@ void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
        SetLastExceptionContext(context);
 
 #ifndef NO_CAST_EXCEPTION
-       if (ex && boost::get_error_info<ContextTraceErrorInfo>(*ex) == NULL)
+       if (ex && !boost::get_error_info<ContextTraceErrorInfo>(*ex))
                *ex << ContextTraceErrorInfo(context);
 #endif /* NO_CAST_EXCEPTION */
 
@@ -277,7 +277,7 @@ String icinga::DiagnosticInformation(boost::exception_ptr eptr, bool verbose)
        try {
                boost::rethrow_exception(eptr);
        } catch (const std::exception& ex) {
-               return DiagnosticInformation(ex, verbose, pt ? &stack : NULL, pc ? &context : NULL);
+               return DiagnosticInformation(ex, verbose, pt ? &stack : nullptr, pc ? &context : nullptr);
        }
 
        return boost::diagnostic_information(eptr);
@@ -320,7 +320,7 @@ void ScriptError::SetHandledByDebugger(bool handled)
 }
 
 posix_error::posix_error(void)
-       : m_Message(NULL)
+       : m_Message(nullptr)
 { }
 
 posix_error::~posix_error(void) throw()
index fd41847198d6c247b63dfe19a33ae39453d46823..7bbb21ebec58090947541447222559fe9799d736 100644 (file)
@@ -120,7 +120,7 @@ inline std::string to_string(const ContextTraceErrorInfo& e)
        return msgbuf.str();
 }
 
-I2_BASE_API String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = NULL, ContextTrace *context = NULL);
+I2_BASE_API String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = nullptr, ContextTrace *context = nullptr);
 I2_BASE_API String DiagnosticInformation(boost::exception_ptr eptr, bool verbose = true);
 
 class I2_BASE_API posix_error : virtual public std::exception, virtual public boost::exception {
index 374a877c867ce186605213636cefbd2b6582acf4..d179dae3aad10abf1a8abf15ec61defe57b2954d 100644 (file)
@@ -25,7 +25,7 @@ using namespace icinga;
  * Constructor for the FIFO class.
  */
 FIFO::FIFO(void)
-       : m_Buffer(NULL), m_DataSize(0), m_AllocSize(0), m_Offset(0)
+       : m_Buffer(nullptr), m_DataSize(0), m_AllocSize(0), m_Offset(0)
 { }
 
 /**
@@ -53,7 +53,7 @@ void FIFO::ResizeBuffer(size_t newSize, bool decrease)
 
        char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
 
-       if (newBuffer == NULL)
+       if (!newBuffer)
                BOOST_THROW_EXCEPTION(std::bad_alloc());
 
        m_Buffer = newBuffer;
@@ -85,7 +85,7 @@ size_t FIFO::Peek(void *buffer, size_t count, bool allow_partial)
        if (count > m_DataSize)
                count = m_DataSize;
 
-       if (buffer != NULL)
+       if (buffer)
                std::memcpy(buffer, m_Buffer + m_Offset, count);
 
        return count;
@@ -101,7 +101,7 @@ size_t FIFO::Read(void *buffer, size_t count, bool allow_partial)
        if (count > m_DataSize)
                count = m_DataSize;
 
-       if (buffer != NULL)
+       if (buffer)
                std::memcpy(buffer, m_Buffer + m_Offset, count);
 
        m_DataSize -= count;
index df75087017c320aa12a559be657d4002a3ba8d70..5b7bf328e79c85ffd2983368ec4fa49eb2a4b56d 100644 (file)
@@ -102,9 +102,9 @@ String icinga::JsonEncode(const Value& value, bool pretty_print)
 {
 #if YAJL_MAJOR < 2
        yajl_gen_config conf = { pretty_print, "" };
-       yajl_gen handle = yajl_gen_alloc(&conf, NULL);
+       yajl_gen handle = yajl_gen_alloc(&conf, nullptr);
 #else /* YAJL_MAJOR */
-       yajl_gen handle = yajl_gen_alloc(NULL);
+       yajl_gen handle = yajl_gen_alloc(nullptr);
        if (pretty_print)
                yajl_gen_config(handle, yajl_gen_beautify, 1);
 #endif /* YAJL_MAJOR */
@@ -307,8 +307,8 @@ Value icinga::JsonDecode(const String& data)
        static const yajl_callbacks callbacks = {
                DecodeNull,
                DecodeBoolean,
-               NULL,
-               NULL,
+               nullptr,
+               nullptr,
                DecodeNumber,
                DecodeString,
                DecodeStartMap,
@@ -325,9 +325,9 @@ Value icinga::JsonDecode(const String& data)
        JsonContext context;
 
 #if YAJL_MAJOR < 2
-       handle = yajl_alloc(&callbacks, &cfg, NULL, &context);
+       handle = yajl_alloc(&callbacks, &cfg, nullptr, &context);
 #else /* YAJL_MAJOR */
-       handle = yajl_alloc(&callbacks, NULL, &context);
+       handle = yajl_alloc(&callbacks, nullptr, &context);
        yajl_config(handle, yajl_dont_validate_strings, 1);
        yajl_config(handle, yajl_allow_comments, 1);
 #endif /* YAJL_MAJOR */
index 9988b609a779d7bce8fd87325ff248a638d67ea5..7a8c27eb162ac240cdaa408ba9991002a66abb8b 100644 (file)
@@ -46,7 +46,7 @@ void Loader::LoadExtensionLibrary(const String& library)
 #ifdef _WIN32
        HMODULE hModule = LoadLibrary(path.CStr());
 
-       if (hModule == NULL) {
+       if (!hModule) {
                BOOST_THROW_EXCEPTION(win32_error()
                    << boost::errinfo_api_function("LoadLibrary")
                    << errinfo_win32_error(GetLastError())
@@ -55,7 +55,7 @@ void Loader::LoadExtensionLibrary(const String& library)
 #else /* _WIN32 */
        void *hModule = dlopen(path.CStr(), RTLD_NOW | RTLD_GLOBAL);
 
-       if (hModule == NULL) {
+       if (!hModule) {
                BOOST_THROW_EXCEPTION(std::runtime_error("Could not load library '" + path + "': " + dlerror()));
        }
 #endif /* _WIN32 */
index 3fc443ca042412f864aa3ed294fd32a66c62e7cf..8213859cd451dacb19648ec5b720ef89d5c948e4 100644 (file)
@@ -35,7 +35,7 @@ void NetworkStream::Close(void)
 /**
  * Reads data from the stream.
  *
- * @param buffer The buffer where data should be stored. May be NULL if you're
+ * @param buffer The buffer where data should be stored. May be nullptr if you're
  *              not actually interested in the data.
  * @param count The number of bytes to read from the queue.
  * @returns The number of bytes actually read.
index 51a376f1433429d36e00dbac271fb4a369a7d158..3908d27a4d6138b0d430e566d43c05f1d96b16f8 100644 (file)
@@ -35,7 +35,7 @@ struct I2_BASE_API ObjectLock
 {
 public:
        inline ObjectLock(void)
-               : m_Object(NULL), m_Locked(false)
+               : m_Object(nullptr), m_Locked(false)
        { }
 
        inline ~ObjectLock(void)
@@ -96,7 +96,7 @@ public:
 
        inline void Lock(void)
        {
-               ASSERT(!m_Locked && m_Object != NULL);
+               ASSERT(!m_Locked && m_Object);
 
                LockMutex(m_Object);
 
index e5cdba37248aac2751ea0f93d76b9af6a94fe487..d0613db8e06d96420095bbd114c0f9c3476824a9 100644 (file)
@@ -58,7 +58,7 @@ int ObjectType::GetFieldId(const String& name) const
 Field ObjectType::GetFieldInfo(int id) const
 {
        if (id == 0)
-               return Field(1, "String", "type", NULL, NULL, 0, 0);
+               return Field(1, "String", "type", nullptr, nullptr, 0, 0);
        else
                BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
 }
index 808a4160a2aa0664da9dbc2bb338410e51425a1d..f1d416a5106496739f0fee986dac2d62c5e096d5 100644 (file)
@@ -71,7 +71,7 @@ private:
        REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, DefaultObjectFactoryVA<type>)
 
 #define REGISTER_PRIMITIVE_TYPE_NOINST(type, base, prototype)                  \
-       REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, NULL)
+       REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, nullptr)
 
 }
 
index 2f8590f782488f4fd3d41db58465593343d66185..40817517227aeb65a3f9e26d7da8ff9f1fc34850 100644 (file)
@@ -72,7 +72,7 @@ Process::Process(const Process::Arguments& arguments, const Dictionary::Ptr& ext
 #endif /* _WIN32 */
 {
 #ifdef _WIN32
-       m_Overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+       m_Overlapped.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
 #endif /* _WIN32 */
 }
 
@@ -88,7 +88,7 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
 {
        struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
 
-       if (cmsg == NULL || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_len != CMSG_LEN(sizeof(int) * 3)) {
+       if (cmsg == nullptr || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_len != CMSG_LEN(sizeof(int) * 3)) {
                std::cerr << "Invalid 'spawn' request: FDs missing" << std::endl;
                return Empty;
        }
@@ -107,13 +107,13 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
                argv[i] = strdup(arg.CStr());
        }
 
-       argv[arguments->GetLength()] = NULL;
+       argv[arguments->GetLength()] = nullptr;
 
        // build envp
        int envc = 0;
 
        /* count existing environment variables */
-       while (environ[envc] != NULL)
+       while (environ[envc])
                envc++;
 
        char **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
@@ -133,7 +133,7 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
        }
 
        envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0)] = strdup("LC_NUMERIC=C");
-       envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 1] = NULL;
+       envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 1] = nullptr;
 
        extraEnvironment.reset();
 
@@ -170,7 +170,7 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
 
                sigset_t mask;
                sigemptyset(&mask);
-               sigprocmask(SIG_SETMASK, &mask, NULL);
+               sigprocmask(SIG_SETMASK, &mask, nullptr);
 
                if (icinga2_execvpe(argv[0], argv, envp) < 0) {
                        char errmsg[512];
@@ -190,13 +190,13 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
        (void)close(fds[2]);
 
        // free arguments
-       for (int i = 0; argv[i] != NULL; i++)
+       for (int i = 0; argv[i]; i++)
                free(argv[i]);
 
        delete[] argv;
 
        // free environment
-       for (int i = 0; envp[i] != NULL; i++)
+       for (int i = 0; envp[i]; i++)
                free(envp[i]);
 
        delete[] envp;
@@ -241,7 +241,7 @@ static void ProcessHandler(void)
 {
        sigset_t mask;
        sigfillset(&mask);
-       sigprocmask(SIG_SETMASK, &mask, NULL);
+       sigprocmask(SIG_SETMASK, &mask, nullptr);
 
        rlimit rl;
        if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
@@ -508,7 +508,7 @@ static void InitializeProcess(void)
 {
        for (int tid = 0; tid < IOTHREADS; tid++) {
 #ifdef _WIN32
-               l_Events[tid] = CreateEvent(NULL, TRUE, FALSE, NULL);
+               l_Events[tid] = CreateEvent(nullptr, TRUE, FALSE, nullptr);
 #else /* _WIN32 */
 #      ifdef HAVE_PIPE2
                if (pipe2(l_EventFDs[tid], O_CLOEXEC) < 0) {
@@ -601,10 +601,10 @@ bool Process::GetAdjustPriority(void) const
 void Process::IOThreadProc(int tid)
 {
 #ifdef _WIN32
-       HANDLE *handles = NULL;
-       HANDLE *fhandles = NULL;
+       HANDLE *handles = nullptr;
+       HANDLE *fhandles = nullptr;
 #else /* _WIN32 */
-       pollfd *pfds = NULL;
+       pollfd *pfds = nullptr;
 #endif /* _WIN32 */
        int count = 0;
        double now;
@@ -773,7 +773,7 @@ static BOOL CreatePipeOverlapped(HANDLE *outReadPipe, HANDLE *outWritePipe,
        if (*outReadPipe == INVALID_HANDLE_VALUE)
                return FALSE;
 
-       *outWritePipe = CreateFile(pipeName, GENERIC_WRITE, 0, securityAttributes, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | writeMode, NULL);
+       *outWritePipe = CreateFile(pipeName, GENERIC_WRITE, 0, securityAttributes, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | writeMode, nullptr);
 
        if (*outWritePipe == INVALID_HANDLE_VALUE) {
                DWORD error = GetLastError();
@@ -821,7 +821,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
 /*     LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
        SIZE_T cbSize;
 
-       if (!InitializeProcThreadAttributeList(NULL, 1, 0, &cbSize) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+       if (!InitializeProcThreadAttributeList(nullptr, 1, 0, &cbSize) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
                BOOST_THROW_EXCEPTION(win32_error()
                << boost::errinfo_api_function("InitializeProcThreadAttributeList")
                << errinfo_win32_error(GetLastError()));
@@ -839,7 +839,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
        rgHandles[2] = GetStdHandle(STD_INPUT_HANDLE);
 
        if (!UpdateProcThreadAttribute(lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
-           rgHandles, sizeof(rgHandles), NULL, NULL))
+           rgHandles, sizeof(rgHandles), nullptr, nullptr))
                BOOST_THROW_EXCEPTION(win32_error()
                        << boost::errinfo_api_function("UpdateProcThreadAttribute")
                        << errinfo_win32_error(GetLastError()));
@@ -862,7 +862,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
        LPCH pEnvironment = GetEnvironmentStrings();
        size_t ioffset = 0, offset = 0;
 
-       char *envp = NULL;
+       char *envp = nullptr;
 
        for (;;) {
                size_t len = strlen(pEnvironment + ioffset);
@@ -878,7 +878,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
 
                envp = static_cast<char *>(realloc(envp, offset + len + 1));
 
-               if (envp == NULL)
+               if (!envp)
                        BOOST_THROW_EXCEPTION(std::bad_alloc());
 
                strcpy(envp + offset, pEnvironment + ioffset);
@@ -896,7 +896,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
 
                        envp = static_cast<char *>(realloc(envp, offset + skv.GetLength() + 1));
 
-                       if (envp == NULL)
+                       if (!envp)
                                BOOST_THROW_EXCEPTION(std::bad_alloc());
 
                        strcpy(envp + offset, skv.CStr());
@@ -906,13 +906,13 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
 
        envp = static_cast<char *>(realloc(envp, offset + 1));
 
-       if (envp == NULL)
+       if (!envp)
                BOOST_THROW_EXCEPTION(std::bad_alloc());
 
        envp[offset] = '\0';
 
-       if (!CreateProcess(NULL, args, NULL, NULL, TRUE,
-           0 /*EXTENDED_STARTUPINFO_PRESENT*/, envp, NULL, &si.StartupInfo, &pi)) {
+       if (!CreateProcess(nullptr, args, nullptr, nullptr, TRUE,
+           0 /*EXTENDED_STARTUPINFO_PRESENT*/, envp, nullptr, &si.StartupInfo, &pi)) {
                DWORD error = GetLastError();
                CloseHandle(outWritePipe);
                CloseHandle(outWritePipeDup);
index 7e3d14270b225815f236897d2b403e8cccb291b3..2a7d3629f9f4035b9225bc4b1cb3ae484a162a70 100644 (file)
@@ -34,7 +34,7 @@ namespace icinga
 class I2_BASE_API ScriptGlobal
 {
 public:
-       static Value Get(const String& name, const Value *defaultValue = NULL);
+       static Value Get(const String& name, const Value *defaultValue = nullptr);
        static void Set(const String& name, const Value& value);
        static bool Exists(const String& name);
 
index c05fdabfdcb2e561313310acf95f21ebaf2bafd5..05ddce49afbcef3c5f321a3e489857c051628c83 100644 (file)
@@ -155,12 +155,12 @@ Value icinga::Serialize(const Value& value, int attributeTypes)
 
        Array::Ptr array = dynamic_pointer_cast<Array>(input);
 
-       if (array != NULL)
+       if (array)
                return SerializeArray(array, attributeTypes);
 
        Dictionary::Ptr dict = dynamic_pointer_cast<Dictionary>(input);
 
-       if (dict != NULL)
+       if (dict)
                return SerializeDictionary(dict, attributeTypes);
 
        return SerializeObject(input, attributeTypes);
@@ -180,12 +180,12 @@ Value icinga::Deserialize(const Object::Ptr& object, const Value& value, bool sa
 
        Array::Ptr array = dynamic_pointer_cast<Array>(input);
 
-       if (array != NULL)
+       if (array)
                return DeserializeArray(array, safe_mode, attributeTypes);
 
        Dictionary::Ptr dict = dynamic_pointer_cast<Dictionary>(input);
 
-       ASSERT(dict != NULL);
+       ASSERT(dict);
 
        if ((safe_mode && !object) || !dict->Contains("type"))
                return DeserializeDictionary(dict, safe_mode, attributeTypes);
index 12834233bd308b9e2aaa83b285b39386e14d9170..a748ec2edbad14a4ca589d1b5de0fdc573a1779a 100644 (file)
@@ -53,7 +53,7 @@ public:
        void Listen(void);
        Socket::Ptr Accept(void);
 
-       bool Poll(bool read, bool write, struct timeval *timeout = NULL);
+       bool Poll(bool read, bool write, struct timeval *timeout = nullptr);
 
        void MakeNonBlocking(void);
 
index 589fe789a34f4b363fa1358ad4d32af0468bf5b7..6b775abe26db0e35033f6f3fd580359eff47af18 100644 (file)
@@ -174,7 +174,7 @@ void SocketEventEngineEpoll::Unregister(SocketEvents *se)
                m_Sockets[tid].erase(se->m_FD);
                m_FDChanged[tid] = true;
 
-               epoll_ctl(m_PollFDs[tid], EPOLL_CTL_DEL, se->m_FD, NULL);
+               epoll_ctl(m_PollFDs[tid], EPOLL_CTL_DEL, se->m_FD, nullptr);
 
                se->m_FD = INVALID_SOCKET;
                se->m_Events = false;
index 8b77da1a0091f3de024d5def23e751a54ab3c01b..26fbb9223de3d9985e6748f5acfe15a6993132ec 100644 (file)
@@ -112,7 +112,7 @@ void SocketEvents::InitializeEngine(void)
  * Constructor for the SocketEvents class.
  */
 SocketEvents::SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject)
-       : m_ID(m_NextID++), m_FD(socket->GetFD()), m_EnginePrivate(NULL)
+       : m_ID(m_NextID++), m_FD(socket->GetFD()), m_EnginePrivate(nullptr)
 {
        boost::call_once(l_SocketIOOnceFlag, &SocketEvents::InitializeEngine);
 
index c40d36430792dfe1d2bd567c4975978ff1824863..23262258c84ace897602c1d54192fc4f95877d14 100644 (file)
@@ -82,7 +82,7 @@ struct SocketEventDescriptor
        Object *LifesupportObject;
 
        SocketEventDescriptor(void)
-               : Events(POLLIN), EventInterface(NULL), LifesupportObject(NULL)
+               : Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr)
        { }
 };
 
index e4fa7249c4c50209135d95dccd5265654a59b2b1..65aaafd7940c1232cc5e231d225df54febbe0ee1 100644 (file)
@@ -37,7 +37,7 @@ StackTrace::StackTrace(void)
        m_Count = backtrace(m_Frames, sizeof(m_Frames) / sizeof(m_Frames[0]));
 #else /* HAVE_BACKTRACE_SYMBOLS */
 #      ifdef _WIN32
-       m_Count = CaptureStackBackTrace(0, sizeof(m_Frames) / sizeof(m_Frames), m_Frames, NULL);
+       m_Count = CaptureStackBackTrace(0, sizeof(m_Frames) / sizeof(m_Frames), m_Frames, nullptr);
 #      else /* _WIN32 */
        m_Count = 0;
 #      endif /* _WIN32 */
@@ -75,8 +75,8 @@ StackTrace::StackTrace(PEXCEPTION_POINTERS exi)
        m_Count = 0;
 
        while (StackWalk64(architecture, GetCurrentProcess(), GetCurrentThread(),
-           &frame, exi->ContextRecord, NULL, &SymFunctionTableAccess64,
-           &SymGetModuleBase64, NULL) && m_Count < sizeof(m_Frames) / sizeof(m_Frames[0])) {
+           &frame, exi->ContextRecord, nullptr, &SymFunctionTableAccess64,
+           &SymGetModuleBase64, nullptr) && m_Count < sizeof(m_Frames) / sizeof(m_Frames[0])) {
                m_Frames[m_Count] = reinterpret_cast<void *>(frame.AddrPC.Offset);
                m_Count++;
        }
@@ -86,7 +86,7 @@ StackTrace::StackTrace(PEXCEPTION_POINTERS exi)
 #ifdef _WIN32
 INITIALIZE_ONCE([]() {
        (void) SymSetOptions(SYMOPT_UNDNAME | SYMOPT_LOAD_LINES);
-       (void) SymInitialize(GetCurrentProcess(), NULL, TRUE);
+       (void) SymInitialize(GetCurrentProcess(), nullptr, TRUE);
 });
 #endif /* _WIN32 */
 
@@ -106,7 +106,7 @@ void StackTrace::Print(std::ostream& fp, int ignoreFrames) const
 #      ifdef HAVE_BACKTRACE_SYMBOLS
        char **messages = backtrace_symbols(m_Frames, m_Count);
 
-       for (int i = ignoreFrames + 1; i < m_Count && messages != NULL; ++i) {
+       for (int i = ignoreFrames + 1; i < m_Count && messages; ++i) {
                String message = messages[i];
 
                char *sym_begin = strchr(messages[i], '(');
@@ -114,7 +114,7 @@ void StackTrace::Print(std::ostream& fp, int ignoreFrames) const
                if (sym_begin) {
                        char *sym_end = strchr(sym_begin, '+');
 
-                       if (sym_end != NULL) {
+                       if (sym_end) {
                                String sym = String(sym_begin + 1, sym_end);
                                String sym_demangled = Utility::DemangleSymbolName(sym);
 
index bf79a7768c3dbe75a729601b9770709cde5ab9d3..c4a6a7af11ed25cf68f38a9e6767671ca684d7fc 100644 (file)
@@ -39,7 +39,7 @@ enum ConnectionRole
 struct I2_BASE_API StreamReadContext
 {
        StreamReadContext(void)
-               : Buffer(NULL), Size(0), MustRead(true), Eof(false)
+               : Buffer(nullptr), Size(0), MustRead(true), Eof(false)
        { }
 
        ~StreamReadContext(void)
@@ -76,7 +76,7 @@ public:
        /**
         * Reads data from the stream without removing it from the stream buffer.
         *
-        * @param buffer The buffer where data should be stored. May be NULL if you're
+        * @param buffer The buffer where data should be stored. May be nullptr if you're
         *               not actually interested in the data.
         * @param count The number of bytes to read from the queue.
         * @param allow_partial Whether to allow partial reads.
@@ -87,7 +87,7 @@ public:
        /**
         * Reads data from the stream.
         *
-        * @param buffer The buffer where data should be stored. May be NULL if you're
+        * @param buffer The buffer where data should be stored. May be nullptr if you're
         *               not actually interested in the data.
         * @param count The number of bytes to read from the queue.
         * @param allow_partial Whether to allow partial reads.
index cb36a3d403cd7e077a6ef851a1a17d501c136a7a..1bc999970d57cbab3c42c6fc502f6724be28bc8c 100644 (file)
@@ -34,7 +34,7 @@ boost::mutex StreamLogger::m_Mutex;
  * Constructor for the StreamLogger class.
  */
 StreamLogger::StreamLogger(void)
-       : m_Stream(NULL), m_OwnsStream(false)
+       : m_Stream(nullptr), m_OwnsStream(false)
 { }
 
 void StreamLogger::Stop(bool runtimeRemoved)
index 113306436d2fa9a79cfa82ad5f43277955b2e885..a3dcc1429be8d287c6d84683128980dc65558714 100644 (file)
@@ -58,7 +58,7 @@ void TcpSocket::Bind(const String& node, const String& service, int family)
        hints.ai_protocol = IPPROTO_TCP;
        hints.ai_flags = AI_PASSIVE;
 
-       int rc = getaddrinfo(node.IsEmpty() ? NULL : node.CStr(),
+       int rc = getaddrinfo(node.IsEmpty() ? nullptr : node.CStr(),
            service.CStr(), &hints, &result);
 
        if (rc != 0) {
@@ -72,7 +72,7 @@ void TcpSocket::Bind(const String& node, const String& service, int family)
 
        int fd = INVALID_SOCKET;
 
-       for (addrinfo *info = result; info != NULL; info = info->ai_next) {
+       for (addrinfo *info = result; info != nullptr; info = info->ai_next) {
                fd = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
 
                if (fd == INVALID_SOCKET) {
@@ -163,7 +163,7 @@ void TcpSocket::Connect(const String& node, const String& service)
 
        SOCKET fd = INVALID_SOCKET;
 
-       for (addrinfo *info = result; info != NULL; info = info->ai_next) {
+       for (addrinfo *info = result; info != nullptr; info = info->ai_next) {
                fd = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
 
                if (fd == INVALID_SOCKET) {
index d49ffa414fcdc3836e430f4c4e8d0473d76c1cd5..ecef5d9fec6958a9038b2a50187f7caf6105534e 100644 (file)
@@ -83,7 +83,7 @@ private:
                boost::thread *Thread;
 
                WorkerThread(ThreadState state = ThreadDead)
-                       : State(state), Zombie(false), Utilization(0), LastUpdate(0), Thread(NULL)
+                       : State(state), Zombie(false), Utilization(0), LastUpdate(0), Thread(nullptr)
                { }
 
                void UpdateUtilization(ThreadState state = ThreadUnspecified);
index 6f8f0664c85abf998fe118ce411ef92f32d94800..c9f14667ff053cb628f43d04ca6b0cf935f1966c 100644 (file)
@@ -58,7 +58,7 @@ TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, Connecti
        }
 
        if (!m_SSLIndexInitialized) {
-               m_SSLIndex = SSL_get_ex_new_index(0, const_cast<char *>("TlsStream"), NULL, NULL, NULL);
+               m_SSLIndex = SSL_get_ex_new_index(0, const_cast<char *>("TlsStream"), nullptr, nullptr, nullptr);
                m_SSLIndexInitialized = true;
        }
 
@@ -187,7 +187,7 @@ void TlsStream::OnEvent(int revents)
                        rc = SSL_write(m_SSL.get(), buffer, count);
 
                        if (rc > 0) {
-                               m_SendQ->Read(NULL, rc, true);
+                               m_SendQ->Read(nullptr, rc, true);
                                success = true;
                        }
 
@@ -232,7 +232,7 @@ void TlsStream::OnEvent(int revents)
 
                                if (m_ErrorCode != 0) {
                                        Log(LogWarning, "TlsStream")
-                                               << "OpenSSL error: " << ERR_error_string(m_ErrorCode, NULL);
+                                               << "OpenSSL error: " << ERR_error_string(m_ErrorCode, nullptr);
                                } else {
                                        Log(LogWarning, "TlsStream", "TLS stream was disconnected.");
                                }
index 04a6bd1ed3e4e0dc969140d77948e2a49b9f13c0..e357ad40c11b16b82cd507f1bb9cdb40ce06b345 100644 (file)
@@ -142,7 +142,7 @@ std::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& priv
        }
 
        if (!cakey.IsEmpty()) {
-               if (!SSL_CTX_load_verify_locations(sslContext.get(), cakey.CStr(), NULL)) {
+               if (!SSL_CTX_load_verify_locations(sslContext.get(), cakey.CStr(), nullptr)) {
                        Log(LogCritical, "SSL")
                            << "Error loading and verifying locations in ca key file '" << cakey << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
                        BOOST_THROW_EXCEPTION(openssl_error()
@@ -154,7 +154,7 @@ std::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& priv
                STACK_OF(X509_NAME) *cert_names;
 
                cert_names = SSL_load_client_CA_file(cakey.CStr());
-               if (cert_names == NULL) {
+               if (!cert_names) {
                        Log(LogCritical, "SSL")
                            << "Error loading client ca key file '" << cakey << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
                        BOOST_THROW_EXCEPTION(openssl_error()
@@ -298,7 +298,7 @@ std::shared_ptr<X509> GetX509Certificate(const String& pemfile)
        X509 *cert;
        BIO *fpcert = BIO_new(BIO_s_file());
 
-       if (fpcert == NULL) {
+       if (!fpcert) {
                Log(LogCritical, "SSL")
                    << "Error creating new BIO: " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
                BOOST_THROW_EXCEPTION(openssl_error()
@@ -315,8 +315,8 @@ std::shared_ptr<X509> GetX509Certificate(const String& pemfile)
                    << boost::errinfo_file_name(pemfile));
        }
 
-       cert = PEM_read_bio_X509_AUX(fpcert, NULL, NULL, NULL);
-       if (cert == NULL) {
+       cert = PEM_read_bio_X509_AUX(fpcert, nullptr, nullptr, nullptr);
+       if (!cert) {
                Log(LogCritical, "SSL")
                    << "Error on bio X509 AUX reading pem file '" << pemfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
                BOOST_THROW_EXCEPTION(openssl_error()
@@ -379,7 +379,7 @@ int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile,
                    << boost::errinfo_file_name(keyfile));
        }
 
-       if (!PEM_write_bio_PrivateKey(bio, key, NULL, NULL, 0, 0, NULL)) {
+       if (!PEM_write_bio_PrivateKey(bio, key, nullptr, nullptr, 0, 0, nullptr)) {
                EVP_PKEY_free(key);
                EC_KEY_free(eckey);
                BIO_free(bio);
@@ -446,7 +446,7 @@ int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile,
 
                if (!ca) {
                        String san = "DNS:" + cn;
-                       X509_EXTENSION *subjectAltNameExt = X509V3_EXT_conf_nid(NULL, NULL, NID_subject_alt_name, const_cast<char *>(san.CStr()));
+                       X509_EXTENSION *subjectAltNameExt = X509V3_EXT_conf_nid(nullptr, nullptr, NID_subject_alt_name, const_cast<char *>(san.CStr()));
                        if (subjectAltNameExt) {
                                /* OpenSSL 0.9.8 requires STACK_OF(X509_EXTENSION), otherwise we would just use stack_st_X509_EXTENSION. */
                                STACK_OF(X509_EXTENSION) *exts = sk_X509_EXTENSION_new_null();
@@ -539,7 +539,7 @@ std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME
 
        X509V3_CTX ctx;
        X509V3_set_ctx_nodb(&ctx);
-       X509V3_set_ctx(&ctx, cert, cert, NULL, NULL, 0);
+       X509V3_set_ctx(&ctx, cert, cert, nullptr, nullptr, 0);
 
        const char *attr;
 
@@ -548,7 +548,7 @@ std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME
        else
                attr = "critical,CA:FALSE";
 
-       X509_EXTENSION *basicConstraintsExt = X509V3_EXT_conf_nid(NULL, &ctx, NID_basic_constraints, const_cast<char *>(attr));
+       X509_EXTENSION *basicConstraintsExt = X509V3_EXT_conf_nid(nullptr, &ctx, NID_basic_constraints, const_cast<char *>(attr));
 
        if (basicConstraintsExt) {
                X509_add_ext(cert, basicConstraintsExt, -1);
@@ -559,7 +559,7 @@ std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME
 
        if (!ca) {
                String san = "DNS:" + cn;
-               X509_EXTENSION *subjectAltNameExt = X509V3_EXT_conf_nid(NULL, &ctx, NID_subject_alt_name, const_cast<char *>(san.CStr()));
+               X509_EXTENSION *subjectAltNameExt = X509V3_EXT_conf_nid(nullptr, &ctx, NID_subject_alt_name, const_cast<char *>(san.CStr()));
                if (subjectAltNameExt) {
                        X509_add_ext(cert, subjectAltNameExt, -1);
                        X509_EXTENSION_free(subjectAltNameExt);
@@ -592,7 +592,7 @@ std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
                return std::shared_ptr<X509>();
        }
 
-       EVP_PKEY *privkey = PEM_read_bio_PrivateKey(cakeybio, NULL, NULL, NULL);
+       EVP_PKEY *privkey = PEM_read_bio_PrivateKey(cakeybio, nullptr, nullptr, nullptr);
 
        if (!privkey) {
                Log(LogCritical, "SSL")
@@ -635,7 +635,7 @@ std::shared_ptr<X509> StringToCertificate(const String& cert)
        BIO *bio = BIO_new(BIO_s_mem());
        BIO_write(bio, (const void *)cert.CStr(), cert.GetLength());
 
-       X509 *rawCert = PEM_read_bio_X509_AUX(bio, NULL, NULL, NULL);
+       X509 *rawCert = PEM_read_bio_X509_AUX(bio, nullptr, nullptr, nullptr);
 
        BIO_free(bio);
 
@@ -772,7 +772,7 @@ bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::sh
        X509_STORE_add_cert(store, caCertificate.get());
 
        X509_STORE_CTX *csc = X509_STORE_CTX_new();
-       X509_STORE_CTX_init(csc, store, certificate.get(), NULL);
+       X509_STORE_CTX_init(csc, store, certificate.get(), nullptr);
 
        int rc = X509_verify_cert(csc);
 
index 16190710417d5624cb8174ae62746488d5ae56f7..e7734767cc7b2aa1c9334ebcfab079d086d73d00 100644 (file)
@@ -69,7 +69,7 @@ inline std::string to_string(const errinfo_openssl_error& e)
 
        const char *message = ERR_error_string(code, errbuf);
 
-       if (message == NULL)
+       if (!message)
                message = "Unknown error.";
 
        tmp << code << ", \"" << message << "\"";
index f58d6e19352dbc5a8167092aa834602d7b9cdf50..6ea216a2c421f54cd305b055ed78b2b08308f57b 100644 (file)
@@ -39,7 +39,7 @@ String Type::ToString(void) const
 
 void Type::Register(const Type::Ptr& type)
 {
-       VERIFY(GetByName(type->GetName()) == NULL);
+       VERIFY(!GetByName(type->GetName()));
 
        ScriptGlobal::Set("Types." + type->GetName(), type);
 }
@@ -195,11 +195,11 @@ Field TypeType::GetFieldInfo(int id) const
                return GetBaseType()->GetFieldInfo(id);
 
        if (real_id == 0)
-               return Field(0, "String", "name", "", NULL, 0, 0);
+               return Field(0, "String", "name", "", nullptr, 0, 0);
        else if (real_id == 1)
-               return Field(1, "Object", "prototype", "", NULL, 0, 0);
+               return Field(1, "Object", "prototype", "", nullptr, 0, 0);
        else if (real_id == 2)
-               return Field(2, "Type", "base", "", NULL, 0, 0);
+               return Field(2, "Type", "base", "", nullptr, 0, 0);
 
        throw std::runtime_error("Invalid field ID.");
 }
@@ -211,6 +211,6 @@ int TypeType::GetFieldCount(void) const
 
 ObjectFactory TypeType::GetFactory(void) const
 {
-       return NULL;
+       return nullptr;
 }
 
index 24d5b1b9250d45c405a206695dd989f9d66f63c3..19ab1a598b9d2b8d4dedbe17c605ac0562a06f9f 100644 (file)
@@ -85,7 +85,7 @@ String Utility::DemangleSymbolName(const String& sym)
        int status;
        char *realname = abi::__cxa_demangle(sym.CStr(), 0, 0, &status);
 
-       if (realname != NULL) {
+       if (realname) {
                result = String(realname);
                free(realname);
        }
@@ -277,7 +277,7 @@ String Utility::DirName(const String& path)
        dir = strdup(path.CStr());
 #endif /* _WIN32 */
 
-       if (dir == NULL)
+       if (!dir)
                BOOST_THROW_EXCEPTION(std::bad_alloc());
 
        String result;
@@ -315,7 +315,7 @@ String Utility::BaseName(const String& path)
        char *dir = strdup(path.CStr());
        String result;
 
-       if (dir == NULL)
+       if (!dir)
                BOOST_THROW_EXCEPTION(std::bad_alloc());
 
 #ifndef _WIN32
@@ -395,7 +395,7 @@ double Utility::GetTime(void)
 #else /* _WIN32 */
        struct timeval tv;
 
-       int rc = gettimeofday(&tv, NULL);
+       int rc = gettimeofday(&tv, nullptr);
        VERIFY(rc >= 0);
 
        return tv.tv_sec + tv.tv_usec / 1000000.0;
@@ -664,7 +664,7 @@ bool Utility::GlobRecursive(const String& path, const String& pattern, const std
 
        dirp = opendir(path.CStr());
 
-       if (dirp == NULL)
+       if (!dirp)
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("opendir")
                    << boost::errinfo_errno(errno)
@@ -1017,7 +1017,7 @@ String Utility::FormatDateTime(const char *format, double ts)
 #ifdef _MSC_VER
        tm *temp = localtime(&tempts);
 
-       if (temp == NULL) {
+       if (!temp) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime")
                    << boost::errinfo_errno(errno));
@@ -1025,7 +1025,7 @@ String Utility::FormatDateTime(const char *format, double ts)
 
        tmthen = *temp;
 #else /* _MSC_VER */
-       if (localtime_r(&tempts, &tmthen) == NULL) {
+       if (!localtime_r(&tempts, &tmthen)) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime_r")
                    << boost::errinfo_errno(errno));
@@ -1045,8 +1045,8 @@ String Utility::FormatErrorNumber(int code) {
        String result = "Unknown error.";
 
        DWORD rc = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-               FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, code, 0, (char *)&message,
-               0, NULL);
+               FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, code, 0, (char *)&message,
+               0, nullptr);
 
        if (rc != 0) {
                result = String(message);
@@ -1295,10 +1295,10 @@ String Utility::GetFQDN(void)
        hints.ai_flags = AI_CANONNAME;
 
        addrinfo *result;
-       int rc = getaddrinfo(hostname.CStr(), NULL, &hints, &result);
+       int rc = getaddrinfo(hostname.CStr(), nullptr, &hints, &result);
 
        if (rc != 0)
-               result = NULL;
+               result = nullptr;
 
        if (result) {
                if (strcmp(result->ai_canonname, "localhost") != 0)
@@ -1331,7 +1331,7 @@ tm Utility::LocalTime(time_t ts)
 #ifdef _MSC_VER
        tm *result = localtime(&ts);
 
-       if (result == NULL) {
+       if (!result) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime")
                    << boost::errinfo_errno(errno));
@@ -1341,7 +1341,7 @@ tm Utility::LocalTime(time_t ts)
 #else /* _MSC_VER */
        tm result;
 
-       if (localtime_r(&ts, &result) == NULL) {
+       if (!localtime_r(&ts, &result)) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime_r")
                    << boost::errinfo_errno(errno));
@@ -1479,7 +1479,7 @@ static String UnameHelper(char type)
        char line[1024];
        std::ostringstream msgbuf;
 
-       while (fgets(line, sizeof(line), fp) != NULL)
+       while (fgets(line, sizeof(line), fp))
                msgbuf << line;
 
        pclose(fp);
@@ -1557,10 +1557,10 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
        /* You are using a distribution which supports LSB. */
        FILE *fp = popen("type lsb_release >/dev/null 2>&1 && lsb_release -s -i 2>&1", "r");
 
-       if (fp != NULL) {
+       if (fp) {
                std::ostringstream msgbuf;
                char line[1024];
-               while (fgets(line, sizeof(line), fp) != NULL)
+               while (fgets(line, sizeof(line), fp))
                        msgbuf << line;
                int status = pclose(fp);
                if (WEXITSTATUS(status) == 0) {
@@ -1571,10 +1571,10 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
 
        fp = popen("type lsb_release >/dev/null 2>&1 && lsb_release -s -r 2>&1", "r");
 
-       if (fp != NULL) {
+       if (fp) {
                std::ostringstream msgbuf;
                char line[1024];
-               while (fgets(line, sizeof(line), fp) != NULL)
+               while (fgets(line, sizeof(line), fp))
                        msgbuf << line;
                int status = pclose(fp);
                if (WEXITSTATUS(status) == 0) {
@@ -1586,10 +1586,10 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
        /* OS X */
        fp = popen("type sw_vers >/dev/null 2>&1 && sw_vers -productName 2>&1", "r");
 
-       if (fp != NULL) {
+       if (fp) {
                std::ostringstream msgbuf;
                char line[1024];
-               while (fgets(line, sizeof(line), fp) != NULL)
+               while (fgets(line, sizeof(line), fp))
                        msgbuf << line;
                int status = pclose(fp);
                if (WEXITSTATUS(status) == 0) {
@@ -1603,10 +1603,10 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
 
        fp = popen("type sw_vers >/dev/null 2>&1 && sw_vers -productVersion 2>&1", "r");
 
-       if (fp != NULL) {
+       if (fp) {
                std::ostringstream msgbuf;
                char line[1024];
-               while (fgets(line, sizeof(line), fp) != NULL)
+               while (fgets(line, sizeof(line), fp))
                        msgbuf << line;
                int status = pclose(fp);
                if (WEXITSTATUS(status) == 0) {
@@ -1690,7 +1690,7 @@ String Utility::GetPlatformKernelVersion(void)
 String Utility::GetPlatformName(void)
 {
        String platformName;
-       if (!ReleaseHelper(&platformName, NULL))
+       if (!ReleaseHelper(&platformName, nullptr))
                return "Unknown";
        return platformName;
 }
@@ -1698,7 +1698,7 @@ String Utility::GetPlatformName(void)
 String Utility::GetPlatformVersion(void)
 {
        String platformVersion;
-       if (!ReleaseHelper(NULL, &platformVersion))
+       if (!ReleaseHelper(nullptr, &platformVersion))
                return "Unknown";
        return platformVersion;
 }
@@ -1928,7 +1928,7 @@ String Utility::GetIcingaInstallPath(void)
 String Utility::GetIcingaDataPath(void)
 {
        char path[MAX_PATH];
-       if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path)))
+       if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_COMMON_APPDATA, nullptr, 0, path)))
                return "";
        return String(path) + "\\icinga2";
 }
index 0eab3712cbe41e51e036af9b64b6dfa87a2444c6..996a6a25b615a02bb727e117b3fdbfa98240b722 100644 (file)
@@ -259,7 +259,7 @@ public:
                if (!IsObject())
                        return false;
 
-               return (dynamic_cast<T *>(boost::get<Object::Ptr>(m_Value).get()) != NULL);
+               return dynamic_cast<T *>(boost::get<Object::Ptr>(m_Value).get());
        }
 
        /**
index 3b150505d36e54c695aa5982483182e73ee4832d..b678c8218d3a6d5e4f72fc77ad9ac91c536fe6d6 100644 (file)
@@ -78,9 +78,9 @@ public:
           CLICommand::Ptr& command, bool autocomplete);
 
        static void ShowCommands(int argc, char **argv,
-           boost::program_options::options_description *visibleDesc = NULL,
-           boost::program_options::options_description *hiddenDesc = NULL,
-           ArgumentCompletionCallback globalArgCompletionCallback = NULL,
+           boost::program_options::options_description *visibleDesc = nullptr,
+           boost::program_options::options_description *hiddenDesc = nullptr,
+           ArgumentCompletionCallback globalArgCompletionCallback = nullptr,
            bool autocomplete = false, int autoindex = -1);
 
 private:
index 42a225b4a8905d691b2b038c19b17f20f2c60677..0ace2fc6956417bde986181cb5738516c31f514f 100644 (file)
@@ -68,7 +68,7 @@ extern "C" void dbg_inspect_object(Object *obj)
 
 extern "C" void dbg_eval(const char *text)
 {
-       Expression *expr = NULL;
+       Expression *expr = nullptr;
 
        try {
                ScriptFrame frame;
@@ -84,7 +84,7 @@ extern "C" void dbg_eval(const char *text)
 
 extern "C" void dbg_eval_with_value(const Value& value, const char *text)
 {
-       Expression *expr = NULL;
+       Expression *expr = nullptr;
 
        try {
                ScriptFrame frame;
@@ -102,7 +102,7 @@ extern "C" void dbg_eval_with_value(const Value& value, const char *text)
 
 extern "C" void dbg_eval_with_object(Object *object, const char *text)
 {
-       Expression *expr = NULL;
+       Expression *expr = nullptr;
 
        try {
                ScriptFrame frame;
@@ -214,7 +214,7 @@ char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
        }
 
        if (state >= static_cast<int>(matches.size()))
-               return NULL;
+               return nullptr;
 
        return strdup(matches[state].CStr());
 }
@@ -400,7 +400,7 @@ incomplete:
 
                command += line;
 
-               Expression *expr = NULL;
+               Expression *expr = nullptr;
 
                try {
                        lines[fileName] = command;
index e9d0d60d6dd97941cd22d562bf85060b9d7eacf9..199552b921a8ae4d0e6a7eec89bfa59aabd4acb3 100644 (file)
@@ -306,7 +306,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = &SigHupHandler;
-       sigaction(SIGHUP, &sa, NULL);
+       sigaction(SIGHUP, &sa, nullptr);
 #endif /* _WIN32 */
 
        ApiListener::UpdateObjectAuthority();
index 28ea6cb72ff80dc39ebb2dd4f58043a7fa4d924d..90d785ad6740dc7066b47ae8944ff0dffaae18c5 100644 (file)
@@ -185,7 +185,7 @@ bool TroubleshootCommand::ObjectInfo(InfoLog& log, const boost::program_options:
                    << "FAILED: This probably means you have a fault configuration.\n";
                return false;
        } else {
-               InfoLog *OFile = NULL;
+               InfoLog *OFile = nullptr;
                bool OConsole = false;
                if (vm.count("include-objects")) {
                        if (vm.count("console"))
@@ -196,7 +196,7 @@ bool TroubleshootCommand::ObjectInfo(InfoLog& log, const boost::program_options:
                                        InfoLogLine(log, 0, LogWarning)
                                            << "Failed to open Object-write-stream, not printing objects\n\n";
                                        delete OFile;
-                                       OFile = NULL;
+                                       OFile = nullptr;
                                } else
                                        InfoLogLine(log)
                                        << "Printing all objects to " << path+"-objects\n";
index 6ce2891d5accbc48c75afe0698582f948d7ce06d..3c98407cc5c8aa802b09486ce51aa17255b7148b 100644 (file)
@@ -541,7 +541,7 @@ void CompatLogger::ScheduleNextRotation(void)
 #ifdef _MSC_VER
        tm *temp = localtime(&now);
 
-       if (temp == NULL) {
+       if (!temp) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime")
                    << boost::errinfo_errno(errno));
@@ -549,7 +549,7 @@ void CompatLogger::ScheduleNextRotation(void)
 
        tmthen = *temp;
 #else /* _MSC_VER */
-       if (localtime_r(&now, &tmthen) == NULL) {
+       if (!localtime_r(&now, &tmthen)) {
                BOOST_THROW_EXCEPTION(posix_error()
                    << boost::errinfo_api_function("localtime_r")
                    << boost::errinfo_errno(errno));
index ec9c7c8c9a76c00fc2641f932e8f2b3fa8a90abf..e200bde9e4864d55f51c8a79d6a8906fc71ce75d 100644 (file)
@@ -385,7 +385,7 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl
              "\t" "max_attempts=" << checkable->GetMaxCheckAttempts() << "\n"
              "\t" "last_state_change=" << static_cast<long>(checkable->GetLastStateChange()) << "\n"
              "\t" "last_hard_state_change=" << static_cast<long>(checkable->GetLastHardStateChange()) << "\n"
-             "\t" "last_update=" << static_cast<long>(time(NULL)) << "\n"
+             "\t" "last_update=" << static_cast<long>(time(nullptr)) << "\n"
              "\t" "notifications_enabled=" << CompatUtility::GetCheckableNotificationsEnabled(checkable) << "\n"
              "\t" "active_checks_enabled=" << CompatUtility::GetCheckableActiveChecksEnabled(checkable) << "\n"
              "\t" "passive_checks_enabled=" << CompatUtility::GetCheckablePassiveChecksEnabled(checkable) << "\n"
index fcb9c13d50f5c77613f773e0d740fd90a37fbf59..d4db5b1761830da52259536be3d376fd7bf0fd06 100644 (file)
@@ -32,7 +32,7 @@ ConfigCompilerContext *ConfigCompilerContext::GetInstance(void)
 }
 
 ConfigCompilerContext::ConfigCompilerContext(void)
-    : m_ObjectsFP(NULL)
+    : m_ObjectsFP(nullptr)
 { }
 
 void ConfigCompilerContext::OpenObjectsFile(const String& filename)
@@ -69,7 +69,7 @@ void ConfigCompilerContext::WriteObject(const Dictionary::Ptr& object)
 void ConfigCompilerContext::CancelObjectsFile(void)
 {
        delete m_ObjectsFP;
-       m_ObjectsFP = NULL;
+       m_ObjectsFP = nullptr;
 
 #ifdef _WIN32
        _unlink(m_ObjectsTempFile.CStr());
@@ -81,7 +81,7 @@ void ConfigCompilerContext::CancelObjectsFile(void)
 void ConfigCompilerContext::FinishObjectsFile(void)
 {
        delete m_ObjectsFP;
-       m_ObjectsFP = NULL;
+       m_ObjectsFP = nullptr;
 
 #ifdef _WIN32
        _unlink(m_ObjectsPath.CStr());
index f7dcb1a22ff264d7edf0e1b8acd43990f075db2c..af3eb883d9fa1b12a6e42e95ec07edba34569cd2 100644 (file)
@@ -137,7 +137,7 @@ bool VariableExpression::GetReference(ScriptFrame& frame, bool init_dict, Value
                *parent = frame.Locals;
 
                if (dhint)
-                       *dhint = NULL;
+                       *dhint = nullptr;
        } else if (frame.Self.IsObject() && frame.Locals != frame.Self.Get<Object::Ptr>() && frame.Self.Get<Object::Ptr>()->HasOwnField(m_Variable)) {
                *parent = frame.Self;
 
@@ -149,7 +149,7 @@ bool VariableExpression::GetReference(ScriptFrame& frame, bool init_dict, Value
                *parent = ScriptGlobal::GetGlobals();
 
                if (dhint)
-                       *dhint = NULL;
+                       *dhint = nullptr;
        } else
                *parent = frame.Self;
 
@@ -487,7 +487,7 @@ ExpressionResult DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint
 
        try {
                for (Expression *aexpr : m_Expressions) {
-                       ExpressionResult element = aexpr->Evaluate(frame, m_Inline ? dhint : NULL);
+                       ExpressionResult element = aexpr->Evaluate(frame, m_Inline ? dhint : nullptr);
                        CHECK_RESULT(element);
                        result = element.GetValue();
                }
@@ -643,7 +643,7 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
 {
        Value vparent;
        String vindex;
-       DebugHint *psdhint = NULL;
+       DebugHint *psdhint = nullptr;
        bool free_psd = false;
 
        if (dhint)
@@ -674,7 +674,7 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
                if (psdhint)
                        *dhint = new DebugHint(psdhint->GetChild(*index));
                else
-                       *dhint = NULL;
+                       *dhint = nullptr;
        }
 
        if (free_psd)
@@ -921,7 +921,7 @@ ExpressionResult IncludeExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dh
 
 ExpressionResult BreakpointExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
 {
-       ScriptBreakpoint(frame, NULL, GetDebugInfo());
+       ScriptBreakpoint(frame, nullptr, GetDebugInfo());
 
        return Empty;
 }
index c5cd197b34f7a3bdefe7dc538061d2f66fad2401..e8046448fd359de37d770ce86873c2e2539d1bc6 100644 (file)
@@ -200,8 +200,8 @@ class I2_CONFIG_API Expression
 public:
        virtual ~Expression(void);
 
-       ExpressionResult Evaluate(ScriptFrame& frame, DebugHint *dhint = NULL) const;
-       virtual bool GetReference(ScriptFrame& frame, bool init_dict, Value *parent, String *index, DebugHint **dhint = NULL) const;
+       ExpressionResult Evaluate(ScriptFrame& frame, DebugHint *dhint = nullptr) const;
+       virtual bool GetReference(ScriptFrame& frame, bool init_dict, Value *parent, String *index, DebugHint **dhint = nullptr) const;
        virtual const DebugInfo& GetDebugInfo(void) const;
 
        virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const = 0;
index b3c11eefd90df15f807743acbd9a5de153a671b6..72ff71bae3899990467b4257634bb867e96c2edb 100644 (file)
@@ -52,10 +52,10 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
        resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String idoType = MacroProcessor::ResolveMacros("$ido_type$", resolvers, checkable->GetLastCheckResult(),
-           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
        String idoName = MacroProcessor::ResolveMacros("$ido_name$", resolvers, checkable->GetLastCheckResult(),
-           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
        if (resolvedMacros && !useResolvedMacros)
                return;
index 59be843ea2513ae206c20fd94e905534e479423e..8b2b52227ab6305ccfc0ad73bef6ab882f1042b1 100644 (file)
@@ -235,18 +235,18 @@ void IdoMysqlConnection::Reconnect(void)
        isslCaPath = GetSslCapath();
        isslCipher = GetSslCipher();
 
-       host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
+       host = (!ihost.IsEmpty()) ? ihost.CStr() : nullptr;
        port = GetPort();
-       socket_path = (!isocket_path.IsEmpty()) ? isocket_path.CStr() : NULL;
-       user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
-       passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
-       db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
-
-       sslKey = (!isslKey.IsEmpty()) ? isslKey.CStr() : NULL;
-       sslCert = (!isslCert.IsEmpty()) ? isslCert.CStr() : NULL;
-       sslCa = (!isslCa.IsEmpty()) ? isslCa.CStr() : NULL;
-       sslCaPath = (!isslCaPath.IsEmpty()) ? isslCaPath.CStr() : NULL;
-       sslCipher = (!isslCipher.IsEmpty()) ? isslCipher.CStr() : NULL;
+       socket_path = (!isocket_path.IsEmpty()) ? isocket_path.CStr() : nullptr;
+       user = (!iuser.IsEmpty()) ? iuser.CStr() : nullptr;
+       passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : nullptr;
+       db = (!idb.IsEmpty()) ? idb.CStr() : nullptr;
+
+       sslKey = (!isslKey.IsEmpty()) ? isslKey.CStr() : nullptr;
+       sslCert = (!isslCert.IsEmpty()) ? isslCert.CStr() : nullptr;
+       sslCa = (!isslCa.IsEmpty()) ? isslCa.CStr() : nullptr;
+       sslCaPath = (!isslCaPath.IsEmpty()) ? isslCaPath.CStr() : nullptr;
+       sslCipher = (!isslCipher.IsEmpty()) ? isslCipher.CStr() : nullptr;
 
        /* connection */
        if (!mysql_init(&m_Connection)) {
index 2db019072a9f654acab3419cd58a4200039ebcb2..bf71bf5d61e6f306901822944dcce2239d5494e8 100644 (file)
@@ -210,13 +210,13 @@ void IdoPgsqlConnection::Reconnect(void)
        ipasswd = GetPassword();
        idb = GetDatabase();
 
-       host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
-       port = (!iport.IsEmpty()) ? iport.CStr() : NULL;
-       user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
-       passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
-       db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
+       host = (!ihost.IsEmpty()) ? ihost.CStr() : nullptr;
+       port = (!iport.IsEmpty()) ? iport.CStr() : nullptr;
+       user = (!iuser.IsEmpty()) ? iuser.CStr() : nullptr;
+       passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : nullptr;
+       db = (!idb.IsEmpty()) ? idb.CStr() : nullptr;
 
-       m_Connection = PQsetdbLogin(host, port, NULL, NULL, db, user, passwd);
+       m_Connection = PQsetdbLogin(host, port, nullptr, nullptr, db, user, passwd);
 
        if (!m_Connection)
                return;
@@ -508,7 +508,7 @@ String IdoPgsqlConnection::Escape(const String& s)
        size_t length = utf8s.GetLength();
        char *to = new char[utf8s.GetLength() * 2 + 1];
 
-       PQescapeStringConn(m_Connection, to, utf8s.CStr(), length, NULL);
+       PQescapeStringConn(m_Connection, to, utf8s.CStr(), length, nullptr);
 
        String result = String(to);
 
index 61a4905a2d7e0550cebe12f9b6e037af9ce99c50..03b8296cb39ef262667da785f7a35761f11c964e 100644 (file)
@@ -67,7 +67,7 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
 {
        double interval;
 
-       if (GetStateType() == StateTypeSoft && GetLastCheckResult() != NULL)
+       if (GetStateType() == StateTypeSoft && GetLastCheckResult() != nullptr)
                interval = GetRetryInterval();
        else
                interval = GetCheckInterval();
@@ -85,7 +85,7 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
 
 bool Checkable::HasBeenChecked(void) const
 {
-       return GetLastCheckResult() != NULL;
+       return GetLastCheckResult() != nullptr;
 }
 
 double Checkable::GetLastCheck(void) const
@@ -445,7 +445,7 @@ void Checkable::ExecuteCheck(void)
        bool local = !endpoint || endpoint == Endpoint::GetLocalEndpoint();
 
        if (local) {
-               GetCheckCommand()->Execute(this, cr, NULL, false);
+               GetCheckCommand()->Execute(this, cr, nullptr, false);
        } else {
                Dictionary::Ptr macros = new Dictionary();
                GetCheckCommand()->Execute(this, cr, macros, false);
index ca7b479baa50c0b35b34830c105350fcfa007e82..9341e91fa86c08d46eba56922f1092635efd23b0 100644 (file)
@@ -94,7 +94,7 @@ public:
 
        void AddGroup(const String& name);
 
-       bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = NULL, int rstack = 0) const;
+       bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = nullptr, int rstack = 0) const;
 
        AcknowledgementType GetAcknowledgement(void);
 
index 4a831901a2663498c2a390b5b573a3ed59e0ec90..cd59df144b47001dfa20c5530839cbb632937ff4 100644 (file)
@@ -292,7 +292,7 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
 
                String second = def.SubStr(pos + 1).Trim();
 
-               ParseTimeSpec(first, begin, NULL, reference);
+               ParseTimeSpec(first, begin, nullptr, reference);
 
                /* If the second definition starts with a number we need
                 * to add the first word from the first definition, e.g.:
@@ -313,7 +313,7 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
                        second = first.SubStr(0, xpos + 1) + second;
                }
 
-               ParseTimeSpec(second, NULL, end, reference);
+               ParseTimeSpec(second, nullptr, end, reference);
        } else {
                ParseTimeSpec(def, begin, end, reference);
        }
index 570912280e236fc7b9d040e6630e67eb3fded5d5..e3d81202f174d29d39ea84fb9c5ae05a71f6f5d0 100644 (file)
@@ -454,7 +454,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P
 {
        Value resolvedCommand;
        if (!arguments || command.IsObjectType<Array>() || command.IsObjectType<Function>())
-               resolvedCommand = MacroProcessor::ResolveMacros(command, resolvers, cr, NULL,
+               resolvedCommand = MacroProcessor::ResolveMacros(command, resolvers, cr, nullptr,
                    EscapeMacroShellArg, resolvedMacros, useResolvedMacros, recursionLevel + 1);
        else {
                Array::Ptr arr = new Array();
index 0adc5acbce375bf0b3dc4089ed9f8e58df5e060a..1b2c015da0e26374e52e402282edf69a4e98c6c7 100644 (file)
@@ -41,7 +41,7 @@ public:
        typedef std::vector<ResolverSpec> ResolverList;
 
        static Value ResolveMacros(const Value& str, const ResolverList& resolvers,
-           const CheckResult::Ptr& cr = nullptr, String *missingMacro = NULL,
+           const CheckResult::Ptr& cr = nullptr, String *missingMacro = nullptr,
            const EscapeCallback& escapeFn = EscapeCallback(),
            const Dictionary::Ptr& resolvedMacros = nullptr,
            bool useResolvedMacros = false, int recursionLevel = 0);
index 15b390a6ddf70a46db0d5dc1740bfa92b057f973..9cb5db8cf037846946646961f91d3fb3ece2021a 100644 (file)
@@ -73,7 +73,7 @@ void PluginUtility::ExecuteCommand(const Command::Ptr& commandObj, const Checkab
                        String name = kv.second;
 
                        Value value = MacroProcessor::ResolveMacros(name, macroResolvers, cr,
-                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros,
+                           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros,
                            useResolvedMacros);
 
                        if (value.IsObjectType<Array>())
index 71d7402db6be9b186e6ed86520ad115444cf9a69..5926a0719bcc9bd212632368f8560cbcbebbb3f7 100644 (file)
@@ -526,7 +526,7 @@ void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream)
                        auto it = allStats.find(statsKey);
 
                        if (it == allStats.end()) {
-                               std::vector<AggregatorState *> newStats(m_Aggregators.size(), NULL);
+                               std::vector<AggregatorState *> newStats(m_Aggregators.size(), nullptr);
                                it = allStats.insert(std::make_pair(statsKey, newStats)).first;
                        }
 
index 20640898b1ae5df114342c9500c834c83e9ef2ec..9376fcff262e22280a1f55e7e14569e30a46b100 100644 (file)
@@ -51,7 +51,7 @@ static void InitializeClr(void)
 {
        ICorRuntimeHost *runtimeHost;
 
-       if (FAILED(CorBindToRuntimeEx(NULL, NULL,
+       if (FAILED(CorBindToRuntimeEx(nullptr, nullptr,
            STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN | STARTUP_CONCURRENT_GC,
            CLSID_CorRuntimeHost, IID_ICorRuntimeHost, (void **)&runtimeHost))) {
                return;
@@ -59,7 +59,7 @@ static void InitializeClr(void)
 
        runtimeHost->Start();
 
-       IUnknownPtr punkAppDomain = NULL;
+       IUnknownPtr punkAppDomain = nullptr;
        runtimeHost->GetDefaultDomain(&punkAppDomain);
 
        punkAppDomain->QueryInterface(__uuidof(mscorlib::_AppDomain), (void **)&l_AppDomain);
@@ -87,7 +87,7 @@ static variant_t InvokeClrMethod(const variant_t& vtObject, const String& method
        HRESULT hr = CLSIDFromProgID(L"System.Collections.Hashtable", &clsid);
 
        mscorlib::IDictionaryPtr pHashtable;
-       CoCreateInstance(clsid, NULL, CLSCTX_ALL, __uuidof(mscorlib::IDictionary), (void **)&pHashtable);
+       CoCreateInstance(clsid, nullptr, CLSCTX_ALL, __uuidof(mscorlib::IDictionary), (void **)&pHashtable);
 
        ObjectLock olock(args);
        for (const Dictionary::Pair& kv : args) {
@@ -107,7 +107,7 @@ static variant_t InvokeClrMethod(const variant_t& vtObject, const String& method
 
        variant_t result = pType->InvokeMember_3(methodName.CStr(),
                mscorlib::BindingFlags_InvokeMethod,
-               NULL,
+               nullptr,
                vtObject,
                psa);
 
@@ -125,19 +125,19 @@ static void FillCheckResult(const CheckResult::Ptr& cr, variant_t vtResult)
        SAFEARRAY *psa = SafeArrayCreateVector(VT_VARIANT, 0, 0);
        int lState = pType->InvokeMember_3("State",
                mscorlib::BindingFlags_GetField,
-               NULL,
+               nullptr,
                vtResult,
                psa);
        cr->SetState(static_cast<ServiceState>(lState));
        bstr_t sOutput = pType->InvokeMember_3("Output",
                mscorlib::BindingFlags_GetField,
-               NULL,
+               nullptr,
                vtResult,
                psa);
        cr->SetOutput(static_cast<const char *>(sOutput));
        bstr_t sPerformanceData = pType->InvokeMember_3("PerformanceData",
                mscorlib::BindingFlags_GetField,
-               NULL,
+               nullptr,
                vtResult,
                psa);
        SafeArrayDestroy(psa);
@@ -171,7 +171,7 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
                        String name = kv.second;
 
                        Value value = MacroProcessor::ResolveMacros(name, resolvers, checkable->GetLastCheckResult(),
-                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+                           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
                        envMacros->Set(kv.first, value);
                }
@@ -188,9 +188,9 @@ void ClrCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
                        vtObject = it->second;
                } else {
                        String clr_assembly = MacroProcessor::ResolveMacros("$clr_assembly$", resolvers, checkable->GetLastCheckResult(),
-                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+                           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
                        String clr_type = MacroProcessor::ResolveMacros("$clr_type$", resolvers, checkable->GetLastCheckResult(),
-                           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+                           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
                        if (resolvedMacros && !useResolvedMacros)
                                return;
index 7e240edd9d4186c2504315936c423b30b938ab06..87cd759ff8957a6cbd23ef174cbdc7939ff056d5 100644 (file)
@@ -58,7 +58,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
        resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        String zoneName = MacroProcessor::ResolveMacros("$cluster_zone$", resolvers, checkable->GetLastCheckResult(),
-           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
        String missingLagWarning;
        String missingLagCritical;
index 652ef7e4a84e9490c5dabd6edb55eb75a8816b0a..d7f9d3f832d9bba0c6c388763d4b228450b3af1b 100644 (file)
@@ -50,10 +50,10 @@ void DummyCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResu
        resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        int dummyState = MacroProcessor::ResolveMacros("$dummy_state$", resolvers, checkable->GetLastCheckResult(),
-           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
        String dummyText = MacroProcessor::ResolveMacros("$dummy_text$", resolvers, checkable->GetLastCheckResult(),
-           NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
+           nullptr, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
        if (resolvedMacros && !useResolvedMacros)
                return;
index 75ca4008b349e5f3ad66740d883f52f8e033e332..213feed1379377caea7901a797baabd57206f702 100644 (file)
@@ -206,9 +206,9 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
        String prefix;
 
        if (service) {
-               prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, NULL, std::bind(&GraphiteWriter::EscapeMacroMetric, _1));
+               prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, nullptr, std::bind(&GraphiteWriter::EscapeMacroMetric, _1));
        } else {
-               prefix = MacroProcessor::ResolveMacros(GetHostNameTemplate(), resolvers, cr, NULL, std::bind(&GraphiteWriter::EscapeMacroMetric, _1));
+               prefix = MacroProcessor::ResolveMacros(GetHostNameTemplate(), resolvers, cr, nullptr, std::bind(&GraphiteWriter::EscapeMacroMetric, _1));
        }
 
        String prefixPerfdata = prefix + ".perfdata";
index 1350edfea588edfe2741cd68a46d3df98c1c898a..a23827bd30e6b24f3e40125372083e3367fe08b9 100644 (file)
@@ -105,7 +105,7 @@ void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
        resolvers.emplace_back("icinga", IcingaApplication::GetInstance());
 
        if (service) {
-               String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, NULL, &PerfdataWriter::EscapeMacroMetric);
+               String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);
 
                {
                        ObjectLock olock(this);
@@ -115,7 +115,7 @@ void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
                        m_ServiceOutputFile << line << "\n";
                }
        } else {
-               String line = MacroProcessor::ResolveMacros(GetHostFormatTemplate(), resolvers, cr, NULL, &PerfdataWriter::EscapeMacroMetric);
+               String line = MacroProcessor::ResolveMacros(GetHostFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);
 
                {
                        ObjectLock olock(this);
index 09344a4f9a9685c1c8f65efd82f1fa3fb89d0ac2..fd1afc1e813d4fb05f4204f8c30a8100fe43f5fe 100644 (file)
@@ -132,7 +132,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
                ScriptFrame frame;
                expr->Evaluate(frame);
                delete expr;
-               expr = NULL;
+               expr = nullptr;
 
                WorkQueue upq;
                std::vector<ConfigItem::Ptr> newItems;
index 9004a57aef865544aa12c4d23cb0f3dded1bd95b..ed2748c3a24805fbd2abc6a0adc9c026a9b502bc 100644 (file)
@@ -123,7 +123,7 @@ bool ConsoleHandler::ExecuteScriptHelper(HttpRequest& request, HttpResponse& res
 
        Array::Ptr results = new Array();
        Dictionary::Ptr resultInfo = new Dictionary();
-       Expression *expr = NULL;
+       Expression *expr = nullptr;
        Value exprResult;
 
        try {
index 5681214a2b1909c8b459ae3689e040218f499c7c..e7b0b4bf95c7285bde734f82b938ce931af5bbe8 100644 (file)
@@ -25,7 +25,7 @@
 using namespace icinga;
 
 EventQueue::EventQueue(const String& name)
-    : m_Name(name), m_Filter(NULL)
+    : m_Name(name), m_Filter(nullptr)
 { }
 
 EventQueue::~EventQueue(void)
index e27b136d294fdf042b137c3e1afe5f7c319190fa..c8c57c6b596b05f3bae20485a14af1ec45060c24 100644 (file)
@@ -66,7 +66,7 @@ bool EventsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request
 
        String filter = HttpUtility::GetLastParameter(params, "filter");
 
-       Expression *ufilter = NULL;
+       Expression *ufilter = nullptr;
 
        if (!filter.IsEmpty())
                ufilter = ConfigCompiler::CompileText("<API query>", filter);
index 8038314d6c98850d3ecef10d94738c75194c3b49..672d3afe547945fc54607c69ae4fca1fd318e244 100644 (file)
@@ -133,7 +133,7 @@ static void FilteredAddTarget(ScriptFrame& permissionFrame, Expression *permissi
 void FilterUtility::CheckPermission(const ApiUser::Ptr& user, const String& permission, Expression **permissionFilter)
 {
        if (permissionFilter)
-               *permissionFilter = NULL;
+               *permissionFilter = nullptr;
 
        if (permission.IsEmpty())
                return;
@@ -250,7 +250,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
                frame.Sandboxed = true;
                Dictionary::Ptr uvars = new Dictionary();
 
-               Expression *ufilter = NULL;
+               Expression *ufilter = nullptr;
 
                if (query->Contains("filter")) {
                        String filter = HttpUtility::GetLastParameter(query, "filter");
index 461cfd6384c751662f728b6cf857c1e545b7de28..6b06def31c624f131a59d51657936b5f0ecf8019 100644 (file)
@@ -68,7 +68,7 @@ class I2_REMOTE_API FilterUtility
 {
 public:
        static Type::Ptr TypeFromPluralName(const String& pluralName);
-       static void CheckPermission(const ApiUser::Ptr& user, const String& permission, Expression **filter = NULL);
+       static void CheckPermission(const ApiUser::Ptr& user, const String& permission, Expression **filter = nullptr);
        static std::vector<Value> GetFilterTargets(const QueryDescription& qd, const Dictionary::Ptr& query,
            const ApiUser::Ptr& user, const String& variableName = String());
        static bool EvaluateFilter(ScriptFrame& frame, Expression *filter,
index a1be4bd459c59239202801f038d3c7a393368d2b..82f144dd3000558216a1cbfe65413207723fcfed 100644 (file)
@@ -226,7 +226,7 @@ void HttpRequest::Finish(void)
                if (m_State == HttpRequestStart || m_State == HttpRequestHeaders)
                        FinishHeaders();
 
-               WriteBody(NULL, 0);
+               WriteBody(nullptr, 0);
                m_Stream->Write("\r\n", 2);
        }
 
index 308cbd27244a41d41a270cab1eedcda3e116c881..e8b1b70616f32182cbfea6a2e16dc9e36638dc88 100644 (file)
@@ -108,7 +108,7 @@ void HttpResponse::Finish(void)
                        m_Stream->Write(buffer, rc);
                }
        } else {
-               WriteBody(NULL, 0);
+               WriteBody(nullptr, 0);
                m_Stream->Write("\r\n", 2);
        }
 
index 0457b6ed0917a9281a100e95ddcd3bec15fda052..3aa5006ffb14aee167bebfd5cf07f3a973fbb2f0 100644 (file)
@@ -71,7 +71,7 @@ int PkiUtility::SignCsr(const String& csrfile, const String& certfile)
        InitializeOpenSSL();
 
        BIO *csrbio = BIO_new_file(csrfile.CStr(), "r");
-       X509_REQ *req = PEM_read_bio_X509_REQ(csrbio, NULL, NULL, NULL);
+       X509_REQ *req = PEM_read_bio_X509_REQ(csrbio, nullptr, nullptr, nullptr);
 
        if (!req) {
                Log(LogCritical, "SSL")
@@ -396,7 +396,7 @@ static void CollectRequestHandler(const Dictionary::Ptr& requests, const String&
 /* XXX (requires OpenSSL >= 1.0.0)
        time_t now;
        time(&now);
-       ASN1_TIME *tm = ASN1_TIME_adj(NULL, now, 0, 0);
+       ASN1_TIME *tm = ASN1_TIME_adj(nullptr, now, 0, 0);
 
        int day, sec;
        ASN1_TIME_diff(&day, &sec, tm, X509_get_notBefore(certRequest.get()));
index 6da89cd562068ff43a091fc6c3e937481f9b58ea..97b342de90b537537bf7b2b4256d7de3f14290d0 100644 (file)
@@ -226,7 +226,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                         << "{" << std::endl
                         << "\t" << "static ObjectFactory GetFactory(void)" << std::endl
                         << "\t" << "{" << std::endl
-                        << "\t\t" << "return NULL;" << std::endl
+                        << "\t\t" << "return nullptr;" << std::endl
                         << "\t" << "}" << std::endl
                         << "};" << std::endl << std::endl;
        }
@@ -374,7 +374,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                        if (field.Type.IsName)
                                nameref = "\"" + field.Type.TypeName + "\"";
                        else
-                               nameref = "NULL";
+                               nameref = "nullptr";
 
                        m_Impl << "\t\t" << "case " << num << ":" << std::endl
                                 << "\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << field.Name << "\", \"" << (field.NavigationName.empty() ? field.Name : field.NavigationName) << "\", "  << nameref << ", " << field.Attributes << ", " << field.Type.ArrayRank << ");" << std::endl;
@@ -1411,7 +1411,7 @@ std::string ClassCompiler::BaseName(const std::string& path)
        char *dir = strdup(path.c_str());
        std::string result;
 
-       if (dir == NULL)
+       if (!dir)
                throw std::bad_alloc();
 
 #ifndef _WIN32