diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-cgroup.c | 3 | ||||
-rw-r--r-- | src/core/dbus-execute.c | 9 | ||||
-rw-r--r-- | src/core/dbus-job.c | 4 | ||||
-rw-r--r-- | src/core/dbus-manager.c | 6 | ||||
-rw-r--r-- | src/core/device.c | 3 | ||||
-rw-r--r-- | src/core/execute.c | 4 | ||||
-rw-r--r-- | src/core/namespace.c | 26 | ||||
-rw-r--r-- | src/core/socket.c | 6 | ||||
-rw-r--r-- | src/core/swap.c | 4 | ||||
-rw-r--r-- | src/core/target.c | 3 |
10 files changed, 23 insertions, 45 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 37c581fb22..a7d9312d97 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -32,7 +32,6 @@ static int property_get_cgroup_mask( sd_bus_error *error) { CGroupMask *mask = userdata; - CGroupController ctrl; int r; assert(bus); @@ -42,7 +41,7 @@ static int property_get_cgroup_mask( if (r < 0) return r; - for (ctrl = 0; ctrl < _CGROUP_CONTROLLER_MAX; ctrl++) { + for (CGroupController ctrl = 0; ctrl < _CGROUP_CONTROLLER_MAX; ctrl++) { if ((*mask & CGROUP_CONTROLLER_TO_MASK(ctrl)) == 0) continue; diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 8434ccb48e..0fbf0b167c 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -698,7 +698,6 @@ static int property_get_bind_paths( sd_bus_error *error) { ExecContext *c = userdata; - unsigned i; bool ro; int r; @@ -713,7 +712,7 @@ static int property_get_bind_paths( if (r < 0) return r; - for (i = 0; i < c->n_bind_mounts; i++) { + for (size_t i = 0; i < c->n_bind_mounts; i++) { if (ro != c->bind_mounts[i].read_only) continue; @@ -741,7 +740,6 @@ static int property_get_temporary_filesystems( sd_bus_error *error) { ExecContext *c = userdata; - unsigned i; int r; assert(bus); @@ -753,7 +751,7 @@ static int property_get_temporary_filesystems( if (r < 0) return r; - for (i = 0; i < c->n_temporary_filesystems; i++) { + for (unsigned i = 0; i < c->n_temporary_filesystems; i++) { TemporaryFileSystem *t = c->temporary_filesystems + i; r = sd_bus_message_append( @@ -777,7 +775,6 @@ static int property_get_log_extra_fields( sd_bus_error *error) { ExecContext *c = userdata; - size_t i; int r; assert(bus); @@ -789,7 +786,7 @@ static int property_get_log_extra_fields( if (r < 0) return r; - for (i = 0; i < c->n_log_extra_fields; i++) { + for (size_t i = 0; i < c->n_log_extra_fields; i++) { r = sd_bus_message_append_array(reply, 'y', c->log_extra_fields[i].iov_base, c->log_extra_fields[i].iov_len); if (r < 0) return r; diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index 1526b316cc..3334b977bf 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -71,7 +71,7 @@ int bus_job_method_get_waiting_jobs(sd_bus_message *message, void *userdata, sd_ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_free_ Job **list = NULL; Job *j = userdata; - int r, i, n; + int r, n; if (strstr(sd_bus_message_get_member(message), "After")) n = job_get_after(j, &list); @@ -88,7 +88,7 @@ int bus_job_method_get_waiting_jobs(sd_bus_message *message, void *userdata, sd_ if (r < 0) return r; - for (i = 0; i < n; i ++) { + for (int i = 0; i < n; i ++) { _cleanup_free_ char *unit_path = NULL, *job_path = NULL; job_path = job_dbus_path(list[i]); diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index eeb74353da..9053d48149 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -1951,10 +1951,9 @@ static int install_error( UnitFileChange *changes, size_t n_changes) { - size_t i; int r; - for (i = 0; i < n_changes; i++) + for (size_t i = 0; i < n_changes; i++) switch(changes[i].type) { @@ -2021,7 +2020,6 @@ static int reply_unit_file_changes_and_free( _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; bool bad = false, good = false; - size_t i; int r; if (unit_file_changes_have_modification(changes, n_changes)) { @@ -2044,7 +2042,7 @@ static int reply_unit_file_changes_and_free( if (r < 0) goto fail; - for (i = 0; i < n_changes; i++) { + for (size_t i = 0; i < n_changes; i++) { if (changes[i].type < 0) { bad = true; diff --git a/src/core/device.c b/src/core/device.c index cbfb87a808..db39479c8f 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -193,11 +193,10 @@ static const struct { static int device_found_to_string_many(DeviceFound flags, char **ret) { _cleanup_free_ char *s = NULL; - unsigned i; assert(ret); - for (i = 0; i < ELEMENTSOF(device_found_map); i++) { + for (size_t i = 0; i < ELEMENTSOF(device_found_map); i++) { if (!FLAGS_SET(flags, device_found_map[i].flag)) continue; diff --git a/src/core/execute.c b/src/core/execute.c index c56a4ef03b..1a679da435 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -4911,9 +4911,7 @@ static void exec_command_done(ExecCommand *c) { } void exec_command_done_array(ExecCommand *c, size_t n) { - size_t i; - - for (i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) exec_command_done(c+i); } diff --git a/src/core/namespace.c b/src/core/namespace.c index db9a12319d..e8306a8d55 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -312,11 +312,9 @@ static int append_empty_dir_mounts(MountEntry **p, char **strv) { } static int append_bind_mounts(MountEntry **p, const BindMount *binds, size_t n) { - size_t i; - assert(p); - for (i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { const BindMount *b = binds + i; *((*p)++) = (MountEntry) { @@ -390,14 +388,12 @@ static int append_tmpfs_mounts(MountEntry **p, const TemporaryFileSystem *tmpfs, } static int append_static_mounts(MountEntry **p, const MountEntry *mounts, size_t n, bool ignore_protect) { - size_t i; - assert(p); assert(mounts); /* Adds a list of static pre-defined entries */ - for (i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) *((*p)++) = (MountEntry) { .path_const = mount_entry_path(mounts+i), .mode = mounts[i].mode, @@ -464,11 +460,11 @@ static int mount_path_compare(const MountEntry *a, const MountEntry *b) { } static int prefix_where_needed(MountEntry *m, size_t n, const char *root_directory) { - size_t i; - /* Prefixes all paths in the bind mount table with the root directory if the entry needs that. */ - for (i = 0; i < n; i++) { + assert(m || n == 0); + + for (size_t i = 0; i < n; i++) { char *s; if (m[i].has_prefix) @@ -1913,11 +1909,9 @@ finish: } void bind_mount_free_many(BindMount *b, size_t n) { - size_t i; - assert(b || n == 0); - for (i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { free(b[i].source); free(b[i].destination); } @@ -1960,12 +1954,10 @@ int bind_mount_add(BindMount **b, size_t *n, const BindMount *item) { } MountImage* mount_image_free_many(MountImage *m, size_t *n) { - size_t i; - assert(n); assert(m || *n == 0); - for (i = 0; i < *n; i++) { + for (size_t i = 0; i < *n; i++) { free(m[i].source); free(m[i].destination); mount_options_free_all(m[i].mount_options); @@ -2028,11 +2020,9 @@ int mount_image_add(MountImage **m, size_t *n, const MountImage *item) { } void temporary_filesystem_free_many(TemporaryFileSystem *t, size_t n) { - size_t i; - assert(t || n == 0); - for (i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { free(t[i].path); free(t[i].options); } diff --git a/src/core/socket.c b/src/core/socket.c index 1f799830d1..cb5316af3a 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1319,7 +1319,7 @@ static int usbffs_select_ep(const struct dirent *d) { static int usbffs_dispatch_eps(SocketPort *p) { _cleanup_free_ struct dirent **ent = NULL; - size_t n, k, i; + size_t n, k; int r; r = scandir(p->path, &ent, usbffs_select_ep, alphasort); @@ -1336,7 +1336,7 @@ static int usbffs_dispatch_eps(SocketPort *p) { p->n_auxiliary_fds = n; k = 0; - for (i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { _cleanup_free_ char *ep = NULL; ep = path_make_absolute(ent[i]->d_name, p->path); @@ -1363,7 +1363,7 @@ fail: p->n_auxiliary_fds = 0; clear: - for (i = 0; i < n; ++i) + for (size_t i = 0; i < n; ++i) free(ent[i]); return r; diff --git a/src/core/swap.c b/src/core/swap.c index ed06cf4b4b..5746940fa8 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -1183,15 +1183,13 @@ static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userd } static int swap_load_proc_swaps(Manager *m, bool set_flags) { - unsigned i; - assert(m); rewind(m->proc_swaps); (void) fscanf(m->proc_swaps, "%*s %*s %*s %*s %*s\n"); - for (i = 1;; i++) { + for (unsigned i = 1;; i++) { _cleanup_free_ char *dev = NULL, *d = NULL; int prio = 0, k; diff --git a/src/core/target.c b/src/core/target.c index a422056803..5755f26615 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -45,7 +45,6 @@ static int target_add_default_dependencies(Target *t) { }; int r; - unsigned k; assert(t); @@ -55,7 +54,7 @@ static int target_add_default_dependencies(Target *t) { /* Imply ordering for requirement dependencies on target units. Note that when the user created a contradicting * ordering manually we won't add anything in here to make sure we don't create a loop. */ - for (k = 0; k < ELEMENTSOF(deps); k++) { + for (size_t k = 0; k < ELEMENTSOF(deps); k++) { Unit *other; void *v; |