summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/posix/DomainSocket.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Host/posix/DomainSocket.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/source/Host/posix/DomainSocket.cpp')
-rw-r--r--lldb/source/Host/posix/DomainSocket.cpp141
1 files changed, 64 insertions, 77 deletions
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 9dc147196c0..cb0a1d05750 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -21,113 +21,100 @@ using namespace lldb_private;
#ifdef __ANDROID__
// Android does not have SUN_LEN
#ifndef SUN_LEN
-#define SUN_LEN(ptr) (offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path))
+#define SUN_LEN(ptr) \
+ (offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path))
#endif
#endif // #ifdef __ANDROID__
namespace {
const int kDomain = AF_UNIX;
-const int kType = SOCK_STREAM;
+const int kType = SOCK_STREAM;
-bool SetSockAddr(llvm::StringRef name,
- const size_t name_offset,
- sockaddr_un* saddr_un,
- socklen_t& saddr_un_len)
-{
- if (name.size() + name_offset > sizeof(saddr_un->sun_path))
- return false;
+bool SetSockAddr(llvm::StringRef name, const size_t name_offset,
+ sockaddr_un *saddr_un, socklen_t &saddr_un_len) {
+ if (name.size() + name_offset > sizeof(saddr_un->sun_path))
+ return false;
- memset(saddr_un, 0, sizeof(*saddr_un));
- saddr_un->sun_family = kDomain;
+ memset(saddr_un, 0, sizeof(*saddr_un));
+ saddr_un->sun_family = kDomain;
- memcpy(saddr_un->sun_path + name_offset, name.data(), name.size());
+ memcpy(saddr_un->sun_path + name_offset, name.data(), name.size());
- // For domain sockets we can use SUN_LEN in order to calculate size of
- // sockaddr_un, but for abstract sockets we have to calculate size manually
- // because of leading null symbol.
- if (name_offset == 0)
- saddr_un_len = SUN_LEN(saddr_un);
- else
- saddr_un_len = offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();
+ // For domain sockets we can use SUN_LEN in order to calculate size of
+ // sockaddr_un, but for abstract sockets we have to calculate size manually
+ // because of leading null symbol.
+ if (name_offset == 0)
+ saddr_un_len = SUN_LEN(saddr_un);
+ else
+ saddr_un_len =
+ offsetof(struct sockaddr_un, sun_path) + name_offset + name.size();
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
- saddr_un->sun_len = saddr_un_len;
+ saddr_un->sun_len = saddr_un_len;
#endif
- return true;
+ return true;
}
-
}
DomainSocket::DomainSocket(NativeSocket socket)
- : Socket(socket, ProtocolUnixDomain, true)
-{
-}
+ : Socket(socket, ProtocolUnixDomain, true) {}
DomainSocket::DomainSocket(bool child_processes_inherit, Error &error)
- : DomainSocket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error))
-{
-}
-
-DomainSocket::DomainSocket(SocketProtocol protocol, bool child_processes_inherit, Error &error)
- : Socket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error), protocol, true)
-{
-}
-
-Error
-DomainSocket::Connect(llvm::StringRef name)
-{
- sockaddr_un saddr_un;
- socklen_t saddr_un_len;
- if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
- return Error("Failed to set socket address");
-
- Error error;
- if (::connect(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) < 0)
- SetLastError (error);
+ : DomainSocket(
+ CreateSocket(kDomain, kType, 0, child_processes_inherit, error)) {}
+
+DomainSocket::DomainSocket(SocketProtocol protocol,
+ bool child_processes_inherit, Error &error)
+ : Socket(CreateSocket(kDomain, kType, 0, child_processes_inherit, error),
+ protocol, true) {}
+
+Error DomainSocket::Connect(llvm::StringRef name) {
+ sockaddr_un saddr_un;
+ socklen_t saddr_un_len;
+ if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
+ return Error("Failed to set socket address");
+
+ Error error;
+ if (::connect(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) <
+ 0)
+ SetLastError(error);
- return error;
+ return error;
}
-Error
-DomainSocket::Listen(llvm::StringRef name, int backlog)
-{
- sockaddr_un saddr_un;
- socklen_t saddr_un_len;
- if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
- return Error("Failed to set socket address");
+Error DomainSocket::Listen(llvm::StringRef name, int backlog) {
+ sockaddr_un saddr_un;
+ socklen_t saddr_un_len;
+ if (!SetSockAddr(name, GetNameOffset(), &saddr_un, saddr_un_len))
+ return Error("Failed to set socket address");
- DeleteSocketFile(name);
+ DeleteSocketFile(name);
- Error error;
- if (::bind(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) == 0)
- if (::listen(GetNativeSocket(), backlog) == 0)
- return error;
+ Error error;
+ if (::bind(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) ==
+ 0)
+ if (::listen(GetNativeSocket(), backlog) == 0)
+ return error;
- SetLastError(error);
- return error;
+ SetLastError(error);
+ return error;
}
-Error
-DomainSocket::Accept(llvm::StringRef name, bool child_processes_inherit, Socket *&socket)
-{
- Error error;
- auto conn_fd = AcceptSocket(GetNativeSocket(), nullptr, nullptr, child_processes_inherit, error);
- if (error.Success())
- socket = new DomainSocket(conn_fd);
+Error DomainSocket::Accept(llvm::StringRef name, bool child_processes_inherit,
+ Socket *&socket) {
+ Error error;
+ auto conn_fd = AcceptSocket(GetNativeSocket(), nullptr, nullptr,
+ child_processes_inherit, error);
+ if (error.Success())
+ socket = new DomainSocket(conn_fd);
- return error;
+ return error;
}
-size_t
-DomainSocket::GetNameOffset() const
-{
- return 0;
-}
+size_t DomainSocket::GetNameOffset() const { return 0; }
-void
-DomainSocket::DeleteSocketFile(llvm::StringRef name)
-{
- FileSystem::Unlink(FileSpec{name, true});
+void DomainSocket::DeleteSocketFile(llvm::StringRef name) {
+ FileSystem::Unlink(FileSpec{name, true});
}
OpenPOWER on IntegriCloud