aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-07-22 10:55:35 +0200
committerMax Kellermann <max@duempel.org>2015-07-22 10:55:57 +0200
commit7de0a621e3a33b25a62d875670380d33dbd977f5 (patch)
tree229db794983b0ae959b53fb434877c6ca9a9d815
parent3441ea9844a9f91c8d2476be546133610763b4fe (diff)
downloadmpd-7de0a621e3a33b25a62d875670380d33dbd977f5.tar.gz
mpd-7de0a621e3a33b25a62d875670380d33dbd977f5.tar.xz
mpd-7de0a621e3a33b25a62d875670380d33dbd977f5.zip
net/StaticSocketAddress: replace cast operator with GetAddress()
The implicit cast operator can be very dangerous.
-rw-r--r--src/event/ServerSocket.cxx4
-rw-r--r--src/net/StaticSocketAddress.hxx4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx
index 69e62f897..552efb0a3 100644
--- a/src/event/ServerSocket.cxx
+++ b/src/event/ServerSocket.cxx
@@ -159,7 +159,7 @@ OneServerSocket::Accept()
StaticSocketAddress peer_address;
size_t peer_address_length = sizeof(peer_address);
int peer_fd =
- accept_cloexec_nonblock(Get(), peer_address,
+ accept_cloexec_nonblock(Get(), peer_address.GetAddress(),
&peer_address_length);
if (peer_fd < 0) {
const SocketErrorMessage msg;
@@ -306,7 +306,7 @@ ServerSocket::AddFD(int fd, Error &error)
StaticSocketAddress address;
socklen_t address_length = sizeof(address);
- if (getsockname(fd, address,
+ if (getsockname(fd, address.GetAddress(),
&address_length) < 0) {
SetSocketError(error);
error.AddPrefix("Failed to get socket address: ");
diff --git a/src/net/StaticSocketAddress.hxx b/src/net/StaticSocketAddress.hxx
index 2d92d36b5..0a780f6f6 100644
--- a/src/net/StaticSocketAddress.hxx
+++ b/src/net/StaticSocketAddress.hxx
@@ -56,11 +56,11 @@ public:
size);
}
- operator struct sockaddr *() {
+ struct sockaddr *GetAddress() {
return reinterpret_cast<struct sockaddr *>(&address);
}
- operator const struct sockaddr *() const {
+ const struct sockaddr *GetAddress() const {
return reinterpret_cast<const struct sockaddr *>(&address);
}