summaryrefslogtreecommitdiffstats
path: root/src/core/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-07-29 17:22:03 +0200
committerLennart Poettering <lennart@poettering.net>2021-07-29 21:14:38 +0200
commit19fd72df5bcf70c083b07e444976931149432a73 (patch)
treeaa726a554bb16fe96fa0813da1339314af0a067f /src/core/main.c
parentmeson: add the versiondep to the static lib deplist as well (diff)
downloadsystemd-19fd72df5bcf70c083b07e444976931149432a73.tar.xz
systemd-19fd72df5bcf70c083b07e444976931149432a73.zip
main: fix type confusion in do_reexecute()
Let's use size_t for stuff we count in memory. This doesn't matter much, but is certainly more correct and less eyebrow-raising. Follow-up for: 846f1da465beda990c1c01346311393f485df467 See: https://github.com/systemd/systemd/pull/20273#discussion_r679250180
Diffstat (limited to '')
-rw-r--r--src/core/main.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/main.c b/src/core/main.c
index f3272a2737..8920d70d5d 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1721,9 +1721,14 @@ static void update_numa_policy(bool skip_setup) {
log_warning_errno(r, "Failed to set NUMA memory policy: %m");
}
-static void filter_args(const char* dst[], unsigned *pos, char **src, int argc) {
+static void filter_args(
+ const char* dst[],
+ size_t *dst_index,
+ char **src,
+ int argc) {
+
assert(dst);
- assert(pos);
+ assert(dst_index);
/* Copy some filtered arguments into the dst array from src. */
for (int i = 1; i < argc; i++) {
@@ -1757,8 +1762,7 @@ static void filter_args(const char* dst[], unsigned *pos, char **src, int argc)
continue;
/* Seems we have a good old option. Let's pass it over to the new instance. */
- dst[*pos] = src[i];
- (*pos)++;
+ dst[(*dst_index)++] = src[i];
}
}
@@ -1772,10 +1776,11 @@ static void do_reexecute(
const char *switch_root_init,
const char **ret_error_message) {
- unsigned i, args_size;
+ size_t i, args_size;
const char **args;
int r;
+ assert(argc >= 0);
assert(saved_rlimit_nofile);
assert(saved_rlimit_memlock);
assert(ret_error_message);