From 8383b0b503c812e45f2780217b048a19a8946853 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 18 May 2012 20:44:34 +0000 Subject: Replace 0 and NULL pointer constants with nullptr. Also fix an old style cast in secmem.h --- src/entropy/dev_random/dev_random.cpp | 2 +- src/entropy/proc_walk/es_ftw.cpp | 14 +++++++------- src/entropy/unix_procs/es_unix.cpp | 2 +- src/entropy/unix_procs/unix_cmd.cpp | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/entropy') diff --git a/src/entropy/dev_random/dev_random.cpp b/src/entropy/dev_random/dev_random.cpp index d92176ce9..3090f9510 100644 --- a/src/entropy/dev_random/dev_random.cpp +++ b/src/entropy/dev_random/dev_random.cpp @@ -45,7 +45,7 @@ size_t Device_EntropySource::Device_Reader::get(byte out[], size_t length, timeout.tv_sec = (ms_wait_time / 1000); timeout.tv_usec = (ms_wait_time % 1000) * 1000; - if(::select(fd + 1, &read_set, 0, 0, &timeout) < 0) + if(::select(fd + 1, &read_set, nullptr, nullptr, &timeout) < 0) return 0; if(!(FD_ISSET(fd, &read_set))) diff --git a/src/entropy/proc_walk/es_ftw.cpp b/src/entropy/proc_walk/es_ftw.cpp index d65aadfb1..7d72e7752 100644 --- a/src/entropy/proc_walk/es_ftw.cpp +++ b/src/entropy/proc_walk/es_ftw.cpp @@ -42,7 +42,7 @@ class Directory_Walker : public File_Descriptor_Source { public: Directory_Walker(const std::string& root) : - m_cur_dir(std::make_pair(0, "")) + m_cur_dir(std::make_pair(nullptr, "")) { if(DIR* root_dir = ::opendir(root.c_str())) m_cur_dir = std::make_pair(root_dir, root); @@ -75,9 +75,9 @@ std::pair Directory_Walker::get_next_dirent() return std::make_pair(dir, m_cur_dir.second); ::closedir(m_cur_dir.first); - m_cur_dir = std::make_pair(0, ""); + m_cur_dir = std::make_pair(nullptr, ""); - while(!m_dirlist.empty() && m_cur_dir.first == 0) + while(!m_dirlist.empty() && !m_cur_dir.first) { const std::string next_dir_name = m_dirlist[0]; m_dirlist.pop_front(); @@ -87,7 +87,7 @@ std::pair Directory_Walker::get_next_dirent() } } - return std::make_pair(0, ""); // nothing left + return std::make_pair(nullptr, ""); // nothing left } int Directory_Walker::next_fd() @@ -131,9 +131,8 @@ int Directory_Walker::next_fd() /** * FTW_EntropySource Constructor */ -FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p) +FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p), dir(nullptr) { - dir = 0; } /** @@ -142,6 +141,7 @@ FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p) FTW_EntropySource::~FTW_EntropySource() { delete dir; + dir = nullptr; } void FTW_EntropySource::poll(Entropy_Accumulator& accum) @@ -161,7 +161,7 @@ void FTW_EntropySource::poll(Entropy_Accumulator& accum) if(fd == -1) { delete dir; - dir = 0; + dir = nullptr; break; } diff --git a/src/entropy/unix_procs/es_unix.cpp b/src/entropy/unix_procs/es_unix.cpp index 9ec5f7148..f72a691d2 100644 --- a/src/entropy/unix_procs/es_unix.cpp +++ b/src/entropy/unix_procs/es_unix.cpp @@ -68,7 +68,7 @@ void Unix_EntropySource::poll(Entropy_Accumulator& accum) "/etc/passwd", ".", "..", - 0 }; + nullptr }; for(size_t i = 0; stat_targets[i]; i++) { diff --git a/src/entropy/unix_procs/unix_cmd.cpp b/src/entropy/unix_procs/unix_cmd.cpp index 930444075..823da2717 100644 --- a/src/entropy/unix_procs/unix_cmd.cpp +++ b/src/entropy/unix_procs/unix_cmd.cpp @@ -29,10 +29,10 @@ void do_exec(const std::vector& arg_list, { const size_t args = arg_list.size() - 1; - const char* arg1 = (args >= 1) ? arg_list[1].c_str() : 0; - const char* arg2 = (args >= 2) ? arg_list[2].c_str() : 0; - const char* arg3 = (args >= 3) ? arg_list[3].c_str() : 0; - const char* arg4 = (args >= 4) ? arg_list[4].c_str() : 0; + const char* arg1 = (args >= 1) ? arg_list[1].c_str() : nullptr; + const char* arg2 = (args >= 2) ? arg_list[2].c_str() : nullptr; + const char* arg3 = (args >= 3) ? arg_list[3].c_str() : nullptr; + const char* arg4 = (args >= 4) ? arg_list[4].c_str() : nullptr; for(size_t j = 0; j != paths.size(); j++) { @@ -74,7 +74,7 @@ size_t DataSource_Command::read(byte buf[], size_t length) tv.tv_usec = MAX_BLOCK_USECS; ssize_t got = 0; - if(::select(pipe->fd + 1, &set, 0, 0, &tv) == 1) + if(::select(pipe->fd + 1, &set, nullptr, nullptr, &tv) == 1) { if(FD_ISSET(pipe->fd, &set)) got = ::read(pipe->fd, buf, length); @@ -182,7 +182,7 @@ void DataSource_Command::shutdown_pipe() { if(pipe) { - pid_t reaped = waitpid(pipe->pid, 0, WNOHANG); + pid_t reaped = waitpid(pipe->pid, nullptr, WNOHANG); if(reaped == 0) { @@ -191,21 +191,21 @@ void DataSource_Command::shutdown_pipe() struct ::timeval tv; tv.tv_sec = 0; tv.tv_usec = KILL_WAIT; - select(0, 0, 0, 0, &tv); + select(0, nullptr, nullptr, nullptr, &tv); - reaped = ::waitpid(pipe->pid, 0, WNOHANG); + reaped = ::waitpid(pipe->pid, nullptr, WNOHANG); if(reaped == 0) { ::kill(pipe->pid, SIGKILL); do - reaped = ::waitpid(pipe->pid, 0, 0); + reaped = ::waitpid(pipe->pid, nullptr, 0); while(reaped == -1); } } delete pipe; - pipe = 0; + pipe = nullptr; } } @@ -223,7 +223,7 @@ DataSource_Command::DataSource_Command(const std::string& prog_and_args, if(arg_list.size() > 5) throw Invalid_Argument("DataSource_Command: Too many args"); - pipe = 0; + pipe = nullptr; create_pipe(paths); } -- cgit v1.2.3