From: Zbigniew Jędrzejewski-Szmek Date: Thu, 2 Jul 2020 12:25:06 +0000 (+0200) Subject: initctl,update-utmp: define iterator variable in loop X-Git-Tag: v246-rc1~33^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9d9d50cefaae3d2db6d1f9873371290de2c7c36;p=thirdparty%2Fsystemd.git initctl,update-utmp: define iterator variable in loop --- diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c index 7b93de0d8ab..8e615726260 100644 --- a/src/initctl/initctl.c +++ b/src/initctl/initctl.c @@ -68,11 +68,9 @@ static const char *translate_runlevel(int runlevel, bool *isolate) { { '6', SPECIAL_REBOOT_TARGET, false }, }; - unsigned i; - assert(isolate); - for (i = 0; i < ELEMENTSOF(table); i++) + for (size_t i = 0; i < ELEMENTSOF(table); i++) if (table[i].runlevel == runlevel) { *isolate = table[i].isolate; if (runlevel == '6' && kexec_loaded()) @@ -241,7 +239,6 @@ static void server_done(Server *s) { static int server_init(Server *s, unsigned n_sockets) { int r; - unsigned i; assert(s); assert(n_sockets > 0); @@ -256,7 +253,7 @@ static int server_init(Server *s, unsigned n_sockets) { goto fail; } - for (i = 0; i < n_sockets; i++) { + for (unsigned i = 0; i < n_sockets; i++) { Fifo *f; int fd; diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index 28f1aadabcb..47354d50129 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -84,11 +84,10 @@ static int get_current_runlevel(Context *c) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; int r; - unsigned i; assert(c); - for (i = 0; i < ELEMENTSOF(table); i++) { + for (size_t i = 0; i < ELEMENTSOF(table); i++) { _cleanup_free_ char *state = NULL, *path = NULL; path = unit_dbus_path_from_name(table[i].special);