1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

terminal-util: modernize things with TAKE_PTR a bit

This commit is contained in:
Lennart Poettering 2019-03-26 17:19:47 +01:00
parent 49bd196d69
commit f171decd3f

View File

@ -912,20 +912,18 @@ int getttyname_malloc(int fd, char **ret) {
return 0;
}
int getttyname_harder(int fd, char **r) {
int k;
char *s = NULL;
int getttyname_harder(int fd, char **ret) {
_cleanup_free_ char *s = NULL;
int r;
k = getttyname_malloc(fd, &s);
if (k < 0)
return k;
r = getttyname_malloc(fd, &s);
if (r < 0)
return r;
if (streq(s, "tty")) {
free(s);
return get_ctty(0, NULL, r);
}
if (streq(s, "tty"))
return get_ctty(0, NULL, ret);
*r = s;
*ret = TAKE_PTR(s);
return 0;
}