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

Unified Diff: runtime/bin/socket_macos.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/utils_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index 81b2d023cd625d6e7271d0e7da2bdb5501ff2b30..2e2dbb650a1669559151eae34d956bbb4cf32888 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -48,7 +48,10 @@ intptr_t Socket::Create(RawAddr addr) {
fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0));
if (fd < 0) {
- Log::PrintErr("Error Create: %s\n", strerror(errno));
+ const int kBufferSize = 1024;
+ char error_message[kBufferSize];
+ strerror_r(errno, error_message, kBufferSize);
+ Log::PrintErr("Error Create: %s\n", error_message);
return -1;
}
@@ -122,7 +125,10 @@ intptr_t Socket::GetPort(intptr_t fd) {
getsockname(fd,
&raw.addr,
&size))) {
- Log::PrintErr("Error getsockname: %s\n", strerror(errno));
+ const int kBufferSize = 1024;
+ char error_message[kBufferSize];
+ strerror_r(errno, error_message, kBufferSize);
+ Log::PrintErr("Error getsockname: %s\n", error_message);
return 0;
}
return SocketAddress::GetAddrPort(&raw);
@@ -137,7 +143,10 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) {
getpeername(fd,
&raw.addr,
&size))) {
- Log::PrintErr("Error getpeername: %s\n", strerror(errno));
+ const int kBufferSize = 1024;
+ char error_message[kBufferSize];
+ strerror_r(errno, error_message, kBufferSize);
+ Log::PrintErr("Error getpeername: %s\n", error_message);
return false;
}
const void* src;
@@ -150,7 +159,10 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) {
src,
host,
INET_ADDRSTRLEN) == NULL) {
- Log::PrintErr("Error inet_ntop: %s\n", strerror(errno));
+ const int kBufferSize = 1024;
+ char error_message[kBufferSize];
+ strerror_r(errno, error_message, kBufferSize);
+ Log::PrintErr("Error inet_ntop: %s\n", error_message);
return false;
}
*port = SocketAddress::GetAddrPort(&raw);
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/utils_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698