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

Side by Side Diff: util/test/posix/close_multiple.cc

Issue 700143004: C++11: Use type aliases instead of typedefs (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month 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/stdlib/string_number_conversion.cc ('k') | no next file » | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 struct ScopedDIRCloser { 65 struct ScopedDIRCloser {
66 void operator()(DIR* dir) const { 66 void operator()(DIR* dir) const {
67 if (dir) { 67 if (dir) {
68 if (closedir(dir) < 0) { 68 if (closedir(dir) < 0) {
69 PLOG(ERROR) << "closedir"; 69 PLOG(ERROR) << "closedir";
70 } 70 }
71 } 71 }
72 } 72 }
73 }; 73 };
74 74
75 typedef scoped_ptr<DIR, ScopedDIRCloser> ScopedDIR; 75 using ScopedDIR = scoped_ptr<DIR, ScopedDIRCloser>;
76 76
77 // This function implements CloseMultipleNowOrOnExec() using an operating 77 // This function implements CloseMultipleNowOrOnExec() using an operating
78 // system-specific FD directory to determine which file descriptors are open. 78 // system-specific FD directory to determine which file descriptors are open.
79 // This is an advantage over looping over all possible file descriptors, because 79 // This is an advantage over looping over all possible file descriptors, because
80 // no attempt needs to be made to close file descriptors that are not open. 80 // no attempt needs to be made to close file descriptors that are not open.
81 bool CloseMultipleNowOrOnExecUsingFDDir(int fd, int preserve_fd) { 81 bool CloseMultipleNowOrOnExecUsingFDDir(int fd, int preserve_fd) {
82 #if defined(OS_MACOSX) 82 #if defined(OS_MACOSX)
83 const char kFDDir[] = "/dev/fd"; 83 const char kFDDir[] = "/dev/fd";
84 #elif defined(OS_LINUX) 84 #elif defined(OS_LINUX)
85 const char kFDDir[] = "/proc/self/fd"; 85 const char kFDDir[] = "/proc/self/fd";
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 max_fd = std::max(max_fd, getdtablesize()); 148 max_fd = std::max(max_fd, getdtablesize());
149 149
150 for (int entry_fd = fd; entry_fd < max_fd; ++entry_fd) { 150 for (int entry_fd = fd; entry_fd < max_fd; ++entry_fd) {
151 if (entry_fd != preserve_fd) { 151 if (entry_fd != preserve_fd) {
152 CloseNowOrOnExec(entry_fd, true); 152 CloseNowOrOnExec(entry_fd, true);
153 } 153 }
154 } 154 }
155 } 155 }
156 156
157 } // namespace crashpad 157 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/stdlib/string_number_conversion.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698