Commit d7ea6b71 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Use nullptr rather than 0 when initializing pointers

Summary:
Because we do this in a few places, and `nullptr` makes it far clearer what the intention is.
Note that with `-Wzero-as-null-pointer-constant` under GCC, doing `std::function<void()> f = {}` initializes `f` with a `0` rather than `nullptr`, triggering the warning, so I've enabled it there as well.
It is not currently possible to actually enable `-Wzero-as-null-pointer-constant`, because GCC 5 reports conversions resulting from a default value as occuring at the call-site rather than at the location where the parameter is defined, and the default allocator in libstdc++ is not clean for this particular warning -_-...

Reviewed By: yfeldblum

Differential Revision: D6046746

fbshipit-source-id: 6135bb20a503c861838575cf973324d74d75ca69
parent dca6f3ea
......@@ -310,7 +310,7 @@ inline uint32_t hsieh_hash32_buf(const void* buf, size_t len) {
uint32_t tmp;
size_t rem;
if (len <= 0 || buf == 0) {
if (len <= 0 || buf == nullptr) {
return 0;
}
......
......@@ -74,7 +74,7 @@ class PackedSyncPtr {
* (We are avoiding a constructor to ensure gcc allows us to put
* this class in packed structures.)
*/
void init(T* initialPtr = 0, uint16_t initialExtra = 0) {
void init(T* initialPtr = nullptr, uint16_t initialExtra = 0) {
auto intPtr = reinterpret_cast<uintptr_t>(initialPtr);
CHECK(!(intPtr >> 48));
data_.init(intPtr);
......
......@@ -181,7 +181,7 @@ const PrettySuffix kPrettyTimeSuffixes[] = {
{ "ns", 1e-9L },
{ "ps", 1e-12L },
{ "s ", 0 },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyBytesMetricSuffixes[] = {
......@@ -190,7 +190,7 @@ const PrettySuffix kPrettyBytesMetricSuffixes[] = {
{ "MB", 1e6L },
{ "kB", 1e3L },
{ "B ", 0L },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyBytesBinarySuffixes[] = {
......@@ -199,7 +199,7 @@ const PrettySuffix kPrettyBytesBinarySuffixes[] = {
{ "MB", int64_t(1) << 20 },
{ "kB", int64_t(1) << 10 },
{ "B ", 0L },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyBytesBinaryIECSuffixes[] = {
......@@ -208,7 +208,7 @@ const PrettySuffix kPrettyBytesBinaryIECSuffixes[] = {
{ "MiB", int64_t(1) << 20 },
{ "KiB", int64_t(1) << 10 },
{ "B ", 0L },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyUnitsMetricSuffixes[] = {
......@@ -217,7 +217,7 @@ const PrettySuffix kPrettyUnitsMetricSuffixes[] = {
{ "M", 1e6L },
{ "k", 1e3L },
{ " ", 0 },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyUnitsBinarySuffixes[] = {
......@@ -226,7 +226,7 @@ const PrettySuffix kPrettyUnitsBinarySuffixes[] = {
{ "M", int64_t(1) << 20 },
{ "k", int64_t(1) << 10 },
{ " ", 0 },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettyUnitsBinaryIECSuffixes[] = {
......@@ -235,7 +235,7 @@ const PrettySuffix kPrettyUnitsBinaryIECSuffixes[] = {
{ "Mi", int64_t(1) << 20 },
{ "Ki", int64_t(1) << 10 },
{ " ", 0 },
{ 0, 0 },
{ nullptr, 0 },
};
const PrettySuffix kPrettySISuffixes[] = {
......@@ -260,7 +260,7 @@ const PrettySuffix kPrettySISuffixes[] = {
{ "z", 1e-21L },
{ "y", 1e-24L },
{ " ", 0 },
{ 0, 0}
{ nullptr, 0}
};
const PrettySuffix* const kPrettySuffixes[PRETTY_NUM_TYPES] = {
......
......@@ -97,7 +97,8 @@ class FiberImpl {
void deactivate() {
#if BOOST_VERSION >= 106100
auto transfer = boost::context::detail::jump_fcontext(mainContext_, 0);
auto transfer =
boost::context::detail::jump_fcontext(mainContext_, nullptr);
mainContext_ = transfer.fctx;
auto context = reinterpret_cast<intptr_t>(transfer.data);
#elif BOOST_VERSION >= 105600
......@@ -105,9 +106,9 @@ class FiberImpl {
boost::context::jump_fcontext(&fiberContext_, mainContext_, 0);
#elif BOOST_VERSION >= 105200
auto context =
boost::context::jump_fcontext(fiberContext_, &mainContext_, 0);
boost::context::jump_fcontext(fiberContext_, &mainContext_, nullptr);
#else
auto context = jump_fcontext(&fiberContext_, &mainContext_, 0);
auto context = jump_fcontext(&fiberContext_, &mainContext_, nullptr);
#endif
DCHECK_EQ(this, reinterpret_cast<FiberImpl*>(context));
}
......
......@@ -315,7 +315,7 @@ void DoTimingBig(int seed)
for (int i=0; i<NUMBUF; ++i)
{
free(buf[i]);
buf[i] = 0;
buf[i] = nullptr;
}
}
#undef NUMBUF
......
......@@ -305,7 +305,7 @@ void DoTimingBig(int seed)
for (int i=0; i<NUMBUF; ++i)
{
free(buf[i]);
buf[i] = 0;
buf[i] = nullptr;
}
}
#undef NUMBUF
......
......@@ -44,7 +44,7 @@ const int maxBMElements = int(FLAGS_numBMElements * LF); // hit our target LF.
static int64_t nowInUsec() {
timeval tv;
gettimeofday(&tv, 0);
gettimeofday(&tv, nullptr);
return int64_t(tv.tv_sec) * 1000 * 1000 + tv.tv_usec;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment