logind: make use of vtnr_from_tty() in seat_read_active_vt() (#9923)

No functional changes.
This commit is contained in:
Franck Bui 2018-08-24 09:20:51 +02:00 committed by Yu Watanabe
parent 593a5213ce
commit 49679ff70f
1 changed files with 4 additions and 13 deletions

View 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;
}