summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2017-03-28 10:58:58 +0000
committerHaavard <havardpe@yahoo-inc.com>2017-03-28 10:58:58 +0000
commitb8c90739689e1af49b6cea139798cc0914d6cd55 (patch)
tree967d965176c91f20e4af3285b313c7ac3c9428fd /configd
parentc047fe709edae2694a988602f94cde144471c827 (diff)
NULL -> nullptr
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/config-handler.cpp28
-rw-r--r--configd/src/apps/sentinel/line-splitter.cpp4
-rw-r--r--configd/src/apps/sentinel/metrics.cpp4
-rw-r--r--configd/src/apps/sentinel/sentinel.cpp8
-rw-r--r--configd/src/apps/sentinel/service.cpp4
-rw-r--r--configd/src/apps/su/main.cpp4
6 files changed, 26 insertions, 26 deletions
diff --git a/configd/src/apps/sentinel/config-handler.cpp b/configd/src/apps/sentinel/config-handler.cpp
index 9ce4926357f..a801e405fde 100644
--- a/configd/src/apps/sentinel/config-handler.cpp
+++ b/configd/src/apps/sentinel/config-handler.cpp
@@ -50,7 +50,7 @@ ConfigHandler::configure_port(int port)
port = 19098;
const char *portString = getenv("VESPA_SENTINEL_PORT");
if (portString) {
- port = strtoul(portString, NULL, 10);
+ port = strtoul(portString, nullptr, 10);
}
}
if (port <= 0 || port > 65535) {
@@ -73,7 +73,7 @@ ConfigHandler::ConfigHandler()
_commandSocket(listen(0)),
_startMetrics()
{
- _startMetrics.startedTime = time(NULL);
+ _startMetrics.startedTime = time(nullptr);
}
ConfigHandler::~ConfigHandler()
@@ -113,12 +113,12 @@ ConfigHandler::terminate()
// of them.
terminateServices(true);
struct timeval endTime;
- gettimeofday(&endTime, NULL);
+ gettimeofday(&endTime, nullptr);
endTime.tv_sec += 58;
struct timeval tv = {0, 0};
while (tv.tv_sec >= 0 && doWork()) {
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
tv.tv_sec = endTime.tv_sec - tv.tv_sec;
tv.tv_usec = endTime.tv_usec - tv.tv_usec;
@@ -142,7 +142,7 @@ ConfigHandler::terminate()
// Any child exiting will send SIGCHLD and break this select so
// we handle the children exiting even quicker..
- select(0, NULL, NULL, NULL, &tv);
+ select(0, nullptr, nullptr, nullptr, &tv);
}
for (int retry = 0; retry < 10 && doWork(); ++retry) {
LOG(warning, "some services refuse to terminate cleanly, sending KILL");
@@ -223,7 +223,7 @@ ConfigHandler::handleChildDeaths()
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
// A child process has exited. find it.
Service *service = serviceByPid(pid);
- if (service != NULL) {
+ if (service != nullptr) {
LOG(debug, "pid %d finished, Service:%s", (int)pid,
service->name().c_str());
service->youExited(status);
@@ -342,7 +342,7 @@ ConfigHandler::serviceByPid(pid_t pid)
return service;
}
}
- return NULL;
+ return nullptr;
}
Service *
@@ -352,7 +352,7 @@ ConfigHandler::serviceByName(const vespalib::string & name)
if (found != _services.end()) {
return found->second.get();
}
- return NULL;
+ return nullptr;
}
@@ -420,7 +420,7 @@ ConfigHandler::updateMetrics()
_startMetrics.currentlyRunningServices);
_stateApi.myMetrics.setMetrics(snapshot.asString());
- vespalib::SimpleMetricSnapshot totals(_startMetrics.startedTime, time(NULL));
+ vespalib::SimpleMetricSnapshot totals(_startMetrics.startedTime, time(nullptr));
totals.addCount("sentinel.restarts", "how many times sentinel restarted a service",
_startMetrics.totalRestartsCounter);
totals.addGauge("sentinel.running", "how many services the sentinel has running currently",
@@ -488,7 +488,7 @@ void
ConfigHandler::doStart(CommandConnection *c, char *args)
{
Service *service = serviceByName(args);
- if (service == NULL) {
+ if (service == nullptr) {
c->printf("Cannot find any service named '%s'\n", args);
return;
}
@@ -514,7 +514,7 @@ void
ConfigHandler::doRestart(CommandConnection *c, char *args, bool force)
{
Service *service = serviceByName(args);
- if (service == NULL) {
+ if (service == nullptr) {
c->printf("Cannot find any service named '%s'\n", args);
return;
}
@@ -551,7 +551,7 @@ void
ConfigHandler::doStop(CommandConnection *c, char *args, bool force)
{
Service *service = serviceByName(args);
- if (service == NULL) {
+ if (service == nullptr) {
c->printf("Cannot find any service named '%s'\n", args);
return;
}
@@ -575,7 +575,7 @@ void
ConfigHandler::doAuto(CommandConnection *c, char *args)
{
Service *service = serviceByName(args);
- if (service == NULL) {
+ if (service == nullptr) {
c->printf("Cannot find any service named '%s'\n", args);
return;
}
@@ -601,7 +601,7 @@ void
ConfigHandler::doManual(CommandConnection *c, char *args)
{
Service *service = serviceByName(args);
- if (service == NULL) {
+ if (service == nullptr) {
c->printf("Cannot find any service named '%s'\n", args);
return;
}
diff --git a/configd/src/apps/sentinel/line-splitter.cpp b/configd/src/apps/sentinel/line-splitter.cpp
index ec1fe41e766..61523db10b4 100644
--- a/configd/src/apps/sentinel/line-splitter.cpp
+++ b/configd/src/apps/sentinel/line-splitter.cpp
@@ -37,7 +37,7 @@ LineSplitter::resize()
{
_size = _size * 2;
_buffer = static_cast<char *>(realloc(_buffer, _size));
- return (_buffer != NULL);
+ return (_buffer != nullptr);
}
@@ -105,7 +105,7 @@ LineSplitter::getLine()
}
}
} while (!_eof && fill());
- return NULL;
+ return nullptr;
}
} // end namespace config::sentinel
diff --git a/configd/src/apps/sentinel/metrics.cpp b/configd/src/apps/sentinel/metrics.cpp
index 3a7d2ddb883..7f45b01d3de 100644
--- a/configd/src/apps/sentinel/metrics.cpp
+++ b/configd/src/apps/sentinel/metrics.cpp
@@ -14,7 +14,7 @@ StartMetrics::StartMetrics()
snapshotStart(0),
snapshotEnd(0)
{
- snapshotEnd = time(NULL);
+ snapshotEnd = time(nullptr);
lastLoggedTime = snapshotEnd - 55;
}
@@ -39,7 +39,7 @@ StartMetrics::reset(unsigned long curTime)
void
StartMetrics::maybeLog()
{
- uint32_t curTime = time(NULL);
+ uint32_t curTime = time(nullptr);
if (curTime > lastLoggedTime + 59) {
output();
reset(curTime);
diff --git a/configd/src/apps/sentinel/sentinel.cpp b/configd/src/apps/sentinel/sentinel.cpp
index c9185bcf01f..1f450185072 100644
--- a/configd/src/apps/sentinel/sentinel.cpp
+++ b/configd/src/apps/sentinel/sentinel.cpp
@@ -77,7 +77,7 @@ main(int argc, char **argv)
}
struct timeval lastTv;
- gettimeofday(&lastTv, NULL);
+ gettimeofday(&lastTv, nullptr);
while (!stop) {
try {
pendingWait = 0;
@@ -97,12 +97,12 @@ main(int argc, char **argv)
tv.tv_usec = 0;
if (!pendingWait) {
- select(maxNum, &fds, NULL, NULL, &tv);
+ select(maxNum, &fds, nullptr, nullptr, &tv);
}
}
struct timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
double delta = tv.tv_sec - lastTv.tv_sec
+ 1e-6 * tv.tv_usec - lastTv.tv_usec;
if (delta < 0.01) {
@@ -140,6 +140,6 @@ sigPermanent(int sig, void(*handler)(int))
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; // no SA_RESTART!
sa.sa_handler = handler;
- return sigaction(sig, &sa, NULL);
+ return sigaction(sig, &sa, nullptr);
}
diff --git a/configd/src/apps/sentinel/service.cpp b/configd/src/apps/sentinel/service.cpp
index 49944043259..dc62d687007 100644
--- a/configd/src/apps/sentinel/service.cpp
+++ b/configd/src/apps/sentinel/service.cpp
@@ -161,7 +161,7 @@ Service::start()
return -1;
}
- fflush(NULL);
+ fflush(nullptr);
_pid = fork();
if (_pid == -1) {
LOG(error, "%s: Attempted to start, but fork() failed: %s", name().c_str(),
@@ -342,7 +342,7 @@ Service::runChild(int pipes[2])
}
fcntl(0, F_SETFD, 0); // Don't close on exec
- execl("/bin/sh", "/bin/sh", "-c", _config->command.c_str(), NULL);
+ execl("/bin/sh", "/bin/sh", "-c", _config->command.c_str(), nullptr);
char buf[200];
snprintf(buf, sizeof buf, "exec error: %s for /bin/sh -c '%s'",
diff --git a/configd/src/apps/su/main.cpp b/configd/src/apps/su/main.cpp
index 4cce0b5ead0..e6252e483cb 100644
--- a/configd/src/apps/su/main.cpp
+++ b/configd/src/apps/su/main.cpp
@@ -17,11 +17,11 @@ int main(int argc, char** argv)
exit(1);
}
const char *username = getenv("VESPA_USER");
- if (username == NULL) {
+ if (username == nullptr) {
username = "yahoo";
}
struct passwd *p = getpwnam(username);
- if (p == NULL) {
+ if (p == nullptr) {
fprintf(stderr, "FATAL error: user '%s' missing in passwd file\n", username);
exit(1);
}