summaryrefslogtreecommitdiff
path: root/src/login/logind-core.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-11-28 17:05:34 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-11-28 17:38:16 +0100
commit92bd5ff3a062c3f9475b9d9d39b9335bfeb7705e (patch)
tree0769b098958778286b006da515dca801c64e30d3 /src/login/logind-core.c
parent92fe133abf2de889659464ae8affd1db1710f72e (diff)
logind: make VT numbers unsigned
Fix the whole code to use "unsigned int" for vtnr. 0 is an invalid vtnr so we don't need negative numbers at all. Note that most code already assumes it's unsigned so in case there's a negative vtnr, our code may, under special circumstances, silently break. So this patch makes sure all sources of vtnrs verify the validity. Also note that the dbus api already uses unsigned ints.
Diffstat (limited to 'src/login/logind-core.c')
-rw-r--r--src/login/logind-core.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 72ee9fe572..3f8e8139da 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -436,7 +436,7 @@ bool manager_shall_kill(Manager *m, const char *user) {
return strv_contains(m->kill_only_users, user);
}
-static int vt_is_busy(int vtnr) {
+static int vt_is_busy(unsigned int vtnr) {
struct vt_stat vt_stat;
int r = 0, fd;
@@ -462,7 +462,7 @@ static int vt_is_busy(int vtnr) {
return r;
}
-int manager_spawn_autovt(Manager *m, int vtnr) {
+int manager_spawn_autovt(Manager *m, unsigned int vtnr) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *name = NULL;
int r;
@@ -470,11 +470,11 @@ int manager_spawn_autovt(Manager *m, int vtnr) {
assert(m);
assert(vtnr >= 1);
- if ((unsigned) vtnr > m->n_autovts &&
- (unsigned) vtnr != m->reserve_vt)
+ if (vtnr > m->n_autovts &&
+ vtnr != m->reserve_vt)
return 0;
- if ((unsigned) vtnr != m->reserve_vt) {
+ if (vtnr != m->reserve_vt) {
/* If this is the reserved TTY, we'll start the getty
* on it in any case, but otherwise only if it is not
* busy. */
@@ -486,7 +486,7 @@ int manager_spawn_autovt(Manager *m, int vtnr) {
return -EBUSY;
}
- if (asprintf(&name, "autovt@tty%i.service", vtnr) < 0)
+ if (asprintf(&name, "autovt@tty%u.service", vtnr) < 0)
return log_oom();
r = sd_bus_call_method(