terminal-util: trivial modernizations for reset_terminal_fd()
authorLennart Poettering <lennart@poettering.net>
Wed, 22 Nov 2023 12:08:17 +0000 (13:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 22 Nov 2023 12:27:53 +0000 (13:27 +0100)
src/basic/terminal-util.c

index b505a3a..c266fea 100644 (file)
@@ -233,7 +233,7 @@ int ask_string(char **ret, const char *text, ...) {
 
 int reset_terminal_fd(int fd, bool switch_to_text) {
         struct termios termios;
-        int r = 0;
+        int r;
 
         /* Set terminal to some sane defaults */
 
@@ -256,7 +256,9 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
 
 
         /* Set default keyboard mode */
-        (void) vt_reset_keyboard(fd);
+        r = vt_reset_keyboard(fd);
+        if (r < 0)
+                log_debug_errno(r, "Failed to reset VT keyboard, ignoring: %m");
 
         if (tcgetattr(fd, &termios) < 0) {
                 r = log_debug_errno(errno, "Failed to get terminal parameters: %m");
@@ -290,8 +292,7 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
         termios.c_cc[VTIME]  = 0;
         termios.c_cc[VMIN]   = 1;
 
-        if (tcsetattr(fd, TCSANOW, &termios) < 0)
-                r = -errno;
+        r = RET_NERRNO(tcsetattr(fd, TCSANOW, &termios));
 
 finish:
         /* Just in case, flush all crap out */