1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

terminal-util: simplify terminal_set_size_fd() a tiny bit

This commit is contained in:
Lennart Poettering 2024-07-11 11:28:29 +02:00
parent b7120388f8
commit 061b445828

View File

@ -908,13 +908,18 @@ unsigned lines(void) {
int terminal_set_size_fd(int fd, const char *ident, unsigned rows, unsigned cols) {
struct winsize ws;
assert(fd >= 0);
if (!ident)
ident = "TTY";
if (rows == UINT_MAX && cols == UINT_MAX)
return 0;
if (ioctl(fd, TIOCGWINSZ, &ws) < 0)
return log_debug_errno(errno,
"TIOCGWINSZ ioctl for getting %s size failed, not setting terminal size: %m",
ident ?: "TTY");
ident);
if (rows == UINT_MAX)
rows = ws.ws_row;
@ -933,7 +938,7 @@ int terminal_set_size_fd(int fd, const char *ident, unsigned rows, unsigned cols
ws.ws_col = cols;
if (ioctl(fd, TIOCSWINSZ, &ws) < 0)
return log_debug_errno(errno, "TIOCSWINSZ ioctl for setting %s size failed: %m", ident ?: "TTY");
return log_debug_errno(errno, "TIOCSWINSZ ioctl for setting %s size failed: %m", ident);
return 0;
}