Replace a few more NULLs with nullptr

This commit is contained in:
Gunnar Beutner 2017-12-14 15:37:20 +01:00
parent 1bf12c9685
commit 1ad83886ac
66 changed files with 257 additions and 261 deletions

View 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);

View 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;
}

View 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;

View 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

View 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;

View 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()

View 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 {

View 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;

View 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 */

View 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 */

View 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.

View 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);

View 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."));
}

View 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)
}

View 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);

View 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);

View 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);

View 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);

View 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;

View 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);

View File

@ -82,7 +82,7 @@ struct SocketEventDescriptor
Object *LifesupportObject;
SocketEventDescriptor(void)
: Events(POLLIN), EventInterface(NULL), LifesupportObject(NULL)
: Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr)
{ }
};

View 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);

View 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.

View 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)

View 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) {

View 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);

View 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.");
}

View 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);

View 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 << "\"";

View 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;
}

View 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";
}

View 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());
}
/**

View 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:

View 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;

View 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();

View 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";

View 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));

View 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"

View 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());

View 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;
}

View 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;

View 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;

View 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;
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() : 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;
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)) {

View 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);

View 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);

View 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);

View 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);
}

View 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();

View 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);

View 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>())

View 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;
}

View 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;

View 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;

View 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;

View 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";

View 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);

View 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;

View 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 {

View 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)

View 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);

View 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");

View 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,

View 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);
}

View 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);
}

View 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()));

View 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