Merge pull request #8143 from yuwata/drop-unused-func
Drop several unused functions
This commit is contained in:
commit
b8e2400586
|
@ -225,49 +225,6 @@ int readlink_and_make_absolute(const char *p, char **r) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int readlink_and_canonicalize(const char *p, const char *root, char **ret) {
|
||||
char *t, *s;
|
||||
int r;
|
||||
|
||||
assert(p);
|
||||
assert(ret);
|
||||
|
||||
r = readlink_and_make_absolute(p, &t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = chase_symlinks(t, root, 0, &s);
|
||||
if (r < 0)
|
||||
/* If we can't follow up, then let's return the original string, slightly cleaned up. */
|
||||
*ret = path_kill_slashes(t);
|
||||
else {
|
||||
*ret = s;
|
||||
free(t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int readlink_and_make_absolute_root(const char *root, const char *path, char **ret) {
|
||||
_cleanup_free_ char *target = NULL, *t = NULL;
|
||||
const char *full;
|
||||
int r;
|
||||
|
||||
full = prefix_roota(root, path);
|
||||
r = readlink_malloc(full, &target);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
t = file_in_same_dir(path, target);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = t;
|
||||
t = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid) {
|
||||
assert(path);
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ int readlinkat_malloc(int fd, const char *p, char **ret);
|
|||
int readlink_malloc(const char *p, char **r);
|
||||
int readlink_value(const char *p, char **ret);
|
||||
int readlink_and_make_absolute(const char *p, char **r);
|
||||
int readlink_and_canonicalize(const char *p, const char *root, char **r);
|
||||
int readlink_and_make_absolute_root(const char *root, const char *path, char **ret);
|
||||
|
||||
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
|
|
|
@ -758,19 +758,6 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int getnameinfo_pretty(int fd, char **ret) {
|
||||
union sockaddr_union sa;
|
||||
socklen_t salen = sizeof(sa);
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(ret);
|
||||
|
||||
if (getsockname(fd, &sa.sa, &salen) < 0)
|
||||
return -errno;
|
||||
|
||||
return socknameinfo_pretty(&sa, salen, ret);
|
||||
}
|
||||
|
||||
int socket_address_unlink(SocketAddress *a) {
|
||||
assert(a);
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@ int getpeername_pretty(int fd, bool include_port, char **ret);
|
|||
int getsockname_pretty(int fd, char **ret);
|
||||
|
||||
int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
|
||||
int getnameinfo_pretty(int fd, char **ret);
|
||||
|
||||
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
|
||||
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
|
||||
|
|
|
@ -146,7 +146,7 @@ static void test_copy_tree(void) {
|
|||
assert_se((f = strjoin(original_dir, *p)));
|
||||
assert_se((l = strjoin(copy_dir, *link)));
|
||||
|
||||
assert_se(readlink_and_canonicalize(l, NULL, &target) == 0);
|
||||
assert_se(chase_symlinks(l, NULL, 0, &target) == 1);
|
||||
assert_se(path_equal(f, target));
|
||||
}
|
||||
|
||||
|
|
|
@ -360,58 +360,6 @@ static void test_in_addr_ifindex_from_string_auto(void) {
|
|||
assert_se(in_addr_ifindex_from_string_auto("fe80::19%thisinterfacecantexist", &family, &ua, &ifindex) == -ENODEV);
|
||||
}
|
||||
|
||||
static void *connect_thread(void *arg) {
|
||||
union sockaddr_union *sa = arg;
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void test_nameinfo_pretty(void) {
|
||||
_cleanup_free_ char *stdin_name = NULL, *localhost = NULL;
|
||||
|
||||
union sockaddr_union s = {
|
||||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = 0,
|
||||
.in.sin_addr.s_addr = htobe32(INADDR_ANY),
|
||||
};
|
||||
int r;
|
||||
|
||||
union sockaddr_union c = {};
|
||||
socklen_t slen = sizeof(c.in), clen = sizeof(c.in);
|
||||
|
||||
_cleanup_close_ int sfd = -1, cfd = -1;
|
||||
r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
|
||||
log_info_errno(r, "No connection remote: %m");
|
||||
|
||||
assert_se(r < 0);
|
||||
|
||||
sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
assert_se(sfd >= 0);
|
||||
|
||||
assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
|
||||
|
||||
/* find out the port number */
|
||||
assert_se(getsockname(sfd, &s.sa, &slen) == 0);
|
||||
|
||||
assert_se(listen(sfd, 1) == 0);
|
||||
|
||||
assert_se(asynchronous_job(connect_thread, &s) == 0);
|
||||
|
||||
log_debug("Accepting new connection on fd:%d", sfd);
|
||||
cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
|
||||
assert_se(cfd >= 0);
|
||||
|
||||
r = getnameinfo_pretty(cfd, &localhost);
|
||||
log_info("Connection from %s", localhost);
|
||||
assert_se(r == 0);
|
||||
}
|
||||
|
||||
static void test_sockaddr_equal(void) {
|
||||
union sockaddr_union a = {
|
||||
.in.sin_family = AF_INET,
|
||||
|
@ -561,8 +509,6 @@ int main(int argc, char *argv[]) {
|
|||
test_in_addr_ifindex_to_string();
|
||||
test_in_addr_ifindex_from_string_auto();
|
||||
|
||||
test_nameinfo_pretty();
|
||||
|
||||
test_sockaddr_equal();
|
||||
|
||||
test_sockaddr_un_len();
|
||||
|
|
Loading…
Reference in New Issue