summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-08 14:36:47 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-08 15:03:31 +0200
commit1ba239315ff449779189bde77361f323851dc39f (patch)
treee38d36dfaf76494fdefbd5fa21d05fa417669d41
parent3d18b167558bde95a076b16d40f9454f169e70ba (diff)
util: minor modernization of vt_disallocate()
-rw-r--r--src/basic/terminal-util.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 1bda9564fb..ca7554a9fa 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -535,8 +535,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
@@ -558,8 +559,6 @@ int vt_disallocate(const char *name) {
"\033[H" /* move home */
"\033[2J", /* clear screen */
10, false);
- safe_close(fd);
-
return 0;
}
@@ -579,7 +578,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;
@@ -598,8 +597,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;
}