]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: make use of vtnr_from_tty() in seat_read_active_vt() (#9923)
authorFranck Bui <fbui@suse.com>
Fri, 24 Aug 2018 07:20:51 +0000 (09:20 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 Aug 2018 07:20:51 +0000 (16:20 +0900)
No functional changes.

src/login/logind-seat.c

index cca4f907274bfc2405c9eef3bf7b529d335e5e85..f24fe96841eae0720a7203e3624e8eeacece5de3 100644 (file)
@@ -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;
         }