Skip to content

Commit

Permalink
Making use of nullptr coherent
Browse files Browse the repository at this point in the history
This patch replaces the remaining uses of 0 instead of nullptr
  • Loading branch information
Thomas Heller committed Jun 17, 2016
1 parent 8bbce17 commit d3858f9
Show file tree
Hide file tree
Showing 212 changed files with 307 additions and 300 deletions.
2 changes: 1 addition & 1 deletion examples/compute/cuda/data_copy.cu
Expand Up @@ -15,7 +15,7 @@

int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
2 changes: 1 addition & 1 deletion examples/compute/cuda/hello_compute.cu
Expand Up @@ -17,7 +17,7 @@

int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
2 changes: 1 addition & 1 deletion examples/compute/cuda/partitioned_vector.cu
Expand Up @@ -27,7 +27,7 @@ HPX_REGISTER_PARTITIONED_VECTOR(int, target_vector);
///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
6 changes: 3 additions & 3 deletions examples/quickstart/init_globally.cpp
Expand Up @@ -73,7 +73,7 @@ char** __argv = *_NSGetArgv();
struct manage_global_runtime
{
manage_global_runtime()
: running_(false), rts_(0)
: running_(false), rts_(nullptr)
{
#if defined(HPX_WINDOWS)
hpx::detail::init_winsocket();
Expand Down Expand Up @@ -106,7 +106,7 @@ struct manage_global_runtime
// notify hpx_main above to tear down the runtime
{
std::lock_guard<hpx::lcos::local::spinlock> lk(mtx_);
rts_ = 0; // reset pointer
rts_ = nullptr; // reset pointer
}

cond_.notify_one(); // signal exit
Expand Down Expand Up @@ -145,7 +145,7 @@ struct manage_global_runtime
// Now, wait for destructor to be called.
{
std::unique_lock<hpx::lcos::local::spinlock> lk(mtx_);
if (rts_ != 0)
if (rts_ != nullptr)
cond_.wait(lk);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/partitioned_vector_spmd_foreach.cpp
Expand Up @@ -114,7 +114,7 @@ struct partitioned_vector_view
///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/shared_mutex.cpp
Expand Up @@ -38,7 +38,7 @@ int main()
[&ready, &stm, i]
{
boost::random::mt19937 urng(
static_cast<boost::uint32_t>(std::time(0)));
static_cast<boost::uint32_t>(std::time(nullptr)));
boost::random::uniform_int_distribution<int> dist(1, 1000);

while (!ready) { /*** wait... ***/ }
Expand All @@ -65,7 +65,7 @@ int main()
[&ready, &stm, k, i]
{
boost::random::mt19937 urng(
static_cast<boost::uint32_t>(std::time(0)));
static_cast<boost::uint32_t>(std::time(nullptr)));
boost::random::uniform_int_distribution<int> dist(1, 1000);

while (!ready) { /*** wait... ***/ }
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/zerocopy_rdma.cpp
Expand Up @@ -31,7 +31,7 @@ class pointer_allocator
typedef std::ptrdiff_t difference_type;

pointer_allocator() HPX_NOEXCEPT
: pointer_(0), size_(0)
: pointer_(nullptr), size_(0)
{
}

Expand Down
2 changes: 1 addition & 1 deletion examples/sheneos/sheneos_compare.cpp
Expand Up @@ -358,7 +358,7 @@ int hpx_main(boost::program_options::variables_map& vm)

std::size_t seed = vm["seed"].as<std::size_t>();
if (!seed)
seed = std::size_t(std::time(0));
seed = std::size_t(std::time(nullptr));

std::cout << "Seed: " << seed << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion examples/sheneos/sheneos_test.cpp
Expand Up @@ -324,7 +324,7 @@ int hpx_main(boost::program_options::variables_map& vm)

std::size_t seed = vm["seed"].as<std::size_t>();
if (!seed)
seed = std::size_t(std::time(0));
seed = std::size_t(std::time(nullptr));

std::cout << "Seed: " << seed << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion examples/startup_shutdown/server/startup_shutdown.hpp
Expand Up @@ -16,7 +16,7 @@ namespace startup_shutdown { namespace server
public:
// constructor: initialize accumulator value
startup_shutdown_component()
: arg_(0)
: arg_(nullptr)
{}

///////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions examples/transpose/transpose_block.cpp
Expand Up @@ -33,7 +33,7 @@ struct sub_block

sub_block()
: size_(0)
, data_(0)
, data_(nullptr)
, mode_(reference)
{}

Expand All @@ -56,15 +56,15 @@ struct sub_block
, data_(other.data_)
, mode_(other.mode_)
{
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }
}

sub_block & operator=(sub_block && other)
{
size_ = other.size_;
data_ = other.data_;
mode_ = other.mode_;
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }

return *this;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/transpose/transpose_block_numa.cpp
Expand Up @@ -45,7 +45,7 @@ struct sub_block

sub_block()
: size_(0)
, data_(0)
, data_(nullptr)
, mode_(reference)
{}

Expand All @@ -68,15 +68,15 @@ struct sub_block
, data_(other.data_)
, mode_(other.mode_)
{
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }
}

sub_block & operator=(sub_block && other)
{
size_ = other.size_;
data_ = other.data_;
mode_ = other.mode_;
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }

return *this;
}
Expand Down
Expand Up @@ -97,7 +97,7 @@ namespace hpx { namespace components { namespace server

{
std::vector<char> data = f.get();
serialization::input_archive archive(data, data.size(), 0);
serialization::input_archive archive(data, data.size(), nullptr);
archive >> ptr;
}

Expand Down
Expand Up @@ -517,7 +517,7 @@ namespace hpx

bool is_at_end() const
{
return data_ == 0 ||
return data_ == nullptr ||
this->base_type::base_reference() == data_->partitions_.end();
}

Expand Down Expand Up @@ -550,7 +550,7 @@ namespace hpx

bool is_at_end() const
{
return data_ == 0 ||
return data_ == nullptr ||
this->base_type::base_reference() == data_->partitions_.end();
}

Expand Down
2 changes: 1 addition & 1 deletion hpx/components/process/util/posix/executor.hpp
Expand Up @@ -25,7 +25,7 @@ namespace hpx { namespace components { namespace process { namespace posix {

struct executor
{
executor() : exe(0), cmd_line(0), env(0) {}
executor() : exe(nullptr), cmd_line(nullptr), env(nullptr) {}

struct call_on_fork_setup
{
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/run_exe.hpp
Expand Up @@ -30,14 +30,14 @@ class run_exe_ : public initializer_base
public:
run_exe_()
{
cmd_line_[0] = cmd_line_[1] = 0;
cmd_line_[0] = cmd_line_[1] = nullptr;
}

explicit run_exe_(const std::string &s)
: s_(s)
{
cmd_line_[0] = const_cast<char*>(s_.c_str());
cmd_line_[1] = 0;
cmd_line_[1] = nullptr;
}

template <class PosixExecutor>
Expand All @@ -63,7 +63,7 @@ class run_exe_ : public initializer_base
ar & s_;

cmd_line_[0] = const_cast<char*>(s_.c_str());
cmd_line_[1] = 0;
cmd_line_[1] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/set_args.hpp
Expand Up @@ -30,7 +30,7 @@ class set_args_ : public initializer_base
set_args_()
{
args_.resize(1);
args_[0] = 0;
args_[0] = nullptr;
}

explicit set_args_(const Range &args)
Expand All @@ -42,7 +42,7 @@ class set_args_ : public initializer_base
string_args_[i] = args[i];
args_[i] = const_cast<char*>(string_args_[i].c_str());
}
args_[args.size()] = 0;
args_[args.size()] = nullptr;
}

template <class PosixExecutor>
Expand Down Expand Up @@ -72,7 +72,7 @@ class set_args_ : public initializer_base
{
args_[i] = const_cast<char*>(string_args_[i].c_str());
}
args_[string_args_.size()] = 0;
args_[string_args_.size()] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
Expand Up @@ -57,7 +57,7 @@ class set_cmd_line : public initializer_base
std::size_t i = 0;
for (std::string const& s : args_)
cmd_line_[i++] = const_cast<char*>(s.c_str());
cmd_line_[i] = 0;
cmd_line_[i] = nullptr;
}

friend class hpx::serialization::access;
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/set_env.hpp
Expand Up @@ -30,7 +30,7 @@ class set_env_ : public initializer_base
set_env_()
{
env_.resize(1);
env_[0] = 0;
env_[0] = nullptr;
}

explicit set_env_(const Range &envs)
Expand All @@ -42,7 +42,7 @@ class set_env_ : public initializer_base
string_env_[i] = envs[i];
env_[i] = const_cast<char*>(string_env_[i].c_str());
}
env_[envs.size()] = 0;
env_[envs.size()] = nullptr;
}

template <class PosixExecutor>
Expand Down Expand Up @@ -70,7 +70,7 @@ class set_env_ : public initializer_base
{
env_[i] = const_cast<char*>(string_env_[i].c_str());
}
env_[string_env_.size()] = 0;
env_[string_env_.size()] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
2 changes: 1 addition & 1 deletion hpx/compute/host/block_allocator.hpp
Expand Up @@ -116,7 +116,7 @@ namespace hpx { namespace compute { namespace host
// topo.allocate(). The pointer hint may be used to provide locality of
// reference: the allocator, if supported by the implementation, will
// attempt to allocate the new memory block as close as possible to hint.
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0)
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = nullptr)
{
return reinterpret_cast<pointer>(
hpx::threads::get_topology().allocate(n * sizeof(T)));
Expand Down
2 changes: 1 addition & 1 deletion hpx/compute/traits/allocator_traits.hpp
Expand Up @@ -231,7 +231,7 @@ namespace hpx { namespace compute { namespace traits
HPX_HOST_DEVICE
static void bulk_destroy(Allocator& alloc, T* p, size_type count) HPX_NOEXCEPT
{
if (p != 0) detail::call_bulk_destroy(alloc, p, count);
if (p != nullptr) detail::call_bulk_destroy(alloc, p, count);
}
};
}}}
Expand Down
10 changes: 5 additions & 5 deletions hpx/hpx_start_impl.hpp
Expand Up @@ -215,7 +215,7 @@ namespace hpx
options_description desc_commandline(
std::string("Usage: ") + HPX_APPLICATION_STRING + " [options]");

char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), 0 };
char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), nullptr };

return start(static_cast<hpx_main_type>(::hpx_main), desc_commandline,
1, dummy_argv, cfg, startup_function_type(),
Expand All @@ -238,9 +238,9 @@ namespace hpx
options_description desc_commandline(
"Usage: " + app_name + " [options]");

if (argc == 0 || argv == 0)
if (argc == 0 || argv == nullptr)
{
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), 0 };
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), nullptr };
return start(desc_commandline, 1, dummy_argv, mode);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ namespace hpx
main_f = util::bind(detail::init_helper, util::placeholders::_1, f);
std::vector<std::string> cfg;

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return start(main_f, desc_commandline, argc, argv, cfg,
startup_function_type(), shutdown_function_type(), mode);
Expand All @@ -306,7 +306,7 @@ namespace hpx
util::function_nonser<int(boost::program_options::variables_map& vm)>
main_f = util::bind(detail::init_helper, util::placeholders::_1, f);

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return start(main_f, desc_commandline, argc, argv, cfg,
startup_function_type(), shutdown_function_type(), mode);
Expand Down
4 changes: 2 additions & 2 deletions hpx/lcos/future_wait.hpp
Expand Up @@ -133,7 +133,7 @@ namespace hpx { namespace lcos
f_(std::move(rhs.f_)),
success_counter_(rhs.success_counter_)
{
rhs.success_counter_ = 0;
rhs.success_counter_ = nullptr;
}

wait_each& operator= (wait_each && rhs)
Expand All @@ -144,7 +144,7 @@ namespace hpx { namespace lcos
rhs.ready_count_ = 0;
f_ = std::move(rhs.f_);
success_counter_ = rhs.success_counter_;
rhs.success_counter_ = 0;
rhs.success_counter_ = nullptr;
}
return *this;
}
Expand Down
2 changes: 1 addition & 1 deletion hpx/lcos/local/composable_guard.hpp
Expand Up @@ -60,7 +60,7 @@ namespace hpx { namespace lcos { namespace local
public:
detail::guard_atomic task;

guard() : task((detail::guard_task*)0) {}
guard() : task(nullptr) {}
~guard() {
detail::free(task.load());
}
Expand Down
2 changes: 1 addition & 1 deletion hpx/parallel/util/numa_allocator.hpp
Expand Up @@ -73,7 +73,7 @@ namespace hpx { namespace parallel { namespace util

// memory allocation
pointer allocate(size_type cnt,
typename std::allocator<void>::const_pointer = 0)
typename std::allocator<void>::const_pointer = nullptr)
{
// allocate memory
pointer p = reinterpret_cast<pointer>(topo_.allocate(cnt * sizeof(T)));
Expand Down
2 changes: 1 addition & 1 deletion hpx/plugins/parcelport/mpi/header.hpp
Expand Up @@ -123,7 +123,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi
{
if(data_[pos_piggy_back_flag])
return &data_[pos_piggy_back_data];
return 0;
return nullptr;
}

private:
Expand Down

0 comments on commit d3858f9

Please sign in to comment.