| OLD | NEW |
| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 int dir_fd = dirfd(dir); | 96 int dir_fd = dirfd(dir); |
| 97 if (dir_fd == -1) { | 97 if (dir_fd == -1) { |
| 98 PLOG(WARNING) << "dirfd"; | 98 PLOG(WARNING) << "dirfd"; |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 | 101 |
| 102 dirent entry; | 102 dirent entry; |
| 103 dirent* result; | 103 dirent* result; |
| 104 int rv; | 104 int rv; |
| 105 while ((rv = readdir_r(dir, &entry, &result)) == 0 && result != NULL) { | 105 while ((rv = readdir_r(dir, &entry, &result)) == 0 && result != nullptr) { |
| 106 const char* entry_name = &(*result->d_name); | 106 const char* entry_name = &(*result->d_name); |
| 107 if (strcmp(entry_name, ".") == 0 || strcmp(entry_name, "..") == 0) { | 107 if (strcmp(entry_name, ".") == 0 || strcmp(entry_name, "..") == 0) { |
| 108 continue; | 108 continue; |
| 109 } | 109 } |
| 110 | 110 |
| 111 char* end; | 111 char* end; |
| 112 long entry_fd_long = strtol(entry_name, &end, 10); | 112 long entry_fd_long = strtol(entry_name, &end, 10); |
| 113 if (entry_name[0] == '\0' || *end) { | 113 if (entry_name[0] == '\0' || *end) { |
| 114 LOG(ERROR) << "unexpected entry " << entry_name; | 114 LOG(ERROR) << "unexpected entry " << entry_name; |
| 115 return false; | 115 return false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |