Permalink
Browse files

Do not compare boost::function with NULL

On some platforms such as FreeBSD 11.12, NULL is
an alias for nullptr. Comparing a boost::function
to nullptr always returns false.

Closes #2097.
  • Loading branch information...
FooBarWidget committed Jul 15, 2018
1 parent 8c1eebe commit 98064360967103030114417de2ea414ceed6bbca
@@ -1,6 +1,7 @@
Release 5.3.4 (Not yet released)
-------------------------------
* Fixes a crash during startup on FreeBSD 11.2 and recent OpenBSD versions due to C++11 compatibility issues in the code. Closes GH-2097.
* Updates Boost to version 1.67.0.
@@ -642,7 +642,7 @@ class AdminPanelConnector {
if (appPool == NULL) {
throw RuntimeException("appPool must be non-NULL");
}
if (configGetter == NULL) {
if (configGetter.empty()) {
throw RuntimeException("configGetter must be non-NULL");
}
server.initialize();
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2011-2017 Phusion Holding B.V.
* Copyright (c) 2011-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -366,7 +366,7 @@ void
Group::callAbortLongRunningConnectionsCallback(const ProcessPtr &process) {
Pool::AbortLongRunningConnectionsCallback callback =
getPool()->abortLongRunningConnectionsCallback;
if (callback != NULL) {
if (callback) {
callback(process);
}
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2011-2017 Phusion Holding B.V.
* Copyright (c) 2011-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -95,7 +95,7 @@ Pool::prepareForShutdown() {
ScopedLock lock(syncher);
assert(lifeStatus == ALIVE);
lifeStatus = PREPARED_FOR_SHUTDOWN;
if (abortLongRunningConnectionsCallback != NULL) {
if (abortLongRunningConnectionsCallback) {
vector<ProcessPtr> processes = getProcesses(false);
foreach (ProcessPtr process, processes) {
// Ensure that the process is not immediately respawned.
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2011-2017 Phusion Holding B.V.
* Copyright (c) 2011-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -53,7 +53,6 @@ using namespace std;
class HandshakePrepare;
typedef boost::function<void (const char *data, unsigned int size)> OutputHandler;
typedef Passenger::ApplicationPool2::Options AppPoolOptions;
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2011-2017 Phusion Holding B.V.
* Copyright (c) 2011-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -112,7 +112,7 @@ class BackgroundIOCapturer {
boost::lock_guard<boost::mutex> l(dataSyncher);
stopped = true;
}
if (endReachedCallback != NULL) {
if (endReachedCallback) {
endReachedCallback();
}
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2012-2017 Phusion Holding B.V.
* Copyright (c) 2012-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -133,8 +133,10 @@ class PipeWatcher: public boost::enable_shared_from_this<PipeWatcher> {
if (f == NULL) {
LoggingKit::logAppOutput(appGroupName, pid, name, line.data(), line.size(), appLogFile);
} else {
fwrite(line.data(), 1, line.size(), f);
fwrite("\n", 1, 2, f);
size_t ret = fwrite(line.data(), 1, line.size(), f);
(void) ret; // Avoid compiler warning
ret = fwrite("\n", 1, 2, f);
(void) ret; // Avoid compiler warning
fflush(f);
}
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2015-2017 Phusion Holding B.V.
* Copyright (c) 2015-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -460,7 +460,7 @@ apiServerMakeInternalHttpRequestThreadMain(ApiServerInternalHttpRequest<Server,
}
}
if (req.bodyProcessor != NULL) {
if (req.bodyProcessor) {
req.bodyProcessor(req, resp, io);
} else {
resp.body = io.readAll(&req.timeout);
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2017 Phusion Holding B.V.
* Copyright (c) 2017-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -207,7 +207,7 @@ class Store {
StringKeyTable<Entry>::ConstIterator it(entries);
while (*it != NULL) {
const Entry &entry = it.getValue();
if (entry.schemaEntry->inspectFilter == NULL) {
if (entry.schemaEntry->inspectFilter.empty()) {
it.next();
continue;
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2010-2017 Phusion Holding B.V.
* Copyright (c) 2010-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -224,7 +224,7 @@ class SafeLibev {
}
void run(const Callback &callback) {
assert(callback != NULL);
assert(callback);
if (onEventLoopThread()) {
callback();
} else {
@@ -233,7 +233,7 @@ class SafeLibev {
}
void runSync(const Callback &callback) {
assert(callback != NULL);
assert(callback);
boost::unique_lock<boost::mutex> l(syncher);
bool done = false;
commands.push_back(Command(nextCommandId,
@@ -248,13 +248,13 @@ class SafeLibev {
/** Run a callback after a certain timeout. */
void runAfter(unsigned int timeout, const Callback &callback) {
assert(callback != NULL);
assert(callback);
ev_once(loop, -1, 0, timeout / 1000.0, timeoutHandler, new Callback(callback));
}
/** Thread-safe version of runAfter(). */
void runAfterTS(unsigned int timeout, const Callback &callback) {
assert(callback != NULL);
assert(callback);
if (onEventLoopThread()) {
runAfter(timeout, callback);
} else {
@@ -263,7 +263,7 @@ class SafeLibev {
}
unsigned int runLater(const Callback &callback) {
assert(callback != NULL);
assert(callback);
unsigned int result;
{
boost::unique_lock<boost::mutex> l(syncher);
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2014-2017 Phusion Holding B.V.
* Copyright (c) 2014-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -478,7 +478,7 @@ class Channel: public boost::noncopyable {
void callConsumedCallback() {
unsigned int bytesConsumed = this->bytesConsumed;
this->bytesConsumed = 0;
if (consumedCallback != NULL) {
if (consumedCallback) {
consumedCallback(this, bytesConsumed);
}
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2014-2017 Phusion Holding B.V.
* Copyright (c) 2014-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -528,14 +528,14 @@ class FileBufferedChannel: protected Channel {
}
void callBuffersFlushedCallback() {
if (buffersFlushedCallback != NULL) {
if (buffersFlushedCallback) {
FBC_DEBUG("Calling buffersFlushedCallback");
buffersFlushedCallback(this);
}
}
void callDataFlushedCallback() {
if (dataFlushedCallback != NULL) {
if (dataFlushedCallback) {
FBC_DEBUG("Calling dataFlushedCallback");
dataFlushedCallback(this);
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2014-2017 Phusion Holding B.V.
* Copyright (c) 2014-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -86,7 +86,7 @@ class FileBufferedFdSinkChannel: protected FileBufferedChannel {
}
void callOnError(int errcode) {
if (errorCallback != NULL) {
if (errorCallback) {
errorCallback(this, errcode);
}
}
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2014-2017 Phusion Holding B.V.
* Copyright (c) 2014-2018 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
@@ -558,7 +558,7 @@ class BaseServer: public HooksImpl {
SKS_NOTICE("Shutdown finished");
serverState = FINISHED_SHUTDOWN;
if (shutdownFinishCallback != NULL) {
if (shutdownFinishCallback) {
shutdownFinishCallback(static_cast<DerivedServer *>(this));
}
}

0 comments on commit 9806436

Please sign in to comment.