Skip to content

Commit ccdcc76

Browse files
committed
Switch from NULL to nullptr
1 parent f03fdc6 commit ccdcc76

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

commands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ static bool check_if_file_is_encrypted (const std::string& filename)
488488

489489
static bool is_git_file_mode (const std::string& mode)
490490
{
491-
return (std::strtoul(mode.c_str(), NULL, 8) & 0170000) == 0100000;
491+
return (std::strtoul(mode.c_str(), nullptr, 8) & 0170000) == 0100000;
492492
}
493493

494494
static void get_encrypted_files (std::vector<std::string>& files, const char* key_name)
@@ -509,8 +509,8 @@ static void get_encrypted_files (std::vector<std::string>& files, const char* ke
509509
ls_files.spawn(ls_files_command);
510510

511511
Coprocess check_attr;
512-
std::ostream* check_attr_stdin = NULL;
513-
std::istream* check_attr_stdout = NULL;
512+
std::ostream* check_attr_stdin = nullptr;
513+
std::istream* check_attr_stdout = nullptr;
514514
if (git_version() >= make_version(1, 8, 5)) {
515515
// In Git 1.8.5 (released 27 Nov 2013) and higher, we use a single `git check-attr` process
516516
// to get the attributes of all files at once. In prior versions, we have to fork and exec

coprocess-unix.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int execvp (const std::string& file, const std::vector<std::string>& args
4141
for (std::vector<std::string>::const_iterator arg(args.begin()); arg != args.end(); ++arg) {
4242
args_c_str.push_back(arg->c_str());
4343
}
44-
args_c_str.push_back(NULL);
44+
args_c_str.push_back(nullptr);
4545
return execvp(file.c_str(), const_cast<char**>(&args_c_str[0]));
4646
}
4747

@@ -50,10 +50,10 @@ Coprocess::Coprocess ()
5050
pid = -1;
5151
stdin_pipe_reader = -1;
5252
stdin_pipe_writer = -1;
53-
stdin_pipe_ostream = NULL;
53+
stdin_pipe_ostream = nullptr;
5454
stdout_pipe_reader = -1;
5555
stdout_pipe_writer = -1;
56-
stdout_pipe_istream = NULL;
56+
stdout_pipe_istream = nullptr;
5757
}
5858

5959
Coprocess::~Coprocess ()
@@ -79,7 +79,7 @@ std::ostream* Coprocess::stdin_pipe ()
7979
void Coprocess::close_stdin ()
8080
{
8181
delete stdin_pipe_ostream;
82-
stdin_pipe_ostream = NULL;
82+
stdin_pipe_ostream = nullptr;
8383
if (stdin_pipe_writer != -1) {
8484
close(stdin_pipe_writer);
8585
stdin_pipe_writer = -1;
@@ -107,7 +107,7 @@ std::istream* Coprocess::stdout_pipe ()
107107
void Coprocess::close_stdout ()
108108
{
109109
delete stdout_pipe_istream;
110-
stdout_pipe_istream = NULL;
110+
stdout_pipe_istream = nullptr;
111111
if (stdout_pipe_writer != -1) {
112112
close(stdout_pipe_writer);
113113
stdout_pipe_writer = -1;

coprocess-win32.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ static HANDLE spawn_command (const std::vector<std::string>& command, HANDLE std
9696

9797
std::string cmdline(format_cmdline(command));
9898

99-
if (!CreateProcessA(NULL, // application name (NULL to use command line)
99+
if (!CreateProcessA(nullptr, // application name (nullptr to use command line)
100100
const_cast<char*>(cmdline.c_str()),
101-
NULL, // process security attributes
102-
NULL, // primary thread security attributes
101+
nullptr, // process security attributes
102+
nullptr, // primary thread security attributes
103103
TRUE, // handles are inherited
104104
0, // creation flags
105-
NULL, // use parent's environment
106-
NULL, // use parent's current directory
105+
nullptr, // use parent's environment
106+
nullptr, // use parent's current directory
107107
&start_info,
108108
&proc_info)) {
109109
throw System_error("CreateProcess", cmdline, GetLastError());
@@ -117,13 +117,13 @@ static HANDLE spawn_command (const std::vector<std::string>& command, HANDLE std
117117

118118
Coprocess::Coprocess ()
119119
{
120-
proc_handle = NULL;
121-
stdin_pipe_reader = NULL;
122-
stdin_pipe_writer = NULL;
123-
stdin_pipe_ostream = NULL;
124-
stdout_pipe_reader = NULL;
125-
stdout_pipe_writer = NULL;
126-
stdout_pipe_istream = NULL;
120+
proc_handle = nullptr;
121+
stdin_pipe_reader = nullptr;
122+
stdin_pipe_writer = nullptr;
123+
stdin_pipe_ostream = nullptr;
124+
stdout_pipe_reader = nullptr;
125+
stdout_pipe_writer = nullptr;
126+
stdout_pipe_istream = nullptr;
127127
}
128128

129129
Coprocess::~Coprocess ()
@@ -143,7 +143,7 @@ std::ostream* Coprocess::stdin_pipe ()
143143
// Set the bInheritHandle flag so pipe handles are inherited.
144144
sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
145145
sec_attr.bInheritHandle = TRUE;
146-
sec_attr.lpSecurityDescriptor = NULL;
146+
sec_attr.lpSecurityDescriptor = nullptr;
147147

148148
// Create a pipe for the child process's STDIN.
149149
if (!CreatePipe(&stdin_pipe_reader, &stdin_pipe_writer, &sec_attr, 0)) {
@@ -163,14 +163,14 @@ std::ostream* Coprocess::stdin_pipe ()
163163
void Coprocess::close_stdin ()
164164
{
165165
delete stdin_pipe_ostream;
166-
stdin_pipe_ostream = NULL;
166+
stdin_pipe_ostream = nullptr;
167167
if (stdin_pipe_writer) {
168168
CloseHandle(stdin_pipe_writer);
169-
stdin_pipe_writer = NULL;
169+
stdin_pipe_writer = nullptr;
170170
}
171171
if (stdin_pipe_reader) {
172172
CloseHandle(stdin_pipe_reader);
173-
stdin_pipe_reader = NULL;
173+
stdin_pipe_reader = nullptr;
174174
}
175175
}
176176

@@ -182,7 +182,7 @@ std::istream* Coprocess::stdout_pipe ()
182182
// Set the bInheritHandle flag so pipe handles are inherited.
183183
sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
184184
sec_attr.bInheritHandle = TRUE;
185-
sec_attr.lpSecurityDescriptor = NULL;
185+
sec_attr.lpSecurityDescriptor = nullptr;
186186

187187
// Create a pipe for the child process's STDOUT.
188188
if (!CreatePipe(&stdout_pipe_reader, &stdout_pipe_writer, &sec_attr, 0)) {
@@ -202,27 +202,27 @@ std::istream* Coprocess::stdout_pipe ()
202202
void Coprocess::close_stdout ()
203203
{
204204
delete stdout_pipe_istream;
205-
stdout_pipe_istream = NULL;
205+
stdout_pipe_istream = nullptr;
206206
if (stdout_pipe_writer) {
207207
CloseHandle(stdout_pipe_writer);
208-
stdout_pipe_writer = NULL;
208+
stdout_pipe_writer = nullptr;
209209
}
210210
if (stdout_pipe_reader) {
211211
CloseHandle(stdout_pipe_reader);
212-
stdout_pipe_reader = NULL;
212+
stdout_pipe_reader = nullptr;
213213
}
214214
}
215215

216216
void Coprocess::spawn (const std::vector<std::string>& args)
217217
{
218-
proc_handle = spawn_command(args, stdin_pipe_reader, stdout_pipe_writer, NULL);
218+
proc_handle = spawn_command(args, stdin_pipe_reader, stdout_pipe_writer, nullptr);
219219
if (stdin_pipe_reader) {
220220
CloseHandle(stdin_pipe_reader);
221-
stdin_pipe_reader = NULL;
221+
stdin_pipe_reader = nullptr;
222222
}
223223
if (stdout_pipe_writer) {
224224
CloseHandle(stdout_pipe_writer);
225-
stdout_pipe_writer = NULL;
225+
stdout_pipe_writer = nullptr;
226226
}
227227
}
228228

@@ -243,7 +243,7 @@ int Coprocess::wait ()
243243
size_t Coprocess::write_stdin (void* handle, const void* buf, size_t count)
244244
{
245245
DWORD bytes_written;
246-
if (!WriteFile(static_cast<Coprocess*>(handle)->stdin_pipe_writer, buf, count, &bytes_written, NULL)) {
246+
if (!WriteFile(static_cast<Coprocess*>(handle)->stdin_pipe_writer, buf, count, &bytes_written, nullptr)) {
247247
throw System_error("WriteFile", "", GetLastError());
248248
}
249249
return bytes_written;
@@ -257,7 +257,7 @@ size_t Coprocess::read_stdout (void* handle, void* buf, size_t count)
257257
// fails with ERROR_BROKEN_PIPE.
258258
DWORD bytes_read;
259259
do {
260-
if (!ReadFile(static_cast<Coprocess*>(handle)->stdout_pipe_reader, buf, count, &bytes_read, NULL)) {
260+
if (!ReadFile(static_cast<Coprocess*>(handle)->stdout_pipe_reader, buf, count, &bytes_read, nullptr)) {
261261
const DWORD read_error = GetLastError();
262262
if (read_error != ERROR_BROKEN_PIPE) {
263263
throw System_error("ReadFile", "", read_error);

crypto-openssl-11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Hmac_sha1_state::Hmac_sha1_state (const unsigned char* key, size_t key_len)
8383
{
8484

8585
impl->ctx = HMAC_CTX_new();
86-
HMAC_Init_ex(impl->ctx, key, key_len, EVP_sha1(), NULL);
86+
HMAC_Init_ex(impl->ctx, key, key_len, EVP_sha1(), nullptr);
8787
}
8888

8989
Hmac_sha1_state::~Hmac_sha1_state ()

util-unix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ std::string our_exe_path ()
132132
return argv0;
133133
} else if (std::strchr(argv0, '/')) {
134134
// argv[0] contains / => it a relative path that should be resolved
135-
char* resolved_path_p = realpath(argv0, NULL);
135+
char* resolved_path_p = realpath(argv0, nullptr);
136136
std::string resolved_path(resolved_path_p);
137137
free(resolved_path_p);
138138
return resolved_path;
@@ -149,7 +149,7 @@ int exit_status (int wait_status)
149149

150150
void touch_file (const std::string& filename)
151151
{
152-
if (utimes(filename.c_str(), NULL) == -1 && errno != ENOENT) {
152+
if (utimes(filename.c_str(), nullptr) == -1 && errno != ENOENT) {
153153
throw System_error("utimes", filename, errno);
154154
}
155155
}

util-win32.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ std::string System_error::message () const
4646
LPTSTR error_message;
4747
FormatMessageA(
4848
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
49-
NULL,
49+
nullptr,
5050
error,
5151
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
5252
reinterpret_cast<LPTSTR>(&error_message),
5353
0,
54-
NULL);
54+
nullptr);
5555
mesg += error_message;
5656
LocalFree(error_message);
5757
}
@@ -100,7 +100,7 @@ void mkdir_parent (const std::string& path)
100100
std::string prefix(path.substr(0, slash));
101101
if (GetFileAttributes(prefix.c_str()) == INVALID_FILE_ATTRIBUTES) {
102102
// prefix does not exist, so try to create it
103-
if (!CreateDirectory(prefix.c_str(), NULL)) {
103+
if (!CreateDirectory(prefix.c_str(), nullptr)) {
104104
throw System_error("CreateDirectory", prefix, GetLastError());
105105
}
106106
}
@@ -114,7 +114,7 @@ std::string our_exe_path ()
114114
std::vector<char> buffer(128);
115115
size_t len;
116116

117-
while ((len = GetModuleFileNameA(NULL, &buffer[0], buffer.size())) == buffer.size()) {
117+
while ((len = GetModuleFileNameA(nullptr, &buffer[0], buffer.size())) == buffer.size()) {
118118
// buffer may have been truncated - grow and try again
119119
buffer.resize(buffer.size() * 2);
120120
}
@@ -132,7 +132,7 @@ int exit_status (int status)
132132

133133
void touch_file (const std::string& filename)
134134
{
135-
HANDLE fh = CreateFileA(filename.c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
135+
HANDLE fh = CreateFileA(filename.c_str(), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
136136
if (fh == INVALID_HANDLE_VALUE) {
137137
DWORD error = GetLastError();
138138
if (error == ERROR_FILE_NOT_FOUND) {
@@ -146,7 +146,7 @@ void touch_file (const std::string& filename)
146146
FILETIME file_time;
147147
SystemTimeToFileTime(&system_time, &file_time);
148148

149-
if (!SetFileTime(fh, NULL, NULL, &file_time)) {
149+
if (!SetFileTime(fh, nullptr, nullptr, &file_time)) {
150150
DWORD error = GetLastError();
151151
CloseHandle(fh);
152152
throw System_error("SetFileTime", filename, error);

0 commit comments

Comments
 (0)