diff --git a/native/src/core/socket.cpp b/native/src/core/socket.cpp index afa306960..57f70553b 100644 --- a/native/src/core/socket.cpp +++ b/native/src/core/socket.cpp @@ -6,20 +6,6 @@ using namespace std; -static size_t socket_len(sockaddr_un *sun) { - if (sun->sun_path[0]) - return sizeof(sa_family_t) + strlen(sun->sun_path) + 1; - else - return sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1; -} - -socklen_t setup_sockaddr(sockaddr_un *sun, const char *name) { - memset(sun, 0, sizeof(*sun)); - sun->sun_family = AF_UNIX; - strcpy(sun->sun_path + 1, name); - return socket_len(sun); -} - bool get_client_cred(int fd, sock_cred *cred) { socklen_t len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, cred, &len) != 0) @@ -142,10 +128,7 @@ int read_int(int fd) { } int read_int_be(int fd) { - uint32_t val; - if (xxread(fd, &val, sizeof(val)) != sizeof(val)) - return -1; - return ntohl(val); + return ntohl(read_int(fd)); } void write_int(int fd, int val) { @@ -154,8 +137,7 @@ void write_int(int fd, int val) { } void write_int_be(int fd, int val) { - uint32_t nl = htonl(val); - xwrite(fd, &nl, sizeof(nl)); + write_int(fd, htonl(val)); } bool read_string(int fd, std::string &str) { diff --git a/native/src/include/socket.hpp b/native/src/include/socket.hpp index 149391fd6..486300028 100644 --- a/native/src/include/socket.hpp +++ b/native/src/include/socket.hpp @@ -10,7 +10,6 @@ struct sock_cred : public ucred { std::string context; }; -socklen_t setup_sockaddr(sockaddr_un *sun, const char *name); bool get_client_cred(int fd, sock_cred *cred); std::vector recv_fds(int sockfd); int recv_fd(int sockfd);