Skip to content

Commit b8e2400

Browse files
authored
Merge pull request systemd#8143 from yuwata/drop-unused-func
Drop several unused functions
2 parents aa9122b + 92db49a commit b8e2400

File tree

6 files changed

+1
-114
lines changed

6 files changed

+1
-114
lines changed

src/basic/fs-util.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -225,49 +225,6 @@ int readlink_and_make_absolute(const char *p, char **r) {
225225
return 0;
226226
}
227227

228-
int readlink_and_canonicalize(const char *p, const char *root, char **ret) {
229-
char *t, *s;
230-
int r;
231-
232-
assert(p);
233-
assert(ret);
234-
235-
r = readlink_and_make_absolute(p, &t);
236-
if (r < 0)
237-
return r;
238-
239-
r = chase_symlinks(t, root, 0, &s);
240-
if (r < 0)
241-
/* If we can't follow up, then let's return the original string, slightly cleaned up. */
242-
*ret = path_kill_slashes(t);
243-
else {
244-
*ret = s;
245-
free(t);
246-
}
247-
248-
return 0;
249-
}
250-
251-
int readlink_and_make_absolute_root(const char *root, const char *path, char **ret) {
252-
_cleanup_free_ char *target = NULL, *t = NULL;
253-
const char *full;
254-
int r;
255-
256-
full = prefix_roota(root, path);
257-
r = readlink_malloc(full, &target);
258-
if (r < 0)
259-
return r;
260-
261-
t = file_in_same_dir(path, target);
262-
if (!t)
263-
return -ENOMEM;
264-
265-
*ret = t;
266-
t = NULL;
267-
268-
return 0;
269-
}
270-
271228
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid) {
272229
assert(path);
273230

src/basic/fs-util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ int readlinkat_malloc(int fd, const char *p, char **ret);
4141
int readlink_malloc(const char *p, char **r);
4242
int readlink_value(const char *p, char **ret);
4343
int readlink_and_make_absolute(const char *p, char **r);
44-
int readlink_and_canonicalize(const char *p, const char *root, char **r);
45-
int readlink_and_make_absolute_root(const char *root, const char *path, char **ret);
4644

4745
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
4846

src/basic/socket-util.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -758,19 +758,6 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
758758
return 0;
759759
}
760760

761-
int getnameinfo_pretty(int fd, char **ret) {
762-
union sockaddr_union sa;
763-
socklen_t salen = sizeof(sa);
764-
765-
assert(fd >= 0);
766-
assert(ret);
767-
768-
if (getsockname(fd, &sa.sa, &salen) < 0)
769-
return -errno;
770-
771-
return socknameinfo_pretty(&sa, salen, ret);
772-
}
773-
774761
int socket_address_unlink(SocketAddress *a) {
775762
assert(a);
776763

src/basic/socket-util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ int getpeername_pretty(int fd, bool include_port, char **ret);
126126
int getsockname_pretty(int fd, char **ret);
127127

128128
int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
129-
int getnameinfo_pretty(int fd, char **ret);
130129

131130
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
132131
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;

src/test/test-copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void test_copy_tree(void) {
146146
assert_se((f = strjoin(original_dir, *p)));
147147
assert_se((l = strjoin(copy_dir, *link)));
148148

149-
assert_se(readlink_and_canonicalize(l, NULL, &target) == 0);
149+
assert_se(chase_symlinks(l, NULL, 0, &target) == 1);
150150
assert_se(path_equal(f, target));
151151
}
152152

src/test/test-socket-util.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -360,58 +360,6 @@ static void test_in_addr_ifindex_from_string_auto(void) {
360360
assert_se(in_addr_ifindex_from_string_auto("fe80::19%thisinterfacecantexist", &family, &ua, &ifindex) == -ENODEV);
361361
}
362362

363-
static void *connect_thread(void *arg) {
364-
union sockaddr_union *sa = arg;
365-
_cleanup_close_ int fd = -1;
366-
367-
fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
368-
assert_se(fd >= 0);
369-
370-
assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
371-
372-
return NULL;
373-
}
374-
375-
static void test_nameinfo_pretty(void) {
376-
_cleanup_free_ char *stdin_name = NULL, *localhost = NULL;
377-
378-
union sockaddr_union s = {
379-
.in.sin_family = AF_INET,
380-
.in.sin_port = 0,
381-
.in.sin_addr.s_addr = htobe32(INADDR_ANY),
382-
};
383-
int r;
384-
385-
union sockaddr_union c = {};
386-
socklen_t slen = sizeof(c.in), clen = sizeof(c.in);
387-
388-
_cleanup_close_ int sfd = -1, cfd = -1;
389-
r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
390-
log_info_errno(r, "No connection remote: %m");
391-
392-
assert_se(r < 0);
393-
394-
sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
395-
assert_se(sfd >= 0);
396-
397-
assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
398-
399-
/* find out the port number */
400-
assert_se(getsockname(sfd, &s.sa, &slen) == 0);
401-
402-
assert_se(listen(sfd, 1) == 0);
403-
404-
assert_se(asynchronous_job(connect_thread, &s) == 0);
405-
406-
log_debug("Accepting new connection on fd:%d", sfd);
407-
cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
408-
assert_se(cfd >= 0);
409-
410-
r = getnameinfo_pretty(cfd, &localhost);
411-
log_info("Connection from %s", localhost);
412-
assert_se(r == 0);
413-
}
414-
415363
static void test_sockaddr_equal(void) {
416364
union sockaddr_union a = {
417365
.in.sin_family = AF_INET,
@@ -561,8 +509,6 @@ int main(int argc, char *argv[]) {
561509
test_in_addr_ifindex_to_string();
562510
test_in_addr_ifindex_from_string_auto();
563511

564-
test_nameinfo_pretty();
565-
566512
test_sockaddr_equal();
567513

568514
test_sockaddr_un_len();

0 commit comments

Comments
 (0)