Skip to content

Commit 68e4c63

Browse files
committed
terminal-util: trivial modernizations for reset_terminal_fd()
1 parent 097445d commit 68e4c63

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/basic/terminal-util.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int ask_string(char **ret, const char *text, ...) {
233233

234234
int reset_terminal_fd(int fd, bool switch_to_text) {
235235
struct termios termios;
236-
int r = 0;
236+
int r;
237237

238238
/* Set terminal to some sane defaults */
239239

@@ -256,7 +256,9 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
256256

257257

258258
/* Set default keyboard mode */
259-
(void) vt_reset_keyboard(fd);
259+
r = vt_reset_keyboard(fd);
260+
if (r < 0)
261+
log_debug_errno(r, "Failed to reset VT keyboard, ignoring: %m");
260262

261263
if (tcgetattr(fd, &termios) < 0) {
262264
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) {
290292
termios.c_cc[VTIME] = 0;
291293
termios.c_cc[VMIN] = 1;
292294

293-
if (tcsetattr(fd, TCSANOW, &termios) < 0)
294-
r = -errno;
295+
r = RET_NERRNO(tcsetattr(fd, TCSANOW, &termios));
295296

296297
finish:
297298
/* Just in case, flush all crap out */

0 commit comments

Comments
 (0)