Remove unused code

This commit is contained in:
topjohnwu 2023-05-06 01:48:47 -07:00
parent 726ffdcd98
commit d364554425
2 changed files with 2 additions and 21 deletions

View File

@ -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) {

View File

@ -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<int> recv_fds(int sockfd);
int recv_fd(int sockfd);