Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: util/test/multiprocess.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/test/mac/mach_multiprocess.cc ('k') | util/test/multiprocess_exec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 base::ScopedFD pipe_c2p_read; // child to parent 46 base::ScopedFD pipe_c2p_read; // child to parent
47 base::ScopedFD pipe_c2p_write; // child to parent 47 base::ScopedFD pipe_c2p_write; // child to parent
48 base::ScopedFD pipe_p2c_read; // parent to child 48 base::ScopedFD pipe_p2c_read; // parent to child
49 base::ScopedFD pipe_p2c_write; // parent to child 49 base::ScopedFD pipe_p2c_write; // parent to child
50 pid_t child_pid; // valid only in parent 50 pid_t child_pid; // valid only in parent
51 }; 51 };
52 52
53 } // namespace internal 53 } // namespace internal
54 54
55 Multiprocess::Multiprocess() 55 Multiprocess::Multiprocess()
56 : info_(NULL), 56 : info_(nullptr),
57 code_(EXIT_SUCCESS), 57 code_(EXIT_SUCCESS),
58 reason_(kTerminationNormal) { 58 reason_(kTerminationNormal) {
59 } 59 }
60 60
61 void Multiprocess::Run() { 61 void Multiprocess::Run() {
62 ASSERT_EQ(NULL, info_); 62 ASSERT_EQ(nullptr, info_);
63 scoped_ptr<internal::MultiprocessInfo> info(new internal::MultiprocessInfo); 63 scoped_ptr<internal::MultiprocessInfo> info(new internal::MultiprocessInfo);
64 base::AutoReset<internal::MultiprocessInfo*> reset_info(&info_, info.get()); 64 base::AutoReset<internal::MultiprocessInfo*> reset_info(&info_, info.get());
65 65
66 ASSERT_NO_FATAL_FAILURE(PreFork()); 66 ASSERT_NO_FATAL_FAILURE(PreFork());
67 67
68 pid_t pid = fork(); 68 pid_t pid = fork();
69 ASSERT_GE(pid, 0) << ErrnoMessage("fork"); 69 ASSERT_GE(pid, 0) << ErrnoMessage("fork");
70 70
71 if (pid > 0) { 71 if (pid > 0) {
72 info_->child_pid = pid; 72 info_->child_pid = pid;
73 73
74 RunParent(); 74 RunParent();
75 75
76 // Waiting for the child happens here instead of in RunParent() because even 76 // Waiting for the child happens here instead of in RunParent() because even
77 // if RunParent() returns early due to a gtest fatal assertion failure, the 77 // if RunParent() returns early due to a gtest fatal assertion failure, the
78 // child should still be reaped. 78 // child should still be reaped.
79 79
80 // This will make the parent hang up on the child as much as would be 80 // This will make the parent hang up on the child as much as would be
81 // visible from the child’s perspective. The child’s side of the pipe will 81 // visible from the child’s perspective. The child’s side of the pipe will
82 // be broken, the child’s remote port will become a dead name, and an 82 // be broken, the child’s remote port will become a dead name, and an
83 // attempt by the child to look up the service will fail. If this weren’t 83 // attempt by the child to look up the service will fail. If this weren’t
84 // done, the child might hang while waiting for a parent that has already 84 // done, the child might hang while waiting for a parent that has already
85 // triggered a fatal assertion failure to do something. 85 // triggered a fatal assertion failure to do something.
86 info.reset(); 86 info.reset();
87 info_ = NULL; 87 info_ = nullptr;
88 88
89 int status; 89 int status;
90 pid_t wait_pid = HANDLE_EINTR(waitpid(pid, &status, 0)); 90 pid_t wait_pid = HANDLE_EINTR(waitpid(pid, &status, 0));
91 ASSERT_EQ(pid, wait_pid) << ErrnoMessage("waitpid"); 91 ASSERT_EQ(pid, wait_pid) << ErrnoMessage("waitpid");
92 92
93 TerminationReason reason; 93 TerminationReason reason;
94 int code; 94 int code;
95 std::string message; 95 std::string message;
96 if (WIFEXITED(status)) { 96 if (WIFEXITED(status)) {
97 reason = kTerminationNormal; 97 reason = kTerminationNormal;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (testing::Test::HasFailure()) { 209 if (testing::Test::HasFailure()) {
210 // Trigger the ScopedForbidReturn destructor. 210 // Trigger the ScopedForbidReturn destructor.
211 return; 211 return;
212 } 212 }
213 213
214 exit(0); 214 exit(0);
215 } 215 }
216 216
217 } // namespace test 217 } // namespace test
218 } // namespace crashpad 218 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/test/mac/mach_multiprocess.cc ('k') | util/test/multiprocess_exec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698