diff --git a/commands.cpp b/commands.cpp index 866eb81..5ac0b47 100644 --- a/commands.cpp +++ b/commands.cpp @@ -488,7 +488,7 @@ static bool check_if_file_is_encrypted (const std::string& filename) static bool is_git_file_mode (const std::string& mode) { - return (std::strtoul(mode.c_str(), NULL, 8) & 0170000) == 0100000; + return (std::strtoul(mode.c_str(), nullptr, 8) & 0170000) == 0100000; } static void get_encrypted_files (std::vector& files, const char* key_name) @@ -509,8 +509,8 @@ static void get_encrypted_files (std::vector& files, const char* ke ls_files.spawn(ls_files_command); Coprocess check_attr; - std::ostream* check_attr_stdin = NULL; - std::istream* check_attr_stdout = NULL; + std::ostream* check_attr_stdin = nullptr; + std::istream* check_attr_stdout = nullptr; if (git_version() >= make_version(1, 8, 5)) { // In Git 1.8.5 (released 27 Nov 2013) and higher, we use a single `git check-attr` process // to get the attributes of all files at once. In prior versions, we have to fork and exec diff --git a/coprocess-unix.cpp b/coprocess-unix.cpp index f9577e5..45be332 100644 --- a/coprocess-unix.cpp +++ b/coprocess-unix.cpp @@ -41,7 +41,7 @@ static int execvp (const std::string& file, const std::vector& args for (std::vector::const_iterator arg(args.begin()); arg != args.end(); ++arg) { args_c_str.push_back(arg->c_str()); } - args_c_str.push_back(NULL); + args_c_str.push_back(nullptr); return execvp(file.c_str(), const_cast(&args_c_str[0])); } @@ -50,10 +50,10 @@ Coprocess::Coprocess () pid = -1; stdin_pipe_reader = -1; stdin_pipe_writer = -1; - stdin_pipe_ostream = NULL; + stdin_pipe_ostream = nullptr; stdout_pipe_reader = -1; stdout_pipe_writer = -1; - stdout_pipe_istream = NULL; + stdout_pipe_istream = nullptr; } Coprocess::~Coprocess () @@ -79,7 +79,7 @@ std::ostream* Coprocess::stdin_pipe () void Coprocess::close_stdin () { delete stdin_pipe_ostream; - stdin_pipe_ostream = NULL; + stdin_pipe_ostream = nullptr; if (stdin_pipe_writer != -1) { close(stdin_pipe_writer); stdin_pipe_writer = -1; @@ -107,7 +107,7 @@ std::istream* Coprocess::stdout_pipe () void Coprocess::close_stdout () { delete stdout_pipe_istream; - stdout_pipe_istream = NULL; + stdout_pipe_istream = nullptr; if (stdout_pipe_writer != -1) { close(stdout_pipe_writer); stdout_pipe_writer = -1; diff --git a/coprocess-win32.cpp b/coprocess-win32.cpp index 46e21d0..556c873 100644 --- a/coprocess-win32.cpp +++ b/coprocess-win32.cpp @@ -96,14 +96,14 @@ static HANDLE spawn_command (const std::vector& command, HANDLE std std::string cmdline(format_cmdline(command)); - if (!CreateProcessA(NULL, // application name (NULL to use command line) + if (!CreateProcessA(nullptr, // application name (nullptr to use command line) const_cast(cmdline.c_str()), - NULL, // process security attributes - NULL, // primary thread security attributes + nullptr, // process security attributes + nullptr, // primary thread security attributes TRUE, // handles are inherited 0, // creation flags - NULL, // use parent's environment - NULL, // use parent's current directory + nullptr, // use parent's environment + nullptr, // use parent's current directory &start_info, &proc_info)) { throw System_error("CreateProcess", cmdline, GetLastError()); @@ -117,13 +117,13 @@ static HANDLE spawn_command (const std::vector& command, HANDLE std Coprocess::Coprocess () { - proc_handle = NULL; - stdin_pipe_reader = NULL; - stdin_pipe_writer = NULL; - stdin_pipe_ostream = NULL; - stdout_pipe_reader = NULL; - stdout_pipe_writer = NULL; - stdout_pipe_istream = NULL; + proc_handle = nullptr; + stdin_pipe_reader = nullptr; + stdin_pipe_writer = nullptr; + stdin_pipe_ostream = nullptr; + stdout_pipe_reader = nullptr; + stdout_pipe_writer = nullptr; + stdout_pipe_istream = nullptr; } Coprocess::~Coprocess () @@ -143,7 +143,7 @@ std::ostream* Coprocess::stdin_pipe () // Set the bInheritHandle flag so pipe handles are inherited. sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES); sec_attr.bInheritHandle = TRUE; - sec_attr.lpSecurityDescriptor = NULL; + sec_attr.lpSecurityDescriptor = nullptr; // Create a pipe for the child process's STDIN. if (!CreatePipe(&stdin_pipe_reader, &stdin_pipe_writer, &sec_attr, 0)) { @@ -163,14 +163,14 @@ std::ostream* Coprocess::stdin_pipe () void Coprocess::close_stdin () { delete stdin_pipe_ostream; - stdin_pipe_ostream = NULL; + stdin_pipe_ostream = nullptr; if (stdin_pipe_writer) { CloseHandle(stdin_pipe_writer); - stdin_pipe_writer = NULL; + stdin_pipe_writer = nullptr; } if (stdin_pipe_reader) { CloseHandle(stdin_pipe_reader); - stdin_pipe_reader = NULL; + stdin_pipe_reader = nullptr; } } @@ -182,7 +182,7 @@ std::istream* Coprocess::stdout_pipe () // Set the bInheritHandle flag so pipe handles are inherited. sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES); sec_attr.bInheritHandle = TRUE; - sec_attr.lpSecurityDescriptor = NULL; + sec_attr.lpSecurityDescriptor = nullptr; // Create a pipe for the child process's STDOUT. if (!CreatePipe(&stdout_pipe_reader, &stdout_pipe_writer, &sec_attr, 0)) { @@ -202,27 +202,27 @@ std::istream* Coprocess::stdout_pipe () void Coprocess::close_stdout () { delete stdout_pipe_istream; - stdout_pipe_istream = NULL; + stdout_pipe_istream = nullptr; if (stdout_pipe_writer) { CloseHandle(stdout_pipe_writer); - stdout_pipe_writer = NULL; + stdout_pipe_writer = nullptr; } if (stdout_pipe_reader) { CloseHandle(stdout_pipe_reader); - stdout_pipe_reader = NULL; + stdout_pipe_reader = nullptr; } } void Coprocess::spawn (const std::vector& args) { - proc_handle = spawn_command(args, stdin_pipe_reader, stdout_pipe_writer, NULL); + proc_handle = spawn_command(args, stdin_pipe_reader, stdout_pipe_writer, nullptr); if (stdin_pipe_reader) { CloseHandle(stdin_pipe_reader); - stdin_pipe_reader = NULL; + stdin_pipe_reader = nullptr; } if (stdout_pipe_writer) { CloseHandle(stdout_pipe_writer); - stdout_pipe_writer = NULL; + stdout_pipe_writer = nullptr; } } @@ -243,7 +243,7 @@ int Coprocess::wait () size_t Coprocess::write_stdin (void* handle, const void* buf, size_t count) { DWORD bytes_written; - if (!WriteFile(static_cast(handle)->stdin_pipe_writer, buf, count, &bytes_written, NULL)) { + if (!WriteFile(static_cast(handle)->stdin_pipe_writer, buf, count, &bytes_written, nullptr)) { throw System_error("WriteFile", "", GetLastError()); } return bytes_written; @@ -257,7 +257,7 @@ size_t Coprocess::read_stdout (void* handle, void* buf, size_t count) // fails with ERROR_BROKEN_PIPE. DWORD bytes_read; do { - if (!ReadFile(static_cast(handle)->stdout_pipe_reader, buf, count, &bytes_read, NULL)) { + if (!ReadFile(static_cast(handle)->stdout_pipe_reader, buf, count, &bytes_read, nullptr)) { const DWORD read_error = GetLastError(); if (read_error != ERROR_BROKEN_PIPE) { throw System_error("ReadFile", "", read_error); diff --git a/crypto-openssl-11.cpp b/crypto-openssl-11.cpp index ad87b7d..adf03bb 100644 --- a/crypto-openssl-11.cpp +++ b/crypto-openssl-11.cpp @@ -83,7 +83,7 @@ Hmac_sha1_state::Hmac_sha1_state (const unsigned char* key, size_t key_len) { impl->ctx = HMAC_CTX_new(); - HMAC_Init_ex(impl->ctx, key, key_len, EVP_sha1(), NULL); + HMAC_Init_ex(impl->ctx, key, key_len, EVP_sha1(), nullptr); } Hmac_sha1_state::~Hmac_sha1_state () diff --git a/util-unix.cpp b/util-unix.cpp index 1f739ac..3f23d44 100644 --- a/util-unix.cpp +++ b/util-unix.cpp @@ -132,7 +132,7 @@ std::string our_exe_path () return argv0; } else if (std::strchr(argv0, '/')) { // argv[0] contains / => it a relative path that should be resolved - char* resolved_path_p = realpath(argv0, NULL); + char* resolved_path_p = realpath(argv0, nullptr); std::string resolved_path(resolved_path_p); free(resolved_path_p); return resolved_path; @@ -149,7 +149,7 @@ int exit_status (int wait_status) void touch_file (const std::string& filename) { - if (utimes(filename.c_str(), NULL) == -1 && errno != ENOENT) { + if (utimes(filename.c_str(), nullptr) == -1 && errno != ENOENT) { throw System_error("utimes", filename, errno); } } diff --git a/util-win32.cpp b/util-win32.cpp index 445d185..4c47a2d 100644 --- a/util-win32.cpp +++ b/util-win32.cpp @@ -46,12 +46,12 @@ std::string System_error::message () const LPTSTR error_message; FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&error_message), 0, - NULL); + nullptr); mesg += error_message; LocalFree(error_message); } @@ -100,7 +100,7 @@ void mkdir_parent (const std::string& path) std::string prefix(path.substr(0, slash)); if (GetFileAttributes(prefix.c_str()) == INVALID_FILE_ATTRIBUTES) { // prefix does not exist, so try to create it - if (!CreateDirectory(prefix.c_str(), NULL)) { + if (!CreateDirectory(prefix.c_str(), nullptr)) { throw System_error("CreateDirectory", prefix, GetLastError()); } } @@ -114,7 +114,7 @@ std::string our_exe_path () std::vector buffer(128); size_t len; - while ((len = GetModuleFileNameA(NULL, &buffer[0], buffer.size())) == buffer.size()) { + while ((len = GetModuleFileNameA(nullptr, &buffer[0], buffer.size())) == buffer.size()) { // buffer may have been truncated - grow and try again buffer.resize(buffer.size() * 2); } @@ -132,7 +132,7 @@ int exit_status (int status) void touch_file (const std::string& filename) { - HANDLE fh = CreateFileA(filename.c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + HANDLE fh = CreateFileA(filename.c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (fh == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); if (error == ERROR_FILE_NOT_FOUND) { @@ -146,7 +146,7 @@ void touch_file (const std::string& filename) FILETIME file_time; SystemTimeToFileTime(&system_time, &file_time); - if (!SetFileTime(fh, NULL, NULL, &file_time)) { + if (!SetFileTime(fh, nullptr, nullptr, &file_time)) { DWORD error = GetLastError(); CloseHandle(fh); throw System_error("SetFileTime", filename, error);