summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 14:34:52 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-08-18 14:34:52 +0200
commit5f36b7efbf8a6a22c3371b34451e0975aea57b30 (patch)
tree1cd0987044be97c1143ad6a17d95ae63d10dcc29 /fastos
parentb6ccc1da256bb75c2ef6f2de1585bf767c030470 (diff)
NULL -> nullptr
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/backtracetest.cpp2
-rw-r--r--fastos/src/tests/coretest.cpp8
-rw-r--r--fastos/src/tests/coretest2.cpp8
-rw-r--r--fastos/src/tests/filetest.cpp4
-rw-r--r--fastos/src/tests/job.h18
-rw-r--r--fastos/src/tests/performancetest.cpp4
-rw-r--r--fastos/src/tests/prefetchtest.cpp4
-rw-r--r--fastos/src/tests/processtest.cpp28
-rw-r--r--fastos/src/tests/sockettest.cpp40
-rw-r--r--fastos/src/tests/thread_bounce_test.cpp2
-rw-r--r--fastos/src/tests/thread_joinwait_test.cpp6
-rw-r--r--fastos/src/tests/thread_mutex_test.cpp14
-rw-r--r--fastos/src/tests/thread_sleep_test.cpp6
-rw-r--r--fastos/src/tests/thread_stats_test.cpp2
-rw-r--r--fastos/src/tests/thread_test_base.hpp8
-rw-r--r--fastos/src/tests/threadtest.cpp42
-rw-r--r--fastos/src/tests/timetest.cpp2
-rw-r--r--fastos/src/tests/typetest.cpp2
-rw-r--r--fastos/src/tests/usecputest.cpp2
-rw-r--r--fastos/src/vespa/fastos/app.cpp30
-rw-r--r--fastos/src/vespa/fastos/dynamiclibrary.h4
-rw-r--r--fastos/src/vespa/fastos/file.cpp22
-rw-r--r--fastos/src/vespa/fastos/file.h24
-rw-r--r--fastos/src/vespa/fastos/linux_file.cpp8
-rw-r--r--fastos/src/vespa/fastos/linux_file.h2
-rw-r--r--fastos/src/vespa/fastos/process.cpp6
-rw-r--r--fastos/src/vespa/fastos/process.h14
-rw-r--r--fastos/src/vespa/fastos/serversocket.h16
-rw-r--r--fastos/src/vespa/fastos/socket.cpp28
-rw-r--r--fastos/src/vespa/fastos/socket.h4
-rw-r--r--fastos/src/vespa/fastos/socketevent.cpp32
-rw-r--r--fastos/src/vespa/fastos/socketevent.h6
-rw-r--r--fastos/src/vespa/fastos/thread.cpp44
-rw-r--r--fastos/src/vespa/fastos/thread.h16
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp2
-rw-r--r--fastos/src/vespa/fastos/unix_app.cpp24
-rw-r--r--fastos/src/vespa/fastos/unix_cond.cpp4
-rw-r--r--fastos/src/vespa/fastos/unix_dynamiclibrary.cpp14
-rw-r--r--fastos/src/vespa/fastos/unix_dynamiclibrary.h6
-rw-r--r--fastos/src/vespa/fastos/unix_file.h12
-rw-r--r--fastos/src/vespa/fastos/unix_ipc.cpp38
-rw-r--r--fastos/src/vespa/fastos/unix_mutex.cpp2
-rw-r--r--fastos/src/vespa/fastos/unix_process.cpp120
-rw-r--r--fastos/src/vespa/fastos/unix_process.h18
-rw-r--r--fastos/src/vespa/fastos/unix_socket.cpp4
-rw-r--r--fastos/src/vespa/fastos/unix_thread.cpp8
-rw-r--r--fastos/src/vespa/fastos/unix_time.cpp2
47 files changed, 356 insertions, 356 deletions
diff --git a/fastos/src/tests/backtracetest.cpp b/fastos/src/tests/backtracetest.cpp
index df0887c6b63..6c68765c1ee 100644
--- a/fastos/src/tests/backtracetest.cpp
+++ b/fastos/src/tests/backtracetest.cpp
@@ -116,7 +116,7 @@ int main (int argc, char **argv)
{
BackTraceTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/coretest.cpp b/fastos/src/tests/coretest.cpp
index 2337c392730..a53eaf9d2a4 100644
--- a/fastos/src/tests/coretest.cpp
+++ b/fastos/src/tests/coretest.cpp
@@ -8,7 +8,7 @@ bomb(void)
{
char *p;
- p = NULL;
+ p = nullptr;
*p = 4;
}
@@ -29,8 +29,8 @@ bombMain(void)
FastS_Bomber bomber;
FastOS_ThreadInterface *thread;
- thread = pool->NewThread(&bomber, NULL);
- if (thread != NULL)
+ thread = pool->NewThread(&bomber, nullptr);
+ if (thread != nullptr)
thread->Join();
pool->Close();
@@ -60,7 +60,7 @@ int
main(int argc, char **argv)
{
FastS_CoreTestApp app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
if (argc == 1)
return app.Entry(argc, argv);
else
diff --git a/fastos/src/tests/coretest2.cpp b/fastos/src/tests/coretest2.cpp
index a8c416f2de4..e11d334e65e 100644
--- a/fastos/src/tests/coretest2.cpp
+++ b/fastos/src/tests/coretest2.cpp
@@ -8,7 +8,7 @@ bomb(void)
{
char *p;
- p = NULL;
+ p = nullptr;
*p = 4;
}
@@ -16,7 +16,7 @@ void *BomberRun(void *arg)
{
(void) arg;
bomb();
- return NULL;
+ return nullptr;
};
static int
@@ -25,8 +25,8 @@ bombMain(void)
pthread_t thread;
void *ret;
- (void) pthread_create(&thread, NULL, BomberRun, NULL);
- ret = NULL;
+ (void) pthread_create(&thread, nullptr, BomberRun, nullptr);
+ ret = nullptr;
(void) pthread_join(thread, &ret);
return (0);
}
diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp
index ad411364c0c..e063ccbc89d 100644
--- a/fastos/src/tests/filetest.cpp
+++ b/fastos/src/tests/filetest.cpp
@@ -278,7 +278,7 @@ public:
Progress(rc, "Opening file 'generated/memorymaptest' read-only");
if (rc) {
bool mmapEnabled;
- char *mmapBuffer = NULL;
+ char *mmapBuffer = nullptr;
mmapEnabled = file.IsMemoryMapped();
mmapBuffer = static_cast<char *>(file.MemoryMapPtr(0));
@@ -832,6 +832,6 @@ int main (int argc, char **argv)
{
FileTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/job.h b/fastos/src/tests/job.h
index 5199169409d..a5b84fa0f9c 100644
--- a/fastos/src/tests/job.h
+++ b/fastos/src/tests/job.h
@@ -42,17 +42,17 @@ public:
Job()
: code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
+ message(nullptr),
+ mutex(nullptr),
+ condition(nullptr),
+ boolcondition(nullptr),
+ otherThread(nullptr),
+ ownThread(nullptr),
+ timebuf(nullptr),
average(0.0),
result(-1),
_threadId(),
- otherjob(NULL),
+ otherjob(nullptr),
bouncewakeupcnt(0),
bouncewakeup(false)
{
@@ -60,7 +60,7 @@ public:
~Job()
{
- if(message != NULL)
+ if(message != nullptr)
free(message);
}
};
diff --git a/fastos/src/tests/performancetest.cpp b/fastos/src/tests/performancetest.cpp
index 1465ee3d223..55174fcc4e3 100644
--- a/fastos/src/tests/performancetest.cpp
+++ b/fastos/src/tests/performancetest.cpp
@@ -12,14 +12,14 @@ int main (int argc, char **argv)
void (*test)(char *buffer) = PerformanceTest;
- test(NULL);
+ test(nullptr);
return 0;
}
void PerformanceTest (char *buffer)
{
// Cause exception
- *static_cast<char *>(NULL) = 'e';
+ *static_cast<char *>(nullptr) = 'e';
#if 1
FastOS_File file("test.txt");
diff --git a/fastos/src/tests/prefetchtest.cpp b/fastos/src/tests/prefetchtest.cpp
index 26ab67251b3..38d3eed837c 100644
--- a/fastos/src/tests/prefetchtest.cpp
+++ b/fastos/src/tests/prefetchtest.cpp
@@ -35,7 +35,7 @@ public:
size = 32;
size *= 1024*1024/sizeof(*a);
- if ((a = static_cast<int *>(calloc(size, sizeof(*a)))) != NULL)
+ if ((a = static_cast<int *>(calloc(size, sizeof(*a)))) != nullptr)
{
// Standard loop
start.SetNow();
@@ -155,6 +155,6 @@ public:
int main (int argc, char **argv)
{
PrefetchTestApp app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index 5036676a504..11e1307027d 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -47,7 +47,7 @@ public:
void OnReceiveData (const void *data, size_t length) override
{
_receivedBytes += length;
- if(data != NULL)
+ if(data != nullptr)
{
#if 0
printf("[%s] received %u bytes of data:\n%s\n",
@@ -62,7 +62,7 @@ public:
int MyListener::_allocCount = 0;
int MyListener::_successCount = 0;
int MyListener::_failCount = 0;
-FastOS_Mutex *MyListener::_counterLock = NULL;
+FastOS_Mutex *MyListener::_counterLock = nullptr;
class ThreadRunJob : public FastOS_Runnable
@@ -128,7 +128,7 @@ public:
ProcessTest ()
: _gotMessage(false),
_receivedMessages(0),
- _counterLock(NULL),
+ _counterLock(nullptr),
_isChild(true)
{
}
@@ -154,7 +154,7 @@ public:
_gotMessage = true;
// We only have the counter lock if we are the parent process.
- if(_counterLock != NULL)
+ if(_counterLock != nullptr)
{
_counterLock->Lock();
_receivedMessages++;
@@ -197,7 +197,7 @@ public:
if(i == 5)
{
// Make sort quit
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
FastOS_Thread::Sleep(1000);
@@ -257,7 +257,7 @@ public:
if(!waitKill && stdinPre)
{
xproc->WriteStdin(str, strlen(str));
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
if(doKill)
@@ -269,7 +269,7 @@ public:
if(!waitKill && !stdinPre)
{
xproc->WriteStdin(str, strlen(str));
- xproc->WriteStdin(NULL, 0);
+ xproc->WriteStdin(nullptr, 0);
}
}
else
@@ -277,7 +277,7 @@ public:
Progress(false, "Process.CreateWithShell failure %d",
GetLastError());
delete xproc;
- xproc = NULL;
+ xproc = nullptr;
}
procs[j] = xproc;
}
@@ -285,7 +285,7 @@ public:
for(j=0; j<numEachTime; j++)
{
FastOS_ProcessInterface *xproc = procs[j];
- if(xproc == NULL)
+ if(xproc == nullptr)
continue;
int timeOut = -1;
@@ -347,7 +347,7 @@ public:
}
delete MyListener::_counterLock;
- MyListener::_counterLock = NULL;
+ MyListener::_counterLock = nullptr;
PrintSeparator();
}
@@ -412,7 +412,7 @@ public:
"Received %d messages", _receivedMessages);
delete _counterLock;
- _counterLock = NULL;
+ _counterLock = nullptr;
PrintSeparator();
}
@@ -427,8 +427,8 @@ public:
void *inheritData = FastOS_Process::PrefopenNoInherit();
FILE *fp = fopen(filename, "w");
int numProc = FastOS_Process::PostfopenNoInherit(inheritData);
- Progress(fp != NULL, "Open file");
- if(fp != NULL)
+ Progress(fp != nullptr, "Open file");
+ if(fp != nullptr)
{
Progress(numProc > 0, "Number of files processed = %d\n",
numProc);
@@ -469,6 +469,6 @@ public:
int main (int argc, char **argv)
{
ProcessTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/sockettest.cpp b/fastos/src/tests/sockettest.cpp
index 3a9c9dab565..29dcb1b089e 100644
--- a/fastos/src/tests/sockettest.cpp
+++ b/fastos/src/tests/sockettest.cpp
@@ -150,7 +150,7 @@ public:
BaseTest *_app;
MazeServer(BaseTest *app)
- : _serverSocket(NULL),
+ : _serverSocket(nullptr),
_app(app)
{
}
@@ -185,7 +185,7 @@ public:
{
int serverPort = 18334;
_serverSocket = new FastOS_ServerSocket(serverPort);
- _app->Progress(_serverSocket != NULL,
+ _app->Progress(_serverSocket != nullptr,
"Creating ServerSocket instance");
_app->Progress(_serverSocket->SetSoBlocking(false),
@@ -224,12 +224,12 @@ public:
{
FastOS_Socket *connSocket = _serverSocket->AcceptPlain();
- _app->Progress(connSocket != NULL, "Accepting socket (%p)",
+ _app->Progress(connSocket != nullptr, "Accepting socket (%p)",
connSocket);
for(i=0; i<MAX_CONNECTIONS; i++)
{
- if(connections[i] == NULL)
+ if(connections[i] == nullptr)
{
// Found a free positions for the new connection
break;
@@ -237,11 +237,11 @@ public:
}
if(i < MAX_CONNECTIONS)
{
- if(connSocket != NULL)
+ if(connSocket != nullptr)
{
connections[i] = new MazeServerConnection(this, connSocket);
- assert(connections[i] != NULL);
+ assert(connections[i] != nullptr);
connSocket->SetSocketEvent(&socketEvent);
connSocket->EnableReadEvent(true);
@@ -256,7 +256,7 @@ public:
for(i=0; i<MAX_CONNECTIONS; i++)
{
- if((conn = connections[i]) != NULL)
+ if((conn = connections[i]) != nullptr)
{
if(socketEvent.QueryReadEvent(conn->_socket))
{
@@ -273,7 +273,7 @@ public:
if(conn->_shouldFree)
{
delete(conn);
- connections[i] = NULL;
+ connections[i] = nullptr;
}
}
}
@@ -438,7 +438,7 @@ public:
#if 0
void PrintOut()
{
- if(_server != NULL)
+ if(_server != nullptr)
{
for(int y=0; y<MAZE_HEIGHT; y++)
{
@@ -460,7 +460,7 @@ public:
#if 0
void MarkPath (int x, int y, int direction, int length)
{
- if(_server != NULL)
+ if(_server != nullptr)
{
int dx, dy;
SetDirection(dx, dy, direction);
@@ -657,9 +657,9 @@ public:
std::string strictBindHost("localhost");
FastOS_ServerSocket *serverSocket =
- new FastOS_ServerSocket(18333, 5, NULL, strictBindHost.c_str());
+ new FastOS_ServerSocket(18333, 5, nullptr, strictBindHost.c_str());
- Progress(serverSocket != NULL, "Allocating serversocket instance");
+ Progress(serverSocket != nullptr, "Allocating serversocket instance");
rc = serverSocket->GetValidAddressFlag();
Progress(rc, "Address Valid Flag check");
@@ -684,7 +684,7 @@ public:
TestHeader("HTTP Client Test");
FastOS_Socket *sock = new FastOS_Socket();
- Progress(sock != NULL, "Allocating socket instance");
+ Progress(sock != nullptr, "Allocating socket instance");
char hostAddress[] = "www.vg.no";
@@ -714,7 +714,7 @@ public:
int readLength = strlen(expectedResult);
char *readBuffer = new char[readLength+1];
- if(readBuffer != NULL)
+ if(readBuffer != nullptr)
{
memset(readBuffer, 0, readLength+1);
@@ -756,7 +756,7 @@ public:
TestHeader("Client/Server Test");
FastOS_ServerSocket *serverSocket = new FastOS_ServerSocket(18333);
- Progress(serverSocket != NULL, "Allocating serversocket instance");
+ Progress(serverSocket != nullptr, "Allocating serversocket instance");
Progress(rc = serverSocket->Listen(), "Bind socket to port %d. Listen for incoming connections.", 18333);
assert(rc);
@@ -775,7 +775,7 @@ public:
bool rc;
FastOS_Socket *sock = new FastOS_Socket();
- Progress(rc = (sock != NULL), "Allocating socket instance");
+ Progress(rc = (sock != nullptr), "Allocating socket instance");
if(rc)
{
sock->SetAddress(8001, serverAddress);
@@ -786,7 +786,7 @@ public:
{
MazeClient *client = new MazeClient(this, sock);
- Progress(rc = (client != NULL), "Allocating MazeClient instance");
+ Progress(rc = (client != nullptr), "Allocating MazeClient instance");
if(rc)
{
client->Run();
@@ -818,7 +818,7 @@ public:
#if DO_MAZE_SERVER
DoMazeServer();
#else
- char *mazeServerAddress = NULL;
+ char *mazeServerAddress = nullptr;
if(_argc == 3)
{
@@ -832,7 +832,7 @@ public:
ClientServerTest();
StrictBindTest();
- if(mazeServerAddress != NULL)
+ if(mazeServerAddress != nullptr)
MazeTest(mazeServerAddress);
#endif
@@ -850,6 +850,6 @@ int main (int argc, char **argv)
{
SocketTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_bounce_test.cpp b/fastos/src/tests/thread_bounce_test.cpp
index 729c16fab5f..bf94f3e1aab 100644
--- a/fastos/src/tests/thread_bounce_test.cpp
+++ b/fastos/src/tests/thread_bounce_test.cpp
@@ -89,6 +89,6 @@ int Thread_Bounce_Test::Main ()
int main (int argc, char **argv)
{
Thread_Bounce_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_joinwait_test.cpp b/fastos/src/tests/thread_joinwait_test.cpp
index 98e0a1ac467..05ab1627334 100644
--- a/fastos/src/tests/thread_joinwait_test.cpp
+++ b/fastos/src/tests/thread_joinwait_test.cpp
@@ -38,7 +38,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
jobs[i].ownThread = pool.NewThread(this,
static_cast<void *>(&jobs[i]));
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
Progress(rc, "Creating Thread %d", i+1);
if(!rc)
@@ -56,7 +56,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
static_cast<void *>
(&jobs[lastThreadNum]));
- rc = (lastThread != NULL);
+ rc = (lastThread != nullptr);
Progress(rc, "Creating last thread");
if(rc)
@@ -115,6 +115,6 @@ int Thread_JoinWait_Test::Main ()
int main (int argc, char **argv)
{
Thread_JoinWait_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_mutex_test.cpp b/fastos/src/tests/thread_mutex_test.cpp
index 602d89c0b05..b8ac575038b 100644
--- a/fastos/src/tests/thread_mutex_test.cpp
+++ b/fastos/src/tests/thread_mutex_test.cpp
@@ -21,11 +21,11 @@ class Thread_Mutex_Test : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[MUTEX_TEST_THREADS];
- FastOS_Mutex *myMutex=NULL;
+ FastOS_Mutex *myMutex=nullptr;
if(usingMutex)
myMutex = new FastOS_Mutex();
@@ -40,7 +40,7 @@ class Thread_Mutex_Test : public ThreadTestBase
for(i=0; i<MUTEX_TEST_THREADS; i++)
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread with%s mutex", (usingMutex ? "" : "out"));
};
@@ -99,7 +99,7 @@ class Thread_Mutex_Test : public ThreadTestBase
}
}
- if(myMutex != NULL)
+ if(myMutex != nullptr)
delete(myMutex);
Progress(true, "Closing threadpool...");
@@ -125,9 +125,9 @@ class Thread_Mutex_Test : public ThreadTestBase
job.ownThread = pool.NewThread(this,
static_cast<void *>(&job));
- Progress(job.ownThread !=NULL, "Creating thread");
+ Progress(job.ownThread !=nullptr, "Creating thread");
- if(job.ownThread != NULL)
+ if(job.ownThread != nullptr)
{
bool lockrc;
@@ -188,6 +188,6 @@ int Thread_Mutex_Test::Main ()
int main (int argc, char **argv)
{
Thread_Mutex_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_sleep_test.cpp b/fastos/src/tests/thread_sleep_test.cpp
index 914438cdd83..7fd3412b7c3 100644
--- a/fastos/src/tests/thread_sleep_test.cpp
+++ b/fastos/src/tests/thread_sleep_test.cpp
@@ -14,9 +14,9 @@ class Thread_Sleep_Test : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
- bool rc = (NULL != pool->NewThread(this, NULL));
+ bool rc = (nullptr != pool->NewThread(this, nullptr));
Progress(rc, "Creating Thread");
Progress(true, "Sleeping 3 seconds");
@@ -47,6 +47,6 @@ int Thread_Sleep_Test::Main ()
int main (int argc, char **argv)
{
Thread_Sleep_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_stats_test.cpp b/fastos/src/tests/thread_stats_test.cpp
index 3ac4b0a52d6..3633c12bcaa 100644
--- a/fastos/src/tests/thread_stats_test.cpp
+++ b/fastos/src/tests/thread_stats_test.cpp
@@ -131,6 +131,6 @@ int Thread_Stats_Test::Main ()
int main (int argc, char **argv)
{
Thread_Stats_Test app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/thread_test_base.hpp b/fastos/src/tests/thread_test_base.hpp
index 3cd16065726..5305b132d3c 100644
--- a/fastos/src/tests/thread_test_base.hpp
+++ b/fastos/src/tests/thread_test_base.hpp
@@ -57,7 +57,7 @@ public:
void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
{
- if(arg == NULL)
+ if(arg == nullptr)
return;
Job *job = static_cast<Job *>(arg);
@@ -93,7 +93,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
{
int result;
- if(job->mutex != NULL)
+ if(job->mutex != nullptr)
job->mutex->Lock();
result = static_cast<int>(number);
@@ -107,7 +107,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
FastOS_Thread::Sleep(1000);
}
- if(job->mutex != NULL)
+ if(job->mutex != nullptr)
job->mutex->Unlock();
job->result = result; // This marks the end of the thread
@@ -135,7 +135,7 @@ void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg)
if(job->mutex)
job->mutex->Lock();
- if(job->otherThread != NULL)
+ if(job->otherThread != nullptr)
job->otherThread->Join();
if(job->mutex)
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 57e60d9413b..81ea234fb97 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -54,7 +54,7 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[MAX_THREADS];
@@ -70,13 +70,13 @@ class ThreadTest : public ThreadTestBase
{
if(i==MAX_THREADS)
{
- bool rc = (NULL == pool->NewThread(this,
+ bool rc = (nullptr == pool->NewThread(this,
static_cast<void *>(&jobs[0])));
Progress(rc, "Creating too many threads should fail.");
}
else
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread");
}
@@ -110,7 +110,7 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, HOW_MAX_THREADS);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
int i;
Job jobs[HOW_MAX_THREADS];
@@ -126,13 +126,13 @@ class ThreadTest : public ThreadTestBase
{
if(i==HOW_MAX_THREADS)
{
- bool rc = (NULL == pool->NewThread(this,
+ bool rc = (nullptr == pool->NewThread(this,
static_cast<void *>(&jobs[0])));
Progress(rc, "Creating too many threads should fail.");
}
else
{
- bool rc = (NULL != pool->NewThread(this,
+ bool rc = (nullptr != pool->NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread");
}
@@ -164,14 +164,14 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024);
- if(Progress(pool != NULL, "Allocating ThreadPool"))
+ if(Progress(pool != nullptr, "Allocating ThreadPool"))
{
Job job;
job.code = NOP;
job.result = -1;
- bool rc = (NULL != pool->NewThread(this, &job));
+ bool rc = (nullptr != pool->NewThread(this, &job));
Progress(rc, "Creating Thread");
WaitForThreadsToFinish(&job, 1);
@@ -201,8 +201,8 @@ class ThreadTest : public ThreadTestBase
FastOS_ThreadPool *pool = new FastOS_ThreadPool(128 * 1024);
if (!silent)
- Progress(pool != NULL, "Allocating ThreadPool");
- if (pool != NULL) {
+ Progress(pool != nullptr, "Allocating ThreadPool");
+ if (pool != nullptr) {
Job *jobs = new Job[count];
threadsok = 0;
@@ -210,23 +210,23 @@ class ThreadTest : public ThreadTestBase
for (i = 0; i < count; i++) {
jobs[i].code = SILENTNOP;
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
if (rc)
threadsok++;
}
for (j = 0; j < outercount; j++) {
for (i = 0; i < count; i++) {
- if (jobs[i].ownThread != NULL)
+ if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
jobs[i].ownThread = pool->NewThread(this, &jobs[i]);
- rc = (jobs[i].ownThread != NULL);
+ rc = (jobs[i].ownThread != nullptr);
if (rc)
threadsok++;
}
}
for (i = 0; i < count; i++) {
- if (jobs[i].ownThread != NULL)
+ if (jobs[i].ownThread != nullptr)
jobs[i].ownThread->Join();
}
endtime.SetNow();
@@ -286,7 +286,7 @@ class ThreadTest : public ThreadTestBase
{
jobs[i].code = INCREASE_NUMBER;
- bool rc = (NULL != pool.NewThread(this,
+ bool rc = (nullptr != pool.NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread %d", i+1);
}
@@ -311,7 +311,7 @@ class ThreadTest : public ThreadTestBase
{
jobs[i].code = WAIT_FOR_BREAK_FLAG;
- bool rc = (NULL != pool.NewThread(this,
+ bool rc = (nullptr != pool.NewThread(this,
static_cast<void *>(&jobs[i])));
Progress(rc, "Creating Thread %d", i+1);
}
@@ -333,7 +333,7 @@ class ThreadTest : public ThreadTestBase
jobs[i].ownThread = pool->NewThread(this,
static_cast<void *>(&jobs[i]));
- bool rc=(jobs[i].ownThread != NULL);
+ bool rc=(jobs[i].ownThread != nullptr);
Progress(rc, "CreatingThread %d", i+1);
}
@@ -412,7 +412,7 @@ class ThreadTest : public ThreadTestBase
jobs[i].mutex = &slowStartMutex;
jobs[i].ownThread = pool.NewThread(this,
static_cast<void *>(&jobs[i]));
- bool rc=(jobs[i].ownThread != NULL);
+ bool rc=(jobs[i].ownThread != nullptr);
if(rc)
jobs[i]._threadId = jobs[i].ownThread->GetThreadId();
Progress(rc, "CreatingThread %d id:%lu", i+1,
@@ -457,9 +457,9 @@ class ThreadTest : public ThreadTestBase
job.ownThread = pool.NewThread(this,
static_cast<void *>(&job));
- Progress(job.ownThread !=NULL, "Creating thread");
+ Progress(job.ownThread !=nullptr, "Creating thread");
- if(job.ownThread != NULL)
+ if(job.ownThread != nullptr)
{
condition.Lock();
bool gotCond = condition.TimedWait(500);
@@ -597,6 +597,6 @@ int ThreadTest::Main ()
int main (int argc, char **argv)
{
ThreadTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/timetest.cpp b/fastos/src/tests/timetest.cpp
index fa9ef71ba9c..0618e28bcd0 100644
--- a/fastos/src/tests/timetest.cpp
+++ b/fastos/src/tests/timetest.cpp
@@ -290,7 +290,7 @@ int main (int argc, char **argv)
{
TimeTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp
index 87e3d76c461..51bda7e5dbc 100644
--- a/fastos/src/tests/typetest.cpp
+++ b/fastos/src/tests/typetest.cpp
@@ -51,7 +51,7 @@ public:
int main (int argc, char **argv)
{
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
TypeTest app;
return app.Entry(argc, argv);
}
diff --git a/fastos/src/tests/usecputest.cpp b/fastos/src/tests/usecputest.cpp
index 930b1fb305f..9812ed7575d 100644
--- a/fastos/src/tests/usecputest.cpp
+++ b/fastos/src/tests/usecputest.cpp
@@ -63,7 +63,7 @@ void UseSomeCpu (int i, ThreadRunJob *threadRunJob)
int main (int argc, char **argv)
{
UseCpuTest app;
- setvbuf(stdout, NULL, _IOLBF, 8192);
+ setvbuf(stdout, nullptr, _IOLBF, 8192);
return app.Entry(argc, argv);
}
diff --git a/fastos/src/vespa/fastos/app.cpp b/fastos/src/vespa/fastos/app.cpp
index 079dab55754..824d009591f 100644
--- a/fastos/src/vespa/fastos/app.cpp
+++ b/fastos/src/vespa/fastos/app.cpp
@@ -27,16 +27,16 @@ FastOS_ThreadPool *FastOS_ApplicationInterface::GetThreadPool ()
}
FastOS_ApplicationInterface::FastOS_ApplicationInterface() :
- _threadPool(NULL),
- _processList(NULL),
- _processListMutex(NULL),
+ _threadPool(nullptr),
+ _processList(nullptr),
+ _processListMutex(nullptr),
_disableLeakReporting(false),
_argc(0),
- _argv(NULL)
+ _argv(nullptr)
{
FastOS_ProcessInterface::_app = this;
char * fadvise = getenv("VESPA_FADVISE_OPTIONS");
- if (fadvise != NULL) {
+ if (fadvise != nullptr) {
int fadviseOptions(0);
if (strstr(fadvise, "SEQUENTIAL")) { fadviseOptions |= POSIX_FADV_SEQUENTIAL; }
if (strstr(fadvise, "RANDOM")) { fadviseOptions |= POSIX_FADV_RANDOM; }
@@ -63,7 +63,7 @@ bool FastOS_ApplicationInterface::Init ()
{
const char *errorMsg = FastOS_Socket::InitializeServices();
- if(errorMsg == NULL)
+ if(errorMsg == nullptr)
{
_processListMutex = new FastOS_Mutex();
_threadPool = new FastOS_ThreadPool(128 * 1024);
@@ -91,19 +91,19 @@ bool FastOS_ApplicationInterface::Init ()
void FastOS_ApplicationInterface::Cleanup ()
{
- if(_threadPool != NULL)
+ if(_threadPool != nullptr)
{
// printf("Closing threadpool...\n");
_threadPool->Close();
// printf("Deleting threadpool...\n");
delete _threadPool;
- _threadPool = NULL;
+ _threadPool = nullptr;
}
- if(_processListMutex != NULL)
+ if(_processListMutex != nullptr)
{
delete _processListMutex;
- _processListMutex = NULL;
+ _processListMutex = nullptr;
}
FastOS_Socket::CleanupServices();
@@ -139,10 +139,10 @@ OnReceivedIPCMessage (const void *data, size_t length)
void FastOS_ApplicationInterface::
AddChildProcess (FastOS_ProcessInterface *node)
{
- node->_prev = NULL;
+ node->_prev = nullptr;
node->_next = _processList;
- if(_processList != NULL)
+ if(_processList != nullptr)
_processList->_prev = node;
_processList = node;
@@ -159,11 +159,11 @@ RemoveChildProcess (FastOS_ProcessInterface *node)
if(node->_next)
{
node->_next->_prev = node->_prev;
- node->_next = NULL;
+ node->_next = nullptr;
}
- if(node->_prev != NULL)
- node->_prev = NULL;
+ if(node->_prev != nullptr)
+ node->_prev = nullptr;
}
bool
diff --git a/fastos/src/vespa/fastos/dynamiclibrary.h b/fastos/src/vespa/fastos/dynamiclibrary.h
index b0bf5730405..15cc28fa130 100644
--- a/fastos/src/vespa/fastos/dynamiclibrary.h
+++ b/fastos/src/vespa/fastos/dynamiclibrary.h
@@ -34,7 +34,7 @@ public:
* @param libname the name of the library to open
* @return Boolean success/failure
*/
- virtual bool Open(const char *libname = NULL) = 0;
+ virtual bool Open(const char *libname = nullptr) = 0;
/**
* Close (unload) the library.
@@ -45,7 +45,7 @@ public:
/**
* Find the address of a symbol in the library.
* @param symbol Name of symbol to find
- * @return Address of the symbol, or NULL if an error has occurred
+ * @return Address of the symbol, or nullptr if an error has occurred
*/
virtual void * GetSymbol(const char *symbol) const = 0;
diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp
index 8f164c2a522..42ca432329d 100644
--- a/fastos/src/vespa/fastos/file.cpp
+++ b/fastos/src/vespa/fastos/file.cpp
@@ -27,7 +27,7 @@ DirectIOException::DirectIOException(const char * fileName, const void * buffer,
DirectIOException::~DirectIOException() {}
-FastOS_FileInterface::FailedHandler FastOS_FileInterface::_failedHandler = NULL;
+FastOS_FileInterface::FailedHandler FastOS_FileInterface::_failedHandler = nullptr;
int FastOS_FileInterface::_defaultFAdviseOptions = POSIX_FADV_NORMAL;
static const size_t MAX_WRITE_CHUNK_SIZE = 0x4000000; // 64 MB
@@ -35,12 +35,12 @@ static const size_t MAX_WRITE_CHUNK_SIZE = 0x4000000; // 64 MB
FastOS_FileInterface::FastOS_FileInterface(const char *filename)
: _fAdviseOptions(_defaultFAdviseOptions),
_writeChunkSize(MAX_WRITE_CHUNK_SIZE),
- _filename(NULL),
+ _filename(nullptr),
_openFlags(0),
_directIOEnabled(false),
_syncWritesEnabled(false)
{
- if (filename != NULL)
+ if (filename != nullptr)
SetFileName(filename);
}
@@ -200,7 +200,7 @@ FastOS_FileInterface::MemoryMapPtr(int64_t position) const
{
// Only subclases with support for memory mapping do something here.
(void) position;
- return NULL;
+ return nullptr;
}
@@ -218,8 +218,8 @@ FastOS_FileInterface::CopyFile( const char *src, const char *dst )
FastOS_StatInfo statInfo;
bool success = false;
- if ( src != NULL &&
- dst != NULL &&
+ if ( src != nullptr &&
+ dst != nullptr &&
strcmp(src, dst) != 0 &&
FastOS_File::Stat( src, &statInfo )) {
@@ -233,7 +233,7 @@ FastOS_FileInterface::CopyFile( const char *src, const char *dst )
bufSize = static_cast<unsigned int>(bufSizeBound);
char *tmpBuf = new char[ bufSize ];
- if ( tmpBuf != NULL ) {
+ if ( tmpBuf != nullptr ) {
int64_t copied = 0;
success = true;
do {
@@ -278,7 +278,7 @@ FastOS_FileInterface::MoveFile(const char* src, const char* dst)
void
FastOS_FileInterface::EmptyDirectory( const char *dir,
- const char *keepFile /* = NULL */ )
+ const char *keepFile /* = nullptr */ )
{
FastOS_StatInfo statInfo;
if (!FastOS_File::Stat(dir, &statInfo))
@@ -288,7 +288,7 @@ FastOS_FileInterface::EmptyDirectory( const char *dir,
while (dirScan.ReadNext()) {
if (strcmp(dirScan.GetName(), ".") != 0 &&
strcmp(dirScan.GetName(), "..") != 0 &&
- (keepFile == NULL || strcmp(dirScan.GetName(), keepFile) != 0))
+ (keepFile == nullptr || strcmp(dirScan.GetName(), keepFile) != 0))
{
std::string name = dir;
name += GetPathSeparator();
@@ -347,7 +347,7 @@ FastOS_FileInterface::MakeDirIfNotPresentOrExit(const char *name)
void
FastOS_FileInterface::SetFileName(const char *filename)
{
- if (_filename != NULL) {
+ if (_filename != nullptr) {
free(_filename);
}
@@ -358,7 +358,7 @@ FastOS_FileInterface::SetFileName(const char *filename)
const char *
FastOS_FileInterface::GetFileName() const
{
- return (_filename != NULL) ? _filename : "";
+ return (_filename != nullptr) ? _filename : "";
}
diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h
index 00ba61b793f..43e10fcd120 100644
--- a/fastos/src/vespa/fastos/file.h
+++ b/fastos/src/vespa/fastos/file.h
@@ -181,7 +181,7 @@ public:
* @param keepFile a 'const char *' value. If supplied, leave files with
* this name alone.
*/
- static void EmptyDirectory( const char *dir, const char *keepFile = NULL);
+ static void EmptyDirectory( const char *dir, const char *keepFile = nullptr);
/**
* Make a directory (special compatibility version)
@@ -205,7 +205,7 @@ public:
* later using @ref SetFileName() or @ref Open().
* @param filename a filename (optional)
*/
- FastOS_FileInterface(const char *filename=NULL);
+ FastOS_FileInterface(const char *filename=nullptr);
/**
* Destructor. If the current file is open, the destructor will close
@@ -243,7 +243,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- virtual bool Open(unsigned int openFlags, const char *filename=NULL) = 0;
+ virtual bool Open(unsigned int openFlags, const char *filename=nullptr) = 0;
/**
* Open a file for read/write access. The file will be created if it does
@@ -254,7 +254,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadWrite(const char *filename=NULL);
+ bool OpenReadWrite(const char *filename=nullptr);
/**
* Open a file for read/write access. This method fails if the file does
@@ -267,7 +267,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenExisting(bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenExisting(bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for read access. This method fails if the file does
@@ -280,7 +280,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadOnlyExisting (bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenReadOnlyExisting (bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for write access. If the file does not exist, it is created.
@@ -292,7 +292,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnlyTruncate(const char *filename=NULL);
+ bool OpenWriteOnlyTruncate(const char *filename=nullptr);
/**
* Open a file for write access. This method fails if the file does
@@ -305,7 +305,7 @@ public:
* @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnlyExisting (bool abortIfNotExist=false, const char *filename=NULL);
+ bool OpenWriteOnlyExisting (bool abortIfNotExist=false, const char *filename=nullptr);
/**
* Open a file for read-access only. This method fails if the file does
@@ -316,7 +316,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenReadOnly(const char *filename=NULL);
+ bool OpenReadOnly(const char *filename=nullptr);
/**
* Open a file for write-access only. The file will be created if it does
@@ -327,7 +327,7 @@ public:
* @ref SetFileName() or a previous call to @ref Open().
* @return Boolean success/failure
*/
- bool OpenWriteOnly(const char *filename=NULL);
+ bool OpenWriteOnly(const char *filename=nullptr);
bool OpenStdin();
@@ -567,7 +567,7 @@ public:
* from malloc will be saved. Use free() with
* this pointer to deallocate the buffer.
* This value is always set.
- * @return Alligned pointer value or NULL if out of memory
+ * @return Alligned pointer value or nullptr if out of memory
*/
virtual void *AllocateDirectIOBuffer(size_t byteSize, void *&realPtr);
@@ -581,7 +581,7 @@ public:
/**
* Inquiry about where in memory file data is located.
* @return location of file data in memory. If the file is not mapped,
- * NULL is returned.
+ * nullptr is returned.
*/
virtual void *MemoryMapPtr(int64_t position) const;
diff --git a/fastos/src/vespa/fastos/linux_file.cpp b/fastos/src/vespa/fastos/linux_file.cpp
index 3817e337490..08dc78585ec 100644
--- a/fastos/src/vespa/fastos/linux_file.cpp
+++ b/fastos/src/vespa/fastos/linux_file.cpp
@@ -32,7 +32,7 @@ ssize_t
FastOS_Linux_File::readInternal(int fh, void *buffer, size_t length, int64_t readOffset)
{
ssize_t readResult = ::pread(fh, buffer, length, readOffset);
- if (readResult < 0 && _failedHandler != NULL) {
+ if (readResult < 0 && _failedHandler != nullptr) {
int error = errno;
const char *fileName = GetFileName();
_failedHandler("read", fileName, error, readOffset, length, readResult);
@@ -46,7 +46,7 @@ ssize_t
FastOS_Linux_File::readInternal(int fh, void *buffer, size_t length)
{
ssize_t readResult = ::read(fh, buffer, length);
- if (readResult < 0 && _failedHandler != NULL) {
+ if (readResult < 0 && _failedHandler != nullptr) {
int error = errno;
int64_t readOffset = GetPosition();
const char *fileName = GetFileName();
@@ -61,7 +61,7 @@ ssize_t
FastOS_Linux_File::writeInternal(int fh, const void *buffer, size_t length, int64_t writeOffset)
{
ssize_t writeRes = ::pwrite(fh, buffer, length, writeOffset);
- if (writeRes < 0 && _failedHandler != NULL) {
+ if (writeRes < 0 && _failedHandler != nullptr) {
int error = errno;
const char *fileName = GetFileName();
_failedHandler("write", fileName, error, writeOffset, length, writeRes);
@@ -74,7 +74,7 @@ ssize_t
FastOS_Linux_File::writeInternal(int fh, const void *buffer, size_t length)
{
ssize_t writeRes = ::write(fh, buffer, length);
- if (writeRes < 0 && _failedHandler != NULL) {
+ if (writeRes < 0 && _failedHandler != nullptr) {
int error = errno;
int64_t writeOffset = GetPosition();
const char *fileName = GetFileName();
diff --git a/fastos/src/vespa/fastos/linux_file.h b/fastos/src/vespa/fastos/linux_file.h
index 95f2b935958..d33884c872a 100644
--- a/fastos/src/vespa/fastos/linux_file.h
+++ b/fastos/src/vespa/fastos/linux_file.h
@@ -24,7 +24,7 @@ protected:
int64_t _filePointer; // Only maintained/used in directio mode
public:
- FastOS_Linux_File (const char *filename = NULL);
+ FastOS_Linux_File (const char *filename = nullptr);
~FastOS_Linux_File () {
Close();
}
diff --git a/fastos/src/vespa/fastos/process.cpp b/fastos/src/vespa/fastos/process.cpp
index a806799e933..cac491de1e1 100644
--- a/fastos/src/vespa/fastos/process.cpp
+++ b/fastos/src/vespa/fastos/process.cpp
@@ -9,13 +9,13 @@ FastOS_ProcessInterface::FastOS_ProcessInterface (const char *cmdLine,
FastOS_ProcessRedirectListener *stderrListener,
int bufferSize) :
_extradoublehackforalignment(0.0),
- _cmdLine(NULL),
+ _cmdLine(nullptr),
_pipeStdin(pipeStdin),
_stdoutListener(stdoutListener),
_stderrListener(stderrListener),
_bufferSize(bufferSize),
- _next(NULL),
- _prev(NULL)
+ _next(nullptr),
+ _prev(nullptr)
{
_cmdLine = strdup(cmdLine);
}
diff --git a/fastos/src/vespa/fastos/process.h b/fastos/src/vespa/fastos/process.h
index 1810a730d9d..f0c1fcaa2a9 100644
--- a/fastos/src/vespa/fastos/process.h
+++ b/fastos/src/vespa/fastos/process.h
@@ -26,7 +26,7 @@ public:
* You should assume that any thread can invoke this method.
* For convenience the data buffer is always zero- terminated
* (static_cast<uint8_t>(data[length]) = '\\0').
- * When the pipe closes, the method is invoked with data = NULL
+ * When the pipe closes, the method is invoked with data = nullptr
* and length = 0.
* @param data Pointer to data
* @param length Length of data block in bytes
@@ -76,7 +76,7 @@ public:
* of PrefopenNoInherit.
* @return Internal data needed to cancel object inheritance.
*/
- static void *PrefopenNoInherit (void) {return NULL;}
+ static void *PrefopenNoInherit (void) {return nullptr;}
/**
* Call this after opening files with fopen to avoid having
@@ -105,14 +105,14 @@ public:
* @ref CreateWithShell to actually start the process.
* @param cmdLine Command line
* @param pipeStdin set to true in order to redirect stdin
- * @param stdoutListener non-NULL to redirect stdout
- * @param stderrListener non-NULL to redirect stderr
+ * @param stdoutListener non-nullptr to redirect stdout
+ * @param stderrListener non-nullptr to redirect stderr
* @param bufferSize Size of redirect buffers
*/
FastOS_ProcessInterface (const char *cmdLine,
bool pipeStdin = false,
- FastOS_ProcessRedirectListener *stdoutListener = NULL,
- FastOS_ProcessRedirectListener *stderrListener = NULL,
+ FastOS_ProcessRedirectListener *stdoutListener = nullptr,
+ FastOS_ProcessRedirectListener *stderrListener = nullptr,
int bufferSize = 65535);
/**
@@ -154,7 +154,7 @@ public:
/**
* If you are redirecting the standard input stream of the process,
* use this method to write data. To close the input stream,
- * invoke @ref WriteStdin with data=NULL. If the input stream
+ * invoke @ref WriteStdin with data=nullptr. If the input stream
* is not redirected, @ref WriteStdin will fail.
* @param data Pointer to data
* @param length Length of data block in bytes
diff --git a/fastos/src/vespa/fastos/serversocket.h b/fastos/src/vespa/fastos/serversocket.h
index 93f1efe21fc..2e0690ffc3b 100644
--- a/fastos/src/vespa/fastos/serversocket.h
+++ b/fastos/src/vespa/fastos/serversocket.h
@@ -74,14 +74,14 @@ protected:
/**
* The socket factory to use for incoming connections.
- * If this is NULL, the default action is to create an
+ * If this is nullptr, the default action is to create an
* instance of the regular @ref FastOS_Socket.
*/
FastOS_SocketFactory *_socketFactory;
/**
* Create socket for handling an incoming connection
- * @return Returns pointer to newly created socket, or NULL on
+ * @return Returns pointer to newly created socket, or nullptr on
* failure.
*/
FastOS_SocketInterface *CreateHandlerSocket();
@@ -98,8 +98,8 @@ public:
* @param strictBindHostName IP address or hostname for strict binding
*/
FastOS_ServerSocket (int portnum, int backLog=5,
- FastOS_SocketFactory *socketFactory=NULL,
- const char *strictBindHostName=NULL)
+ FastOS_SocketFactory *socketFactory=nullptr,
+ const char *strictBindHostName=nullptr)
: _portNumber(portnum),
_backLog(backLog),
_socketFactory(socketFactory),
@@ -126,7 +126,7 @@ public:
* start to listen for incoming connections. You should
* call @ref Listen() if you have supplied a pre-created listening
* socket handle trough the constructor
- * @ref FastOS_ServerSocket(int listenSocketHandle, FastOS_SocketFactory *socketFactory=NULL).
+ * @ref FastOS_ServerSocket(int listenSocketHandle, FastOS_SocketFactory *socketFactory=nullptr).
* @return Boolean success/failure
*/
bool Listen ();
@@ -137,7 +137,7 @@ public:
* Make sure you have a listening socket (see @ref Listen()) before
* calling @ref Accept().
* @return Returns pointer to newly created socket object for the
- * connection that was accepted, or NULL on failure.
+ * connection that was accepted, or nullptr on failure.
*/
FastOS_SocketInterface *Accept ();
@@ -147,7 +147,7 @@ public:
* Make sure you have a listening socket (see @ref Listen()) before
* calling @ref AcceptPlain().
* @return Returns pointer to newly created socket object for the
- * connection that was accepted, or NULL on failure.
+ * connection that was accepted, or nullptr on failure.
*/
FastOS_Socket *AcceptPlain ();
@@ -157,7 +157,7 @@ public:
* factory will be called to create a new socket object for the
* connection.
*
- * SetSocketFactory(NULL) will enable the default socket factory
+ * SetSocketFactory(nullptr) will enable the default socket factory
* mechanism which will create regular @ref FastOS_Socket instances
* on accepted connections.
*/
diff --git a/fastos/src/vespa/fastos/socket.cpp b/fastos/src/vespa/fastos/socket.cpp
index 2732a38cf4c..c274f42bc68 100644
--- a/fastos/src/vespa/fastos/socket.cpp
+++ b/fastos/src/vespa/fastos/socket.cpp
@@ -14,8 +14,8 @@ FastOS_SocketInterface::FastOS_SocketInterface()
_readPossible(false),
_writePossible(false),
_epolled(false),
- _socketEvent(NULL),
- _eventAttribute(NULL),
+ _socketEvent(nullptr),
+ _eventAttribute(nullptr),
_socketEventArrayPos(-1),
_address(),
_socketHandle(-1),
@@ -30,8 +30,8 @@ FastOS_SocketInterface::FastOS_SocketInterface(int socketHandle, struct sockaddr
_readPossible(false),
_writePossible(false),
_epolled(false),
- _socketEvent(NULL),
- _eventAttribute(NULL),
+ _socketEvent(nullptr),
+ _eventAttribute(nullptr),
_socketEventArrayPos(-1),
_address(),
_socketHandle(-1),
@@ -145,10 +145,10 @@ void FastOS_SocketInterface::ConstructorWork ()
{
_socketHandle = -1;
_epolled = false;
- _socketEvent = NULL;
+ _socketEvent = nullptr;
_readEventEnabled = false;
_writeEventEnabled = false;
- _eventAttribute = NULL;
+ _eventAttribute = nullptr;
_socketEventArrayPos = -1;
}
@@ -234,10 +234,10 @@ bool FastOS_SocketInterface::GetSoIntOpt(int option, int &value)
void FastOS_SocketInterface::CleanupEvents ()
{
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->Detach(this);
assert(!_epolled);
- _socketEvent = NULL;
+ _socketEvent = nullptr;
}
}
@@ -287,7 +287,7 @@ FastOS_SocketInterface::getLastErrorString(void) {
const char *
FastOS_SocketInterface::InitializeServices(void) {
FastOS_SocketEventObjects::InitializeClass();
- return NULL;
+ return nullptr;
}
void FastOS_SocketInterface::CleanupServices () {
@@ -301,14 +301,14 @@ bool FastOS_SocketInterface::SetSocketEvent (FastOS_SocketEvent *event, void *at
if (CreateIfNoSocketYet()) {
if (_socketEvent != event) {
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
// Disable events for this socket on the old SocketEvent
_socketEvent->Detach(this);
assert(!_epolled);
- _socketEvent = NULL;
+ _socketEvent = nullptr;
}
- if (event != NULL) {
+ if (event != nullptr) {
event->Attach(this, _readEventEnabled, _writeEventEnabled);
_socketEvent = event;
}
@@ -322,7 +322,7 @@ bool FastOS_SocketInterface::SetSocketEvent (FastOS_SocketEvent *event, void *at
void FastOS_SocketInterface::EnableReadEvent (bool enabled) {
if (_readEventEnabled == enabled) { return; }
_readEventEnabled = enabled;
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->EnableEvent(this, _readEventEnabled, _writeEventEnabled);
}
}
@@ -337,7 +337,7 @@ void FastOS_SocketInterface::EnableReadEvent (bool enabled) {
void FastOS_SocketInterface::EnableWriteEvent (bool enabled) {
if (_writeEventEnabled == enabled) { return; }
_writeEventEnabled = enabled;
- if (_socketEvent != NULL) {
+ if (_socketEvent != nullptr) {
_socketEvent->EnableEvent(this, _readEventEnabled, _writeEventEnabled);
}
}
diff --git a/fastos/src/vespa/fastos/socket.h b/fastos/src/vespa/fastos/socket.h
index 6f4650ab64a..31b8903a4e4 100644
--- a/fastos/src/vespa/fastos/socket.h
+++ b/fastos/src/vespa/fastos/socket.h
@@ -244,11 +244,11 @@ public:
* @param attribute Event attribute pointer
* @return Boolean success/failure.
*/
- bool SetSocketEvent (FastOS_SocketEvent *event, void *attribute=NULL);
+ bool SetSocketEvent (FastOS_SocketEvent *event, void *attribute=nullptr);
/**
* Get socket event object
- * @return Associated socket event object or NULL
+ * @return Associated socket event object or nullptr
*/
FastOS_SocketEvent *GetSocketEvent () { return _socketEvent; }
diff --git a/fastos/src/vespa/fastos/socketevent.cpp b/fastos/src/vespa/fastos/socketevent.cpp
index e3bc7d28888..a80cb015782 100644
--- a/fastos/src/vespa/fastos/socketevent.cpp
+++ b/fastos/src/vespa/fastos/socketevent.cpp
@@ -6,7 +6,7 @@
#include <unistd.h>
-FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = NULL;
+FastOS_SocketEventObjects *FastOS_SocketEventObjects::_objects = nullptr;
FastOS_Mutex FastOS_SocketEventObjects::_listMutex;
int FastOS_SocketEventObjects::_objectCount = 0;
bool FastOS_SocketEventObjects::_initialized = false;
@@ -17,12 +17,12 @@ FastOS_SocketEvent::FastOS_SocketEvent () :
_socketsInArray(0),
_getEventsIndex(0),
_wokeUp(false),
- _objs(NULL)
+ _objs(nullptr)
{
_objs = FastOS_SocketEventObjects::ObtainObject(this);
- if(_objs != NULL) {
+ if(_objs != nullptr) {
if(_objs->_initOk) {
}
}
@@ -57,19 +57,19 @@ FastOS_SocketEventObjects *FastOS_SocketEventObjects::ObtainObject (FastOS_Socke
FastOS_SocketEventObjects *node;
_listMutex.Lock();
- if(_objects == NULL)
+ if(_objects == nullptr)
{
_objectCount++;
_listMutex.Unlock();
node = new FastOS_SocketEventObjects(event);
- node->_next = NULL;
+ node->_next = nullptr;
}
else
{
node = _objects;
_objects = node->_next;
- node->_next = NULL;
+ node->_next = nullptr;
_listMutex.Unlock();
}
@@ -79,7 +79,7 @@ FastOS_SocketEventObjects *FastOS_SocketEventObjects::ObtainObject (FastOS_Socke
void FastOS_SocketEventObjects::ReleaseObject (FastOS_SocketEventObjects *node)
{
- if (node != NULL)
+ if (node != nullptr)
node->ReleasedCleanup();
_listMutex.Lock();
@@ -99,7 +99,7 @@ bool
FastOS_SocketEvent::epollInit()
{
_epollfd = epoll_create(4093);
- if (_epollfd != -1 && _objs != NULL && _objs->_initOk) {
+ if (_epollfd != -1 && _objs != nullptr && _objs->_initOk) {
epoll_event evt;
evt.events = EPOLLIN;
evt.data.ptr = 0;
@@ -153,7 +153,7 @@ FastOS_SocketEvent::epollWait(bool &error, int msTimeout)
for (int i = 0; i < res; ++i) {
const epoll_event &evt = _epollEvents[i];
FastOS_SocketInterface *sock = (FastOS_SocketInterface *) evt.data.ptr;
- if (sock == NULL) {
+ if (sock == nullptr) {
HandleWakeUp();
} else {
sock->_readPossible = sock->_readEventEnabled &&
@@ -182,7 +182,7 @@ FastOS_SocketEvent::epollGetEvents(bool *wakeUp, int msTimeout,
const epoll_event &evt = _epollEvents[i];
FastOS_IOEvent &appEvt = events[idx];
FastOS_SocketInterface *sock = (FastOS_SocketInterface *) evt.data.ptr;
- if (sock == NULL) {
+ if (sock == nullptr) {
HandleWakeUp(); // sets _wokeUp
} else {
appEvt._readOccurred = sock->_readEventEnabled &&
@@ -227,7 +227,7 @@ void FastOS_SocketEventObjects::ClassCleanup(void)
{
FastOS_SocketEventObjects *node = _objects;
- if(node == NULL)
+ if(node == nullptr)
break;
else
{
@@ -241,11 +241,11 @@ void FastOS_SocketEventObjects::ClassCleanup(void)
FastOS_SocketEventObjects::FastOS_SocketEventObjects(FastOS_SocketEvent *event)
- : _next(NULL),
+ : _next(nullptr),
_initOk(false),
- _socketArray(NULL),
+ _socketArray(nullptr),
_socketArrayAllocSize(0u),
- _pollfds(NULL),
+ _pollfds(nullptr),
_pollfdsAllocSize(0)
{
// Connect ourselves to the socketevent object.
@@ -259,12 +259,12 @@ FastOS_SocketEventObjects::ReleasedCleanup(void)
{
if (_socketArrayAllocSize > 16) {
delete [] _socketArray;
- _socketArray = NULL;
+ _socketArray = nullptr;
_socketArrayAllocSize = 0;
}
if (_pollfdsAllocSize > 16) {
free(_pollfds);
- _pollfds = NULL;
+ _pollfds = nullptr;
_pollfdsAllocSize = 0;
}
}
diff --git a/fastos/src/vespa/fastos/socketevent.h b/fastos/src/vespa/fastos/socketevent.h
index 6ed6b73a86c..5e457908ace 100644
--- a/fastos/src/vespa/fastos/socketevent.h
+++ b/fastos/src/vespa/fastos/socketevent.h
@@ -87,7 +87,7 @@ public:
* FastOS_SocketEvent socketEvent;
*
* // Walk through single-linked list of connections
- * for(conn=connections; conn!=NULL; conn = conn->_next)
+ * for(conn=connections; conn!=nullptr; conn = conn->_next)
* {
* // Associate each socket with socketEvent
* conn->_socket->SetSocketEvent(&socketEvent);
@@ -105,7 +105,7 @@ public:
* if(socketEvent.Wait(200))
* {
* // Walk through list of connections
- * for(conn=connections; conn!=NULL; conn = conn->_next)
+ * for(conn=connections; conn!=nullptr; conn = conn->_next)
* {
* // For each socket, check for read event
* if(socketEvent.QueryReadEvent(conn->_socket))
@@ -172,7 +172,7 @@ public:
if (_epollfd == -1) {
return false;
}
- return (_objs != NULL) ? _objs->_initOk : false;
+ return (_objs != nullptr) ? _objs->_initOk : false;
}
/**
diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp
index 484746a9b0d..3cd3bb4b85b 100644
--- a/fastos/src/vespa/fastos/thread.cpp
+++ b/fastos/src/vespa/fastos/thread.cpp
@@ -21,8 +21,8 @@ FastOS_ThreadPool::FastOS_ThreadPool(int stackSize, int maxThreads)
_closeCalledFlag(false),
_freeMutex(),
_liveCond(),
- _freeThreads(NULL),
- _activeThreads(NULL),
+ _freeThreads(nullptr),
+ _activeThreads(nullptr),
_numFree(0),
_numActive(0),
_numTerminated(0),
@@ -71,9 +71,9 @@ void FastOS_ThreadPool::FreeThread (FastOS_ThreadInterface *thread)
void FastOS_ThreadPool::LinkOutThread (FastOS_ThreadInterface *thread, FastOS_ThreadInterface **listHead)
{
- if (thread->_prev != NULL)
+ if (thread->_prev != nullptr)
thread->_prev->_next = thread->_next;
- if (thread->_next != NULL)
+ if (thread->_next != nullptr)
thread->_next->_prev = thread->_prev;
if (thread == *listHead)
@@ -82,10 +82,10 @@ void FastOS_ThreadPool::LinkOutThread (FastOS_ThreadInterface *thread, FastOS_Th
void FastOS_ThreadPool::LinkInThread (FastOS_ThreadInterface *thread, FastOS_ThreadInterface **listHead)
{
- thread->_prev = NULL;
+ thread->_prev = nullptr;
thread->_next = *listHead;
- if (*listHead != NULL)
+ if (*listHead != nullptr)
(*listHead)->_prev = thread;
*listHead = thread;
@@ -108,12 +108,12 @@ void FastOS_ThreadPool::ActivateThread (FastOS_ThreadInterface *thread)
// make this thread call parameter fcn when it becomes active.
FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, void *arg)
{
- FastOS_ThreadInterface *thread=NULL;
+ FastOS_ThreadInterface *thread=nullptr;
_freeMutex.Lock();
if (!isClosed()) {
- if ((thread = _freeThreads) != NULL) {
+ if ((thread = _freeThreads) != nullptr) {
// Reusing thread entry
_freeThreads = thread->_next;
_numFree--;
@@ -134,7 +134,7 @@ FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, vo
thread = FastOS_Thread::CreateThread(this);
- if (thread == NULL) {
+ if (thread == nullptr) {
_liveCond.Lock();
_numLive--;
if (_numLive == 0) {
@@ -145,14 +145,14 @@ FastOS_ThreadInterface *FastOS_ThreadPool::NewThread (FastOS_Runnable *owner, vo
_freeMutex.Lock();
- if(thread != NULL)
+ if(thread != nullptr)
ActivateThread(thread);
}
}
}
_freeMutex.Unlock();
- if(thread != NULL) {
+ if(thread != nullptr) {
_liveCond.Lock();
thread->Dispatch(owner, arg);
_liveCond.Unlock();
@@ -169,12 +169,12 @@ void FastOS_ThreadPool::BreakThreads ()
_freeMutex.Lock();
// Notice all active threads that they should quit
- for(thread=_activeThreads; thread != NULL; thread=thread->_next) {
+ for(thread=_activeThreads; thread != nullptr; thread=thread->_next) {
thread->SetBreakFlag();
}
// Notice all free threads that they should quit
- for(thread=_freeThreads; thread != NULL; thread=thread->_next) {
+ for(thread=_freeThreads; thread != nullptr; thread=thread->_next) {
thread->SetBreakFlag();
}
@@ -201,7 +201,7 @@ void FastOS_ThreadPool::DeleteThreads ()
assert(_numActive == 0);
assert(_numLive == 0);
- while((thread = _freeThreads) != NULL) {
+ while((thread = _freeThreads) != nullptr) {
LinkOutThread(thread, &_freeThreads);
_numFree--;
// printf("deleting thread %p\n", thread);
@@ -243,7 +243,7 @@ void *FastOS_ThreadHook (void *arg)
FastOS_ThreadInterface *thread = static_cast<FastOS_ThreadInterface *>(arg);
thread->Hook();
- return NULL;
+ return nullptr;
}
};
@@ -264,7 +264,7 @@ void FastOS_ThreadInterface::Hook ()
_dispatched.Lock(); // BEGIN lock
- while (_owner == NULL && !(finished = _pool->isClosed())) {
+ while (_owner == nullptr && !(finished = _pool->isClosed())) {
_dispatched.Wait();
}
@@ -280,8 +280,8 @@ void FastOS_ThreadInterface::Hook ()
if (deleteOnCompletion) {
delete _owner;
}
- _owner = NULL;
- _startArg = NULL;
+ _owner = nullptr;
+ _startArg = nullptr;
_breakFlag = false;
finished = _pool->isClosed();
@@ -343,7 +343,7 @@ FastOS_ThreadInterface *FastOS_ThreadInterface::CreateThread(FastOS_ThreadPool *
if(!thread->Initialize(pool->GetStackSize(), pool->GetStackGuardSize())) {
delete(thread);
- thread = NULL;
+ thread = nullptr;
}
return thread;
@@ -360,16 +360,16 @@ void FastOS_ThreadInterface::Join ()
// ----------------------------------------------------------------------
FastOS_Runnable::FastOS_Runnable(void)
- : _thread(NULL)
+ : _thread(nullptr)
{
}
FastOS_Runnable::~FastOS_Runnable(void)
{
- // assert(_thread == NULL);
+ // assert(_thread == nullptr);
}
void FastOS_Runnable::Detach(void)
{
- _thread = NULL;
+ _thread = nullptr;
}
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index b84708eb050..eb43fc6b664 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -158,9 +158,9 @@ public:
* @param owner Instance to be invoked by new thread.
* @param arg Arguments to be passed to new thread.
*
- * @return Pointer to newly created thread or NULL on failure.
+ * @return Pointer to newly created thread or nullptr on failure.
*/
- FastOS_ThreadInterface *NewThread (FastOS_Runnable *owner, void *arg=NULL);
+ FastOS_ThreadInterface *NewThread (FastOS_Runnable *owner, void *arg=nullptr);
/**
* Get the stack size used for threads in this pool.
@@ -285,7 +285,7 @@ protected:
* Create an operating system thread. In most cases you would want
* to create threads using @ref FastOS_ThreadPool::NewThread() instead.
* @param pool The threadpool which is about to contain the new thread.
- * @return A new @ref FastOS_Thread or NULL on failure.
+ * @return A new @ref FastOS_Thread or nullptr on failure.
*/
static FastOS_ThreadInterface *CreateThread(FastOS_ThreadPool *pool);
@@ -325,11 +325,11 @@ public:
*/
FastOS_ThreadInterface (FastOS_ThreadPool *pool)
: _dispatched(),
- _next(NULL),
- _prev(NULL),
- _owner(NULL),
+ _next(nullptr),
+ _prev(nullptr),
+ _owner(nullptr),
_pool(pool),
- _startArg(NULL),
+ _startArg(nullptr),
_breakFlag(false),
_active(false),
_runningCond()
@@ -492,7 +492,7 @@ public:
FastOS_ThreadInterface *GetThread(void) { return _thread; }
const FastOS_ThreadInterface *GetThread(void) const { return _thread; }
- bool HasThread(void) const { return _thread != NULL; }
+ bool HasThread(void) const { return _thread != nullptr; }
void Detach(void);
};
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index da0aa6bbd01..f967ea5aade 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -32,7 +32,7 @@ TimeStamp::asString(double timeInSeconds)
int64_t ClockSystem::now()
{
struct timeval timeNow;
- gettimeofday(&timeNow, NULL);
+ gettimeofday(&timeNow, nullptr);
int64_t ns = timeNow.tv_sec;
ns *= TimeStamp::NANO;
ns += timeNow.tv_usec*1000;
diff --git a/fastos/src/vespa/fastos/unix_app.cpp b/fastos/src/vespa/fastos/unix_app.cpp
index 5916017e95c..7682b2d5b8f 100644
--- a/fastos/src/vespa/fastos/unix_app.cpp
+++ b/fastos/src/vespa/fastos/unix_app.cpp
@@ -17,8 +17,8 @@
FastOS_UNIX_Application::FastOS_UNIX_Application ()
- : _processStarter(NULL),
- _ipcHelper(NULL)
+ : _processStarter(nullptr),
+ _ipcHelper(nullptr)
{
}
@@ -71,7 +71,7 @@ bool FastOS_UNIX_Application::
SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer,
int length)
{
- if(_ipcHelper == NULL)
+ if(_ipcHelper == nullptr)
return false;
return _ipcHelper->SendMessage(xproc, buffer, length);
}
@@ -80,9 +80,9 @@ SendIPCMessage (FastOS_UNIX_Process *xproc, const void *buffer,
bool FastOS_UNIX_Application::
SendParentIPCMessage (const void *data, size_t length)
{
- if(_ipcHelper == NULL)
+ if(_ipcHelper == nullptr)
return false;
- return _ipcHelper->SendMessage(NULL, data, length);
+ return _ipcHelper->SendMessage(nullptr, data, length);
}
@@ -95,7 +95,7 @@ bool FastOS_UNIX_Application::PreThreadInit ()
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- sigaction(SIGPIPE, &act, NULL);
+ sigaction(SIGPIPE, &act, nullptr);
if (useProcessStarter()) {
_processStarter = new FastOS_UNIX_ProcessStarter(this);
@@ -120,7 +120,7 @@ bool FastOS_UNIX_Application::Init ()
int ipcDescriptor = -1;
char *env = getenv("FASTOS_IPC_PARENT");
- if(env != NULL)
+ if(env != nullptr)
{
int commaCount=0;
int notDigitCount=0;
@@ -158,15 +158,15 @@ bool FastOS_UNIX_Application::Init ()
void FastOS_UNIX_Application::Cleanup ()
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->Exit();
- if (_processStarter != NULL) {
+ if (_processStarter != nullptr) {
if (_processListMutex) ProcessLock();
_processStarter->Stop();
if (_processListMutex) ProcessUnlock();
delete _processStarter;
- _processStarter = NULL;
+ _processStarter = nullptr;
}
FastOS_ApplicationInterface::Cleanup();
@@ -181,13 +181,13 @@ FastOS_UNIX_Application::GetProcessStarter ()
void FastOS_UNIX_Application::
AddToIPCComm (FastOS_UNIX_Process *process)
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->AddProcess(process);
}
void FastOS_UNIX_Application::
RemoveFromIPCComm (FastOS_UNIX_Process *process)
{
- if(_ipcHelper != NULL)
+ if(_ipcHelper != nullptr)
_ipcHelper->RemoveProcess(process);
}
diff --git a/fastos/src/vespa/fastos/unix_cond.cpp b/fastos/src/vespa/fastos/unix_cond.cpp
index f2e541055ff..5eb1f5b0218 100644
--- a/fastos/src/vespa/fastos/unix_cond.cpp
+++ b/fastos/src/vespa/fastos/unix_cond.cpp
@@ -8,7 +8,7 @@ FastOS_UNIX_Cond::FastOS_UNIX_Cond(void)
: FastOS_CondInterface(),
_cond()
{
- pthread_cond_init(&_cond, NULL);
+ pthread_cond_init(&_cond, nullptr);
}
FastOS_UNIX_Cond::~FastOS_UNIX_Cond(void)
@@ -30,7 +30,7 @@ FastOS_UNIX_Cond::TimedWait(int milliseconds)
struct timespec absTime;
int error;
- gettimeofday(&currentTime, NULL);
+ gettimeofday(&currentTime, nullptr);
int64_t ns = (static_cast<int64_t>(currentTime.tv_sec) *
static_cast<int64_t>(1000 * 1000 * 1000) +
diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
index 75d3ee9fb27..f3d3aa35511 100644
--- a/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
+++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.cpp
@@ -20,7 +20,7 @@ bool hasValidSuffix(const std::string & s)
void
FastOS_UNIX_DynamicLibrary::SetLibName(const char *libname)
{
- if (libname != NULL) {
+ if (libname != nullptr) {
_libname = libname;
if ( ! hasValidSuffix(_libname)) {
_libname.append(FASTOS_DYNLIB_SUFFIX);
@@ -58,14 +58,14 @@ FastOS_UNIX_DynamicLibrary::Close()
if (IsOpen()) {
retcode = (dlclose(_handle) == 0);
if (retcode)
- _handle = NULL;
+ _handle = nullptr;
}
return retcode;
}
FastOS_UNIX_DynamicLibrary::FastOS_UNIX_DynamicLibrary(const char *libname) :
- _handle(NULL),
+ _handle(nullptr),
_libname("")
{
SetLibName(libname);
@@ -81,13 +81,13 @@ FastOS_UNIX_DynamicLibrary::Open(const char *libname)
{
if (! Close())
return false;
- if (libname != NULL) {
+ if (libname != nullptr) {
SetLibName(libname);
}
_handle = dlopen(_libname.c_str(), RTLD_NOW);
- if (_handle == NULL) {
+ if (_handle == nullptr) {
// Prepend "lib" if neccessary...
if (NormalizeLibName()) {
// ...try to open again if a change was made.
@@ -95,7 +95,7 @@ FastOS_UNIX_DynamicLibrary::Open(const char *libname)
}
}
- return (_handle != NULL);
+ return (_handle != nullptr);
}
void *
@@ -109,7 +109,7 @@ FastOS_UNIX_DynamicLibrary::GetLastErrorString() const
{
const char *errorString = dlerror();
std::string e;
- if (errorString != NULL) {
+ if (errorString != nullptr) {
e = errorString;
}
diff --git a/fastos/src/vespa/fastos/unix_dynamiclibrary.h b/fastos/src/vespa/fastos/unix_dynamiclibrary.h
index 13e86b1c8af..1c891ee5b6d 100644
--- a/fastos/src/vespa/fastos/unix_dynamiclibrary.h
+++ b/fastos/src/vespa/fastos/unix_dynamiclibrary.h
@@ -24,17 +24,17 @@ private:
std::string _libname;
public:
- FastOS_UNIX_DynamicLibrary(const char *libname = NULL);
+ FastOS_UNIX_DynamicLibrary(const char *libname = nullptr);
~FastOS_UNIX_DynamicLibrary();
void SetLibName(const char *libname);
bool NormalizeLibName(void);
bool Close() override;
- bool Open(const char *libname = NULL) override;
+ bool Open(const char *libname = nullptr) override;
void * GetSymbol(const char *symbol) const override;
std::string GetLastErrorString() const;
const char * GetLibName() const { return _libname.c_str(); }
- bool IsOpen() const override { return (_handle != NULL); }
+ bool IsOpen() const override { return (_handle != nullptr); }
};
diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h
index aa5ea4edb01..5702f511ca5 100644
--- a/fastos/src/vespa/fastos/unix_file.h
+++ b/fastos/src/vespa/fastos/unix_file.h
@@ -47,9 +47,9 @@ public:
static int GetMaximumFilenameLength (const char *pathName);
static int GetMaximumPathLength (const char *pathName);
- FastOS_UNIX_File(const char *filename=NULL)
+ FastOS_UNIX_File(const char *filename=nullptr)
: FastOS_FileInterface(filename),
- _mmapbase(NULL),
+ _mmapbase(nullptr),
_mmaplen(0),
_filedes(-1),
_mmapFlags(0),
@@ -66,18 +66,18 @@ public:
}
void *MemoryMapPtr(int64_t position) const override {
- if (_mmapbase != NULL) {
+ if (_mmapbase != nullptr) {
if (position < int64_t(_mmaplen)) {
return static_cast<void *>(static_cast<char *>(_mmapbase) + position);
} else { // This is an indication that the file size has changed and a remap/reopen must be done.
- return NULL;
+ return nullptr;
}
} else {
- return NULL;
+ return nullptr;
}
}
- bool IsMemoryMapped() const override { return _mmapbase != NULL; }
+ bool IsMemoryMapped() const override { return _mmapbase != nullptr; }
bool SetPosition(int64_t desiredPosition) override;
int64_t GetPosition() override;
int64_t GetSize() override;
diff --git a/fastos/src/vespa/fastos/unix_ipc.cpp b/fastos/src/vespa/fastos/unix_ipc.cpp
index f8cde75bc7a..695d395674f 100644
--- a/fastos/src/vespa/fastos/unix_ipc.cpp
+++ b/fastos/src/vespa/fastos/unix_ipc.cpp
@@ -118,7 +118,7 @@ SetBlocking (int fileDescriptor, bool doBlock)
{
bool rc=false;
- int flags = fcntl(fileDescriptor, F_GETFL, NULL);
+ int flags = fcntl(fileDescriptor, F_GETFL, nullptr);
if (flags != -1)
{
if(doBlock)
@@ -134,7 +134,7 @@ void FastOS_UNIX_IPCHelper::
BuildPollCheck(bool isRead, int filedes,
FastOS_RingBuffer *buffer, bool *check)
{
- if(buffer == NULL ||
+ if(buffer == nullptr ||
filedes < 0 ||
buffer->GetCloseFlag()) {
*check = false;
@@ -154,7 +154,7 @@ void FastOS_UNIX_IPCHelper::
PerformAsyncIO(void)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -187,7 +187,7 @@ void FastOS_UNIX_IPCHelper::
BuildPollChecks(void)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -202,11 +202,11 @@ BuildPollChecks(void)
}
}
- if(_appParentIPCDescriptor._writeBuffer.get() != NULL)
+ if(_appParentIPCDescriptor._writeBuffer.get() != nullptr)
BuildPollCheck(false, _appParentIPCDescriptor._fd,
_appParentIPCDescriptor._writeBuffer.get(),
&_appParentIPCDescriptor._wantWrite);
- if(_appParentIPCDescriptor._readBuffer.get() != NULL)
+ if(_appParentIPCDescriptor._readBuffer.get() != nullptr)
BuildPollCheck(true, _appParentIPCDescriptor._fd,
_appParentIPCDescriptor._readBuffer.get(),
&_appParentIPCDescriptor._wantRead);
@@ -225,12 +225,12 @@ ResizePollArray(pollfd **fds, unsigned int *allocnfds)
else
newallocnfds = *allocnfds * 2;
newfds = static_cast<pollfd *>(malloc(newallocnfds * sizeof(pollfd)));
- assert(newfds != NULL);
+ assert(newfds != nullptr);
if (*allocnfds > 0)
memcpy(newfds, *fds, sizeof(pollfd) * *allocnfds);
- if (*fds != NULL)
+ if (*fds != nullptr)
free(*fds);
*fds = newfds;
@@ -261,7 +261,7 @@ BuildPollArray(pollfd **fds, unsigned int *nfds, unsigned int *allocnfds)
rfds->revents = 0;
rfds++;
pollIdx = 1;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -331,7 +331,7 @@ SavePollArray(pollfd *fds, unsigned int nfds)
{
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
@@ -396,7 +396,7 @@ RemoveClosingProcesses(void)
FastOS_ProcessInterface *node, *next;
- for(node = _app->GetProcessList(); node != NULL; node = next)
+ for(node = _app->GetProcessList(); node != nullptr; node = next)
{
int type;
@@ -430,7 +430,7 @@ RemoveClosingProcesses(void)
if(!stillBusy)
{
- if(xproc->_closing != NULL)
+ if(xproc->_closing != nullptr)
{
// We already have the process lock at this point,
// so modifying the list is safe.
@@ -468,14 +468,14 @@ Run(FastOS_ThreadInterface *thisThread, void *arg)
unsigned int nfds;
unsigned int allocnfds;
- fds = NULL;
+ fds = nullptr;
nfds = 0;
allocnfds = 0;
for(;;)
{
// Deliver messages to from child processes and parent.
_app->ProcessLock();
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc = static_cast<FastOS_UNIX_Process *>(node);
FastOS_UNIX_Process::DescriptorHandle &desc =
@@ -578,12 +578,12 @@ SendMessage (FastOS_UNIX_Process *xproc, const void *buffer,
FastOS_RingBuffer *ipcBuffer;
FastOS_UNIX_Process::DescriptorHandle &desc =
- xproc != NULL ?
+ xproc != nullptr ?
xproc->GetDescriptorHandle(FastOS_UNIX_Process::TYPE_IPC) :
_appParentIPCDescriptor;
ipcBuffer = desc._writeBuffer.get();
- if(ipcBuffer != NULL) {
+ if(ipcBuffer != nullptr) {
ipcBuffer->Lock();
if(ipcBuffer->GetWriteSpace() >= int((length + sizeof(int)))) {
@@ -653,7 +653,7 @@ void FastOS_UNIX_IPCHelper::RemoveProcess (FastOS_UNIX_Process *xproc)
void FastOS_UNIX_IPCHelper::DeliverMessages (FastOS_RingBuffer *buffer)
{
- if(buffer == NULL)
+ if(buffer == nullptr)
return;
buffer->Lock();
@@ -683,11 +683,11 @@ PipeData (FastOS_UNIX_Process *process,
{
FastOS_UNIX_Process::DescriptorHandle &desc = process->GetDescriptorHandle(type);
FastOS_RingBuffer *buffer = desc._readBuffer.get();
- if(buffer == NULL)
+ if(buffer == nullptr)
return;
FastOS_ProcessRedirectListener *listener = process->GetListener(type);
- if(listener == NULL)
+ if(listener == nullptr)
return;
buffer->Lock();
diff --git a/fastos/src/vespa/fastos/unix_mutex.cpp b/fastos/src/vespa/fastos/unix_mutex.cpp
index 4d802f691ec..535a39ce592 100644
--- a/fastos/src/vespa/fastos/unix_mutex.cpp
+++ b/fastos/src/vespa/fastos/unix_mutex.cpp
@@ -7,7 +7,7 @@ FastOS_UNIX_Mutex::FastOS_UNIX_Mutex(void)
: FastOS_MutexInterface(),
_mutex()
{
- int error = pthread_mutex_init(&_mutex, NULL);
+ int error = pthread_mutex_init(&_mutex, nullptr);
assert(error == 0);
(void) error;
}
diff --git a/fastos/src/vespa/fastos/unix_process.cpp b/fastos/src/vespa/fastos/unix_process.cpp
index 70e441c64db..df32cb935ff 100644
--- a/fastos/src/vespa/fastos/unix_process.cpp
+++ b/fastos/src/vespa/fastos/unix_process.cpp
@@ -172,7 +172,7 @@ public:
static const char *
NextArgument (const char *p,
const char **endArg,
- int *length = NULL);
+ int *length = nullptr);
static int CountArguments (const char *commandLine);
@@ -264,10 +264,10 @@ FastOS_UNIX_RealProcess::FastOS_UNIX_RealProcess(int streamMask)
_runDir(),
_stdoutRedirName(),
_stderrRedirName(),
- _path(NULL),
+ _path(nullptr),
_pathProgBuf(),
- _prev(NULL),
- _next(NULL)
+ _prev(nullptr),
+ _next(nullptr)
{
_stdinDes[0] = _stdinDes[1] = -1;
_stdoutDes[0] = _stdoutDes[1] = -1;
@@ -286,15 +286,15 @@ FastOS_UNIX_RealProcess::~FastOS_UNIX_RealProcess(void)
void
FastOS_UNIX_RealProcess::PrepareExecVPE(const char *prog)
{
- const char *path = NULL;
+ const char *path = nullptr;
char defaultPath[] = ":/usr/ucb:/bin:/usr/bin";
- if (strchr(prog, '/') != NULL) {
+ if (strchr(prog, '/') != nullptr) {
path = "";
} else {
path = getenv("PATH");
- if (path == NULL) path = defaultPath;
+ if (path == nullptr) path = defaultPath;
}
_path = path;
_pathProgBuf.resize(strlen(prog) + 1 + strlen(path) + 1);
@@ -362,14 +362,14 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
for(;;)
{
if (*p == '\0') {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
break;
}
if (quoteChar != '\0') {
if (*p == quoteChar) {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
p++;
break;
@@ -378,7 +378,7 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
else
{
if (IsWhiteSpace(*p)) {
- if (length != NULL)
+ if (length != nullptr)
*length = p - nextArg;
break;
}
@@ -391,7 +391,7 @@ FastOS_UNIX_RealProcess::NextArgument (const char *p,
}
p++;
}
- return NULL;
+ return nullptr;
}
@@ -470,7 +470,7 @@ ForkAndExec(const char *command,
int numArguments = 0;
- char **execArgs = NULL;
+ char **execArgs = nullptr;
if (!IsUsingShell()) {
numArguments = CountArguments(command);
@@ -483,9 +483,9 @@ ForkAndExec(const char *command,
const char *arg = NextArgument(nextArg, &nextArg,
&length);
- if (arg == NULL) {
- // printf("ARG NULL\n");
- execArgs[i] = NULL;
+ if (arg == nullptr) {
+ // printf("ARG nullptr\n");
+ execArgs[i] = nullptr;
break;
}
// printf("argLen = %d\n", length);
@@ -497,7 +497,7 @@ ForkAndExec(const char *command,
PrepareExecVPE(execArgs[0]);
}
}
- if (process == NULL) {
+ if (process == nullptr) {
processStarter->CloseProxyDescs(IsStdinPiped() ? _stdinDes[0] : -1,
IsStdoutPiped() ? _stdoutDes[1] : -1,
IsStderrPiped() ? _stderrDes[1] : -1,
@@ -542,7 +542,7 @@ ForkAndExec(const char *command,
CloseDescriptor(_handshakeDes[0]);
_handshakeDes[0] = -1;
- if (process != NULL) {
+ if (process != nullptr) {
if (!process->GetKeepOpenFilesIfDirectChild()) {
int fdlimit = sysconf(_SC_OPEN_MAX);
// Close everything else
@@ -571,7 +571,7 @@ ForkAndExec(const char *command,
shExecArgs[0] = "sh";
shExecArgs[1] = "-c";
shExecArgs[2] = command;
- shExecArgs[3] = NULL;
+ shExecArgs[3] = nullptr;
execve("/bin/sh",
const_cast<char *const *>
(reinterpret_cast<const char *const *>
@@ -702,9 +702,9 @@ ForkAndExec(const char *command,
rc = true;
}
}
- if (execArgs != NULL) {
+ if (execArgs != nullptr) {
char **arg = execArgs;
- while (*arg != NULL) {
+ while (*arg != nullptr) {
delete [] *arg;
arg++;
}
@@ -795,14 +795,14 @@ FastOS_UNIX_Process (const char *cmdLine, bool pipeStdin,
_stdoutRedirName(),
_stderrRedirName(),
_killed(false),
- _closing(NULL)
+ _closing(nullptr)
{
_descriptor[TYPE_IPC]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
_descriptor[TYPE_IPC]._writeBuffer.reset(new FastOS_RingBuffer(bufferSize));
- if (stdoutListener != NULL)
+ if (stdoutListener != nullptr)
_descriptor[TYPE_STDOUT]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
- if (stderrListener != NULL)
+ if (stderrListener != nullptr)
_descriptor[TYPE_STDERR]._readBuffer.reset(new FastOS_RingBuffer(bufferSize));
_app->ProcessLock();
@@ -865,8 +865,8 @@ bool FastOS_UNIX_Process::CreateInternal (bool useShell)
{
return GetProcessStarter()->CreateProcess(this, useShell,
_pipeStdin,
- _stdoutListener != NULL,
- _stderrListener != NULL);
+ _stdoutListener != nullptr,
+ _stderrListener != nullptr);
}
bool FastOS_UNIX_Process::WriteStdin (const void *data, size_t length)
@@ -875,7 +875,7 @@ bool FastOS_UNIX_Process::WriteStdin (const void *data, size_t length)
DescriptorHandle &desc = GetDescriptorHandle(TYPE_STDIN);
if (desc._fd != -1) {
- if (data == NULL) {
+ if (data == nullptr) {
CloseDescriptor(TYPE_STDIN);
rc = true;
}
@@ -940,7 +940,7 @@ bool FastOS_UNIX_Process::InternalWait (int *returnCode,
bool FastOS_UNIX_Process::Wait (int *returnCode, int timeOutSeconds)
{
- return InternalWait(returnCode, timeOutSeconds, NULL);
+ return InternalWait(returnCode, timeOutSeconds, nullptr);
}
bool FastOS_UNIX_Process::PollWait (int *returnCode, bool *stillRunning)
@@ -1054,10 +1054,10 @@ void FastOS_UNIX_ProcessStarter::WriteInt (int fd, int integer,
void FastOS_UNIX_ProcessStarter::
AddChildProcess (FastOS_UNIX_RealProcess *node)
{
- node->_prev = NULL;
+ node->_prev = nullptr;
node->_next = _processList;
- if (_processList != NULL)
+ if (_processList != nullptr)
_processList->_prev = node;
_processList = node;
}
@@ -1072,11 +1072,11 @@ RemoveChildProcess (FastOS_UNIX_RealProcess *node)
if (node->_next) {
node->_next->_prev = node->_prev;
- node->_next = NULL;
+ node->_next = nullptr;
}
- if (node->_prev != NULL)
- node->_prev = NULL;
+ if (node->_prev != nullptr)
+ node->_prev = nullptr;
}
bool FastOS_UNIX_ProcessStarter::SendFileDescriptor (int fd)
@@ -1112,7 +1112,7 @@ bool FastOS_UNIX_ProcessStarter::SendFileDescriptor (int fd)
msg.msg_accrightslen = sizeof(int);
#endif
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
char dummyData = '\0';
@@ -1149,7 +1149,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoWait ()
FastOS_UNIX_RealProcess *process, *next;
for(process = FastOS_UNIX_ProcessStarter::_processList;
- process != NULL; process = next)
+ process != nullptr; process = next)
{
// Need to do this here since we are deleting entries
@@ -1204,7 +1204,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoDetachProcess ()
FastOS_UNIX_RealProcess *process, *next;
for(process = FastOS_UNIX_ProcessStarter::_processList;
- process != NULL; process = next) {
+ process != nullptr; process = next) {
// Need to do this here since we are deleting entries
next = process->_next;
@@ -1342,7 +1342,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoCreateProcess ()
pid_t processId = -1;
if (process->ForkAndExec(cmdLine,
environmentVariables,
- NULL,
+ nullptr,
this))
{
processId = process->GetProcessID();
@@ -1359,7 +1359,7 @@ void FastOS_UNIX_ProcessStarter::StarterDoCreateProcess ()
if (!rc) delete process;
char **pe = environmentVariables;
- while(*pe != NULL) {
+ while(*pe != nullptr) {
delete [] *pe++;
}
delete [] environmentVariables;
@@ -1415,7 +1415,7 @@ bool FastOS_UNIX_ProcessStarter::CreateSocketPairs ()
FastOS_UNIX_ProcessStarter::FastOS_UNIX_ProcessStarter (FastOS_ApplicationInterface *app)
: _app(app),
- _processList(NULL),
+ _processList(nullptr),
_pid(-1),
_starterSocket(-1),
_mainSocket(-1),
@@ -1503,7 +1503,7 @@ int FastOS_UNIX_ProcessStarter::ReadFileDescriptor ()
msg.msg_accrightslen = sizeof(int);
#endif
- msg.msg_name = NULL;
+ msg.msg_name = nullptr;
msg.msg_namelen = 0;
char dummyData = '\0';
@@ -1521,7 +1521,7 @@ int FastOS_UNIX_ProcessStarter::ReadFileDescriptor ()
// printf("recvmsgrc = %d\n", recvmsgrc);
#ifndef FASTOS_HAVE_ACCRIGHTSLEN
- if ((cmptr = CMSG_FIRSTHDR(&msg)) != NULL &&
+ if ((cmptr = CMSG_FIRSTHDR(&msg)) != nullptr &&
cmptr->cmsg_len == CMSG_LEN(sizeof(int)))
{
if (cmptr->cmsg_level != SOL_SOCKET)
@@ -1594,7 +1594,7 @@ char ** FastOS_UNIX_ProcessStarter::ReceiveEnvironmentVariables ()
else
fillIndex++;
}
- myEnvironment[fillIndex] = NULL;
+ myEnvironment[fillIndex] = nullptr;
return myEnvironment;
}
@@ -1605,7 +1605,7 @@ void FastOS_UNIX_ProcessStarter::SendEnvironmentVariables ()
int numEnvVars = 0;
char **pe = environ;
- while(*pe++ != NULL)
+ while(*pe++ != nullptr)
numEnvVars++;
WriteInt(_mainSocket, numEnvVars);
@@ -1619,7 +1619,7 @@ void FastOS_UNIX_ProcessStarter::SendEnvironmentVariables ()
const char *envString = "";
if (!gotNull) {
envString = *pe++;
- if (envString == NULL) {
+ if (envString == nullptr) {
envString = "";
gotNull = true;
}
@@ -1674,7 +1674,7 @@ FastOS_UNIX_ProcessStarter::
CopyEnvironmentVariables(void)
{
char **env = environ;
- while (*env != NULL)
+ while (*env != nullptr)
env++;
int numEnvVars = env - environ;
char **newEnv = new char *[numEnvVars + 2];
@@ -1682,7 +1682,7 @@ CopyEnvironmentVariables(void)
int fillIdx = 1;
env = environ;
- while (*env != NULL) {
+ while (*env != nullptr) {
size_t len = strlen(*env);
if (len > 0 &&
strncmp(*env, "FASTOS_IPC_PARENT=", 18) != 0) {
@@ -1692,7 +1692,7 @@ CopyEnvironmentVariables(void)
}
env++;
}
- newEnv[fillIdx] = NULL;
+ newEnv[fillIdx] = nullptr;
return newEnv;
}
@@ -1702,7 +1702,7 @@ FastOS_UNIX_ProcessStarter::
FreeEnvironmentVariables(char **env)
{
char **p = env;
- while (*p != NULL) {
+ while (*p != nullptr) {
delete [] *p;
p++;
}
@@ -1729,15 +1729,15 @@ CreateProcess (FastOS_UNIX_Process *process,
FastOS_UNIX_RealProcess *rprocess =
new FastOS_UNIX_RealProcess(process->BuildStreamMask(useShell));
const char *runDir = process->GetRunDir();
- if (runDir != NULL) {
+ if (runDir != nullptr) {
rprocess->SetRunDir(runDir); // Handover
}
const char *stdoutRedirName = process->GetStdoutRedirName();
- if (stdoutRedirName != NULL) {
+ if (stdoutRedirName != nullptr) {
rprocess->SetStdoutRedirName(stdoutRedirName);
}
const char *stderrRedirName = process->GetStderrRedirName();
- if (stderrRedirName != NULL) {
+ if (stderrRedirName != nullptr) {
rprocess->SetStderrRedirName(stderrRedirName);
}
char **env = CopyEnvironmentVariables();
@@ -1786,7 +1786,7 @@ CreateProcess (FastOS_UNIX_Process *process,
SendEnvironmentVariables();
const char *runDir = process->GetRunDir();
- if (runDir != NULL) {
+ if (runDir != nullptr) {
int runDirLength = strlen(runDir) + 1;
WriteInt(_mainSocket, runDirLength);
WriteBytes(_mainSocket, runDir, runDirLength);
@@ -1794,7 +1794,7 @@ CreateProcess (FastOS_UNIX_Process *process,
WriteInt(_mainSocket, 0);
const char *stdoutRedirName = process->GetStdoutRedirName();
- if (stdoutRedirName != NULL) {
+ if (stdoutRedirName != nullptr) {
int stdoutRedirNameLength = strlen(stdoutRedirName) + 1;
WriteInt(_mainSocket, stdoutRedirNameLength);
WriteBytes(_mainSocket, stdoutRedirName, stdoutRedirNameLength);
@@ -1802,7 +1802,7 @@ CreateProcess (FastOS_UNIX_Process *process,
WriteInt(_mainSocket, 0);
const char *stderrRedirName = process->GetStderrRedirName();
- if (stderrRedirName != NULL) {
+ if (stderrRedirName != nullptr) {
int stderrRedirNameLength = strlen(stderrRedirName) + 1;
WriteInt(_mainSocket, stderrRedirNameLength);
WriteBytes(_mainSocket, stderrRedirName, stderrRedirNameLength);
@@ -1866,7 +1866,7 @@ FastOS_UNIX_ProcessStarter::PollReapDirectChildren(void)
FastOS_ProcessInterface *node;
for(node = _app->GetProcessList();
- node != NULL; node = node->_next)
+ node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc =
static_cast<FastOS_UNIX_Process *>(node);
@@ -1896,7 +1896,7 @@ FastOS_UNIX_ProcessStarter::PollReapProxiedChildren(void)
ReadBytes(_mainSocket, &returnCode, sizeof(int));
FastOS_ProcessInterface *node;
- for(node = _app->GetProcessList(); node != NULL; node = node->_next)
+ for(node = _app->GetProcessList(); node != nullptr; node = node->_next)
{
FastOS_UNIX_Process *xproc =
static_cast<FastOS_UNIX_Process *>(node);
@@ -1922,7 +1922,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
FastOS_Time startTime;
startTime.SetNow();
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
*pollStillRunning = true;
for (;;) {
@@ -1935,7 +1935,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
process->_app->ProcessUnlock();
if (process->GetDeathFlag()) {
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
*pollStillRunning = false;
break;
}
@@ -1943,7 +1943,7 @@ FastOS_UNIX_ProcessStarter::Wait(FastOS_UNIX_Process *process,
// printf("wasn't dead yet (%d), sleeping\n",
// process->GetProcessId());
- if (pollStillRunning != NULL)
+ if (pollStillRunning != nullptr)
break;
if ((timeOutSeconds != -1) && !timeOutKillAttempted) {
@@ -2032,9 +2032,9 @@ FastOS_UNIX_Process::DescriptorHandle::CloseHandle()
close(_fd);
_fd = -1;
}
- if (_readBuffer.get() != NULL)
+ if (_readBuffer.get() != nullptr)
_readBuffer->Close();
- if (_writeBuffer.get() != NULL)
+ if (_writeBuffer.get() != nullptr)
_writeBuffer->Close();
}
void
diff --git a/fastos/src/vespa/fastos/unix_process.h b/fastos/src/vespa/fastos/unix_process.h
index ff034b0e581..16614deb1a2 100644
--- a/fastos/src/vespa/fastos/unix_process.h
+++ b/fastos/src/vespa/fastos/unix_process.h
@@ -86,32 +86,32 @@ public:
else if(type == TYPE_STDERR)
return _stderrListener;
- return NULL;
+ return nullptr;
}
void CloseListener (DescriptorType type)
{
if(type == TYPE_STDOUT)
{
- if(_stdoutListener != NULL)
+ if(_stdoutListener != nullptr)
{
- _stdoutListener->OnReceiveData(NULL, 0);
- _stdoutListener = NULL;
+ _stdoutListener->OnReceiveData(nullptr, 0);
+ _stdoutListener = nullptr;
}
}
else if(type == TYPE_STDERR)
{
- if(_stderrListener != NULL)
+ if(_stderrListener != nullptr)
{
- _stderrListener->OnReceiveData(NULL, 0);
- _stderrListener = NULL;
+ _stderrListener->OnReceiveData(nullptr, 0);
+ _stderrListener = nullptr;
}
}
}
FastOS_UNIX_Process (const char *cmdLine, bool pipeStdin = false,
- FastOS_ProcessRedirectListener *stdoutListener = NULL,
- FastOS_ProcessRedirectListener *stderrListener = NULL,
+ FastOS_ProcessRedirectListener *stdoutListener = nullptr,
+ FastOS_ProcessRedirectListener *stderrListener = nullptr,
int bufferSize = 65535);
~FastOS_UNIX_Process ();
bool CreateInternal (bool useShell);
diff --git a/fastos/src/vespa/fastos/unix_socket.cpp b/fastos/src/vespa/fastos/unix_socket.cpp
index 2bdda49c982..ba1d2f50417 100644
--- a/fastos/src/vespa/fastos/unix_socket.cpp
+++ b/fastos/src/vespa/fastos/unix_socket.cpp
@@ -29,7 +29,7 @@ bool FastOS_UNIX_Socket::Shutdown()
bool rc=true;
if (ValidHandle()) {
- if(_socketEvent != NULL) {
+ if(_socketEvent != nullptr) {
EnableWriteEvent(false);
}
rc = (0 == shutdown(_socketHandle, SHUT_WR));
@@ -43,7 +43,7 @@ bool FastOS_UNIX_Socket::SetSoBlocking (bool blockingEnabled)
bool rc=false;
if (CreateIfNoSocketYet()) {
- int flags = fcntl(_socketHandle, F_GETFL, NULL);
+ int flags = fcntl(_socketHandle, F_GETFL, nullptr);
if (flags >= 0) {
if (blockingEnabled) {
diff --git a/fastos/src/vespa/fastos/unix_thread.cpp b/fastos/src/vespa/fastos/unix_thread.cpp
index eca7a472c6d..8ff1913b246 100644
--- a/fastos/src/vespa/fastos/unix_thread.cpp
+++ b/fastos/src/vespa/fastos/unix_thread.cpp
@@ -11,11 +11,11 @@ namespace {
bool FastOS_UNIX_Thread::InitializeClass ()
{
- if (getenv("VESPA_PIN_THREAD_TO_CORE") != NULL) {
+ if (getenv("VESPA_PIN_THREAD_TO_CORE") != nullptr) {
_G_maxNumCpus = std::thread::hardware_concurrency();
fprintf(stderr, "Will pin threads to CPU. Using %ld cores\n", _G_maxNumCpus);
- if (getenv("VESPA_MAX_CORES") != NULL) {
- size_t maxCores = strtoul(getenv("VESPA_MAX_CORES"), NULL, 0);
+ if (getenv("VESPA_MAX_CORES") != nullptr) {
+ size_t maxCores = strtoul(getenv("VESPA_MAX_CORES"), nullptr, 0);
fprintf(stderr, "Will limit to %ld", maxCores);
if (maxCores < _G_maxNumCpus) {
_G_maxNumCpus = maxCores;
@@ -76,7 +76,7 @@ FastOS_UNIX_Thread::~FastOS_UNIX_Thread()
// Wait for thread library cleanup to complete.
if (_handleValid) {
- value = NULL;
+ value = nullptr;
pthread_join(_handle, &value);
}
}
diff --git a/fastos/src/vespa/fastos/unix_time.cpp b/fastos/src/vespa/fastos/unix_time.cpp
index 4b83dcd60f5..c6251f60d03 100644
--- a/fastos/src/vespa/fastos/unix_time.cpp
+++ b/fastos/src/vespa/fastos/unix_time.cpp
@@ -99,6 +99,6 @@ FastOS_UNIX_Time::SetSecs(double secs)
}
void FastOS_UNIX_Time::SetNow() {
- gettimeofday(&_time, NULL);
+ gettimeofday(&_time, nullptr);
}