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

Side by Side Diff: runtime/bin/file_linux.cc

Issue 22634003: Replaced strerror() calls with threadsafe strerror_r() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/file_macos.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 29 matching lines...) Expand all
40 Close(); 40 Close();
41 } 41 }
42 delete handle_; 42 delete handle_;
43 } 43 }
44 44
45 45
46 void File::Close() { 46 void File::Close() {
47 ASSERT(handle_->fd() >= 0); 47 ASSERT(handle_->fd() >= 0);
48 int err = TEMP_FAILURE_RETRY(close(handle_->fd())); 48 int err = TEMP_FAILURE_RETRY(close(handle_->fd()));
49 if (err != 0) { 49 if (err != 0) {
50 Log::PrintErr("%s\n", strerror(errno)); 50 const int kBufferSize = 1024;
51 char error_buf[kBufferSize];
52 Log::PrintErr("%s\n", strerror_r(errno, error_buf, kBufferSize));
51 } 53 }
52 handle_->set_fd(kClosedFd); 54 handle_->set_fd(kClosedFd);
53 } 55 }
54 56
55 57
56 bool File::IsClosed() { 58 bool File::IsClosed() {
57 return handle_->fd() == kClosedFd; 59 return handle_->fd() == kClosedFd;
58 } 60 }
59 61
60 62
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 const char* File::StringEscapedPathSeparator() { 303 const char* File::StringEscapedPathSeparator() {
302 return "/"; 304 return "/";
303 } 305 }
304 306
305 307
306 File::StdioHandleType File::GetStdioHandleType(int fd) { 308 File::StdioHandleType File::GetStdioHandleType(int fd) {
307 ASSERT(0 <= fd && fd <= 2); 309 ASSERT(0 <= fd && fd <= 2);
308 struct stat buf; 310 struct stat buf;
309 int result = fstat(fd, &buf); 311 int result = fstat(fd, &buf);
310 if (result == -1) { 312 if (result == -1) {
311 FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno)); 313 const int kBufferSize = 1024;
314 char error_buf[kBufferSize];
315 FATAL2("Failed stat on file descriptor %d: %s", fd,
316 strerror_r(errno, error_buf, kBufferSize));
312 } 317 }
313 if (S_ISCHR(buf.st_mode)) return kTerminal; 318 if (S_ISCHR(buf.st_mode)) return kTerminal;
314 if (S_ISFIFO(buf.st_mode)) return kPipe; 319 if (S_ISFIFO(buf.st_mode)) return kPipe;
315 if (S_ISSOCK(buf.st_mode)) return kSocket; 320 if (S_ISSOCK(buf.st_mode)) return kSocket;
316 if (S_ISREG(buf.st_mode)) return kFile; 321 if (S_ISREG(buf.st_mode)) return kFile;
317 return kOther; 322 return kOther;
318 } 323 }
319 324
320 325
321 File::Type File::GetType(const char* pathname, bool follow_links) { 326 File::Type File::GetType(const char* pathname, bool follow_links) {
(...skipping 22 matching lines...) Expand all
344 return (file_1_info.st_ino == file_2_info.st_ino && 349 return (file_1_info.st_ino == file_2_info.st_ino &&
345 file_1_info.st_dev == file_2_info.st_dev) ? 350 file_1_info.st_dev == file_2_info.st_dev) ?
346 File::kIdentical : 351 File::kIdentical :
347 File::kDifferent; 352 File::kDifferent;
348 } 353 }
349 354
350 } // namespace bin 355 } // namespace bin
351 } // namespace dart 356 } // namespace dart
352 357
353 #endif // defined(TARGET_OS_LINUX) 358 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/file_android.cc ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698