diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-08 14:36:47 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-04-26 12:58:55 +0200 |
commit | be70ef286ad74a5d9db1716d1b097ff0dbd3e713 (patch) | |
tree | 94cbdf9c11e8375f5f189239d7f24f5b08e87467 /src | |
parent | 796f8c41e16712f9faadee3aea6fd2f38baf989a (diff) |
util: minor modernization of vt_disallocate()
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/terminal-util.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 8f63695cf..f7ef57cec 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -545,8 +545,9 @@ int terminal_vhangup(const char *name) { } int vt_disallocate(const char *name) { - int fd, r; + _cleanup_close_ int fd = -1; unsigned u; + int r; /* Deallocate the VT if possible. If not possible * (i.e. because it is the active one), at least clear it @@ -568,8 +569,6 @@ int vt_disallocate(const char *name) { "\033[H" /* move home */ "\033[2J", /* clear screen */ 10, false); - safe_close(fd); - return 0; } @@ -589,7 +588,7 @@ int vt_disallocate(const char *name) { return fd; r = ioctl(fd, VT_DISALLOCATE, u); - safe_close(fd); + fd = safe_close(fd); if (r >= 0) return 0; @@ -608,8 +607,6 @@ int vt_disallocate(const char *name) { "\033[H" /* move home */ "\033[3J", /* clear screen including scrollback, requires Linux 2.6.40 */ 10, false); - safe_close(fd); - return 0; } |