initctl,update-utmp: define iterator variable in loop

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-07-02 14:25:06 +02:00
parent bc9d1dbfc8
commit e9d9d50cef
2 changed files with 3 additions and 7 deletions

View File

@ -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;

View File

@ -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);