From 49679ff70f147cf3b6ff2120e1c8ccff838dba87 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Fri, 24 Aug 2018 09:20:51 +0200 Subject: [PATCH] logind: make use of vtnr_from_tty() in seat_read_active_vt() (#9923) No functional changes. --- src/login/logind-seat.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index cca4f90..f24fe96 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -355,8 +355,7 @@ int seat_active_vt_changed(Seat *s, unsigned int vtnr) { int seat_read_active_vt(Seat *s) { char t[64]; ssize_t k; - unsigned int vtnr; - int r; + int vtnr; assert(s); @@ -375,17 +374,9 @@ int seat_read_active_vt(Seat *s) { t[k] = 0; truncate_nl(t); - if (!startswith(t, "tty")) { - log_error("Hm, /sys/class/tty/tty0/active is badly formatted."); - return -EIO; - } - - r = safe_atou(t+3, &vtnr); - if (r < 0) - return log_error_errno(r, "Failed to parse VT number \"%s\": %m", t+3); - - if (!vtnr) { - log_error("VT number invalid: %s", t+3); + vtnr = vtnr_from_tty(t); + if (vtnr < 0) { + log_error_errno(vtnr, "Hm, /sys/class/tty/tty0/active is badly formatted: %m"); return -EIO; } -- 2.7.4