1
0
mirror of https://github.com/systemd/systemd synced 2025-09-29 08:44:45 +02:00

Compare commits

..

No commits in common. "9a4fce2efc4f74aa69117f43aa9a6ce499f9a099" and "37baf8db563f085e8867a0764f9832dcd7e94605" have entirely different histories.

48 changed files with 218 additions and 260 deletions

View File

@ -41,10 +41,10 @@ available functionality:
symbols of `libsystemd.so` and `libudev.so` with the list of man pages. Symbols
lacking documentation are highlighted.
7. Use `meson compile -C build update-hwdb` to automatically download and import the
7. Use `meson compile -C build hwdb-update` to automatically download and import the
PCI, USB and OUI databases into hwdb.
8. Use `meson compile -C build update-man-rules` to update the meson rules for
8. Use `meson compile -C build man/update-man-rules` to update the meson rules for
building man pages automatically from the docbook XML files included in
`man/`.

View File

@ -10,7 +10,7 @@ layout: default
2. Update the contributors list in NEWS (`meson compile -C build git-contrib`)
3. Update the time and place in NEWS
4. [RC1] Update version and library numbers in `meson.build`
5. Check dbus docs with `meson compile -C build update-dbus-docs`
5. Check dbus docs with `meson compile -C build man/update-dbus-docs`
6. Tag the release: `version=vXXX-rcY && git tag -s "${version}" -m "systemd ${version}"`
7. Do `meson compile -C build`
8. Make sure that the version string and package string match: `build/systemctl --version`

View File

@ -66,9 +66,9 @@ endif
############################################################
run_target(
'update-hwdb',
command : [update_hwdb_sh, meson.current_source_dir()])
'hwdb-update',
command : [hwdb_update_sh, meson.current_source_dir()])
run_target(
'update-hwdb-autosuspend',
command : [update_hwdb_autosuspend_sh, project_source_root])
'autosuspend-update',
command : [autosuspend_update_sh, project_source_root])

View File

@ -6,7 +6,7 @@ if [ -z "$1" ]; then
exit 1
fi
# make sure the rules have been regenerated (in case update-man-rules was just run)
# make sure the rules have been regenerated (in case man/update-man-rules was just run)
ninja -C "@BUILD_ROOT@" version.h
target="man/$1.html"

View File

@ -6,7 +6,7 @@ if [ -z "$1" ]; then
exit 1
fi
# make sure the rules have been regenerated (in case update-man-rules was just run)
# make sure the rules have been regenerated (in case man/update-man-rules was just run)
ninja -C "@BUILD_ROOT@" version.h
page="$(echo "$1" | sed 's/\./\\./')"

View File

@ -198,6 +198,36 @@ run_target(
############################################################
if dbus_docs.length() > 0
custom_target(
'update-dbus-docs',
output : 'update-dbus-docs',
command : [update_dbus_docs_py,
'--build-dir=@0@'.format(project_build_root),
'@INPUT@'],
input : dbus_docs)
if conf.get('BUILD_MODE') == 'BUILD_MODE_DEVELOPER'
test('dbus-docs-fresh',
update_dbus_docs_py,
args : ['--build-dir=@0@'.format(project_build_root),
'--test'] + dbus_docs)
endif
endif
############################################################
custom_target(
'update-man-rules',
output : 'update-man-rules',
command : ['sh', '-c',
'cd @0@ && '.format(meson.build_root()) +
'python3 @0@/tools/update-man-rules.py $(find @0@ -wholename "*/man/*.xml") >t && '.format(project_source_root) +
'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
depend_files : custom_entities_ent)
############################################################
configure_file(
input : 'man.in',
output : 'man',

View File

@ -2,7 +2,7 @@
# Do not edit. Generated by update-man-rules.py.
# Update with:
# ninja -C build update-man-rules
# ninja -C build man/update-man-rules
manpages = [
['binfmt.d', '5', [], 'ENABLE_BINFMT'],
['bootctl', '1', [], 'ENABLE_EFI'],

View File

@ -1589,8 +1589,8 @@ conf.set10('ENABLE_EFI', have)
############################################################
update_hwdb_sh = find_program('tools/update-hwdb.sh')
update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
autosuspend_update_sh = find_program('tools/autosuspend-update.sh')
hwdb_update_sh = find_program('tools/hwdb-update.sh')
make_autosuspend_rules_py = find_program('tools/make-autosuspend-rules.py')
make_directive_index_py = find_program('tools/make-directive-index.py')
make_man_index_py = find_program('tools/make-man-index.py')
@ -3605,34 +3605,6 @@ run_target(
depends : [man, libsystemd, libudev],
command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
############################################################
if dbus_docs.length() > 0
custom_target(
'update-dbus-docs',
output : 'update-dbus-docs',
command : [update_dbus_docs_py,
'--build-dir=@0@'.format(project_build_root),
'@INPUT@'],
input : dbus_docs)
if conf.get('BUILD_MODE') == 'BUILD_MODE_DEVELOPER'
test('dbus-docs-fresh',
update_dbus_docs_py,
args : ['--build-dir=@0@'.format(project_build_root),
'--test'] + dbus_docs)
endif
endif
custom_target(
'update-man-rules',
output : 'update-man-rules',
command : ['sh', '-c',
'cd @0@ && '.format(meson.build_root()) +
'python3 @0@/tools/update-man-rules.py $(find @0@ -wholename "*/man/*.xml") >t && '.format(project_source_root) +
'mv t @0@/man/rules/meson.build'.format(meson.current_source_dir())],
depend_files : custom_entities_ent)
############################################################
watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog

View File

@ -1131,8 +1131,8 @@ static const char *skip_slices(const char *p) {
}
int cg_path_get_unit(const char *path, char **ret) {
_cleanup_free_ char *unit = NULL;
const char *e;
char *unit;
int r;
assert(path);
@ -1145,10 +1145,12 @@ int cg_path_get_unit(const char *path, char **ret) {
return r;
/* We skipped over the slices, don't accept any now */
if (endswith(unit, ".slice"))
if (endswith(unit, ".slice")) {
free(unit);
return -ENXIO;
}
*ret = TAKE_PTR(unit);
*ret = unit;
return 0;
}

View File

@ -91,9 +91,11 @@ void safe_close_pair(int p[static 2]) {
}
void close_many(const int fds[], size_t n_fd) {
size_t i;
assert(fds || n_fd <= 0);
for (size_t i = 0; i < n_fd; i++)
for (i = 0; i < n_fd; i++)
safe_close(fds[i]);
}
@ -177,9 +179,11 @@ int fd_cloexec(int fd, bool cloexec) {
}
_pure_ static bool fd_in_set(int fd, const int fdset[], size_t n_fdset) {
size_t i;
assert(n_fdset == 0 || fdset);
for (size_t i = 0; i < n_fdset; i++)
for (i = 0; i < n_fdset; i++)
if (fdset[i] == fd)
return true;

View File

@ -43,7 +43,7 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
{ "K", UINT64_C(1000) },
};
const suffix_table *table;
size_t n;
size_t n, i;
assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si));
@ -53,7 +53,7 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
table = flag & FORMAT_BYTES_USE_IEC ? table_iec : table_si;
n = ELEMENTSOF(table_iec);
for (size_t i = 0; i < n; i++)
for (i = 0; i < n; i++)
if (t >= table[i].factor) {
if (flag & FORMAT_BYTES_BELOW_POINT) {
snprintf(buf, l,

View File

@ -319,14 +319,16 @@ int iovw_put_string_field_free(struct iovec_wrapper *iovw, const char *field, ch
}
void iovw_rebase(struct iovec_wrapper *iovw, char *old, char *new) {
for (size_t i = 0; i < iovw->count; i++)
size_t i;
for (i = 0; i < iovw->count; i++)
iovw->iovec[i].iov_base = (char *)iovw->iovec[i].iov_base - old + new;
}
size_t iovw_size(struct iovec_wrapper *iovw) {
size_t n = 0;
size_t n = 0, i;
for (size_t i = 0; i < iovw->count; i++)
for (i = 0; i < iovw->count; i++)
n += iovw->iovec[i].iov_len;
return n;

View File

@ -593,13 +593,14 @@ int safe_atod(const char *s, double *ret_d) {
}
int parse_fractional_part_u(const char **p, size_t digits, unsigned *res) {
size_t i;
unsigned val = 0;
const char *s;
s = *p;
/* accept any number of digits, strtoull is limited to 19 */
for (size_t i = 0; i < digits; i++,s++) {
for (i=0; i < digits; i++,s++) {
if (*s < '0' || *s > '9') {
if (i == 0)
return -EINVAL;

View File

@ -50,13 +50,13 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
}
int setrlimit_closest_all(const struct rlimit *const *rlim, int *which_failed) {
int r;
int i, r;
assert(rlim);
/* On failure returns the limit's index that failed in *which_failed, but only if non-NULL */
for (int i = 0; i < _RLIMIT_MAX; i++) {
for (i = 0; i < _RLIMIT_MAX; i++) {
if (!rlim[i])
continue;

View File

@ -23,10 +23,12 @@ static void* volatile sigbus_queue[SIGBUS_QUEUE_MAX];
static volatile sig_atomic_t n_sigbus_queue = 0;
static void sigbus_push(void *addr) {
unsigned u;
assert(addr);
/* Find a free place, increase the number of entries and leave, if we can */
for (size_t u = 0; u < SIGBUS_QUEUE_MAX; u++)
for (u = 0; u < SIGBUS_QUEUE_MAX; u++)
if (__sync_bool_compare_and_swap(&sigbus_queue[u], NULL, addr)) {
__sync_fetch_and_add(&n_sigbus_queue, 1);
return;

View File

@ -15,9 +15,9 @@ int reset_all_signal_handlers(void) {
.sa_handler = SIG_DFL,
.sa_flags = SA_RESTART,
};
int r = 0;
int sig, r = 0;
for (int sig = 1; sig < _NSIG; sig++) {
for (sig = 1; sig < _NSIG; sig++) {
/* These two cannot be caught... */
if (IN_SET(sig, SIGKILL, SIGSTOP))

View File

@ -862,8 +862,9 @@ char *strextend_with_separator_internal(char **x, const char *separator, ...) {
}
char *strrep(const char *s, unsigned n) {
char *r, *p;
size_t l;
char *r, *p;
unsigned i;
assert(s);
@ -872,7 +873,7 @@ char *strrep(const char *s, unsigned n) {
if (!r)
return NULL;
for (unsigned i = 0; i < n; i++)
for (i = 0; i < n; i++)
p = stpcpy(p, s);
*p = 0;

View File

@ -493,6 +493,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
{ "us", 1 },
};
size_t i;
char *p = buf;
bool something = false;
@ -513,7 +514,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
/* The result of this function can be parsed with parse_sec */
for (size_t i = 0; i < ELEMENTSOF(table); i++) {
for (i = 0; i < ELEMENTSOF(table); i++) {
int k = 0;
size_t n;
bool done = false;
@ -961,8 +962,9 @@ static const char* extract_multiplier(const char *p, usec_t *multiplier) {
{ "us", 1ULL },
{ "µs", 1ULL },
};
size_t i;
for (size_t i = 0; i < ELEMENTSOF(table); i++) {
for (i = 0; i < ELEMENTSOF(table); i++) {
char *e;
e = startswith(p, table[i].suffix);

View File

@ -132,6 +132,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
const char *fn;
char *t, *x;
uint64_t u;
unsigned i;
assert(ret);
@ -161,7 +162,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
x = stpcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), extra), fn);
u = random_u64();
for (unsigned i = 0; i < 16; i++) {
for (i = 0; i < 16; i++) {
*(x++) = hexchar(u & 0xF);
u >>= 4;
}
@ -175,6 +176,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
int tempfn_random_child(const char *p, const char *extra, char **ret) {
char *t, *x;
uint64_t u;
unsigned i;
int r;
assert(ret);
@ -203,7 +205,7 @@ int tempfn_random_child(const char *p, const char *extra, char **ret) {
x = stpcpy(stpcpy(stpcpy(t, p), "/.#"), extra);
u = random_u64();
for (unsigned i = 0; i < 16; i++) {
for (i = 0; i < 16; i++) {
*(x++) = hexchar(u & 0xF);
u >>= 4;
}

View File

@ -580,6 +580,7 @@ static const char * const rlmap_initrd[] = {
const char* runlevel_to_target(const char *word) {
const char * const *rlmap_ptr;
size_t i;
if (!word)
return NULL;
@ -592,7 +593,7 @@ const char* runlevel_to_target(const char *word) {
rlmap_ptr = in_initrd() ? rlmap_initrd : rlmap;
for (size_t i = 0; rlmap_ptr[i]; i += 2)
for (i = 0; rlmap_ptr[i]; i += 2)
if (streq(word, rlmap_ptr[i]))
return rlmap_ptr[i+1];

View File

@ -81,7 +81,7 @@ static size_t utf8_encoded_expected_len(uint8_t c) {
/* decode one unicode char */
int utf8_encoded_to_unichar(const char *str, char32_t *ret_unichar) {
char32_t unichar;
size_t len;
size_t len, i;
assert(str);
@ -110,7 +110,7 @@ int utf8_encoded_to_unichar(const char *str, char32_t *ret_unichar) {
return -EINVAL;
}
for (size_t i = 1; i < len; i++) {
for (i = 1; i < len; i++) {
if (((char32_t)str[i] & 0xc0) != 0x80)
return -EINVAL;
@ -302,12 +302,14 @@ char *ascii_is_valid(const char *str) {
}
char *ascii_is_valid_n(const char *str, size_t len) {
size_t i;
/* Very similar to ascii_is_valid(), but checks exactly len
* bytes and rejects any NULs in that range. */
assert(str);
for (size_t i = 0; i < len; i++)
for (i = 0; i < len; i++)
if ((unsigned char) str[i] >= 128 || str[i] == 0)
return NULL;
@ -434,6 +436,7 @@ size_t utf16_encode_unichar(char16_t *out, char32_t c) {
char16_t *utf8_to_utf16(const char *s, size_t length) {
char16_t *n, *p;
size_t i;
int r;
assert(s);
@ -444,7 +447,7 @@ char16_t *utf8_to_utf16(const char *s, size_t length) {
p = n;
for (size_t i = 0; i < length;) {
for (i = 0; i < length;) {
char32_t unichar;
size_t e;
@ -502,7 +505,7 @@ static int utf8_unichar_to_encoded_len(char32_t unichar) {
/* validate one encoded unicode char and return its length */
int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
char32_t unichar;
size_t len;
size_t len, i;
int r;
assert(str);
@ -523,7 +526,7 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
return 1;
/* check if expected encoded chars are available */
for (size_t i = 0; i < len; i++)
for (i = 0; i < len; i++)
if ((str[i] & 0x80) != 0x80)
return -EINVAL;

View File

@ -159,9 +159,10 @@ static int detect_vm_dmi(void) {
/* https://wiki.freebsd.org/bhyve */
{ "BHYVE", VIRTUALIZATION_BHYVE },
};
unsigned i;
int r;
for (size_t i = 0; i < ELEMENTSOF(dmi_vendors); i++) {
for (i = 0; i < ELEMENTSOF(dmi_vendors); i++) {
_cleanup_free_ char *s = NULL;
unsigned j;

View File

@ -32,6 +32,7 @@ static int property_get_cgroup_mask(
sd_bus_error *error) {
CGroupMask *mask = userdata;
CGroupController ctrl;
int r;
assert(bus);
@ -41,7 +42,7 @@ static int property_get_cgroup_mask(
if (r < 0)
return r;
for (CGroupController ctrl = 0; ctrl < _CGROUP_CONTROLLER_MAX; ctrl++) {
for (ctrl = 0; ctrl < _CGROUP_CONTROLLER_MAX; ctrl++) {
if ((*mask & CGROUP_CONTROLLER_TO_MASK(ctrl)) == 0)
continue;

View File

@ -698,6 +698,7 @@ static int property_get_bind_paths(
sd_bus_error *error) {
ExecContext *c = userdata;
unsigned i;
bool ro;
int r;
@ -712,7 +713,7 @@ static int property_get_bind_paths(
if (r < 0)
return r;
for (size_t i = 0; i < c->n_bind_mounts; i++) {
for (i = 0; i < c->n_bind_mounts; i++) {
if (ro != c->bind_mounts[i].read_only)
continue;
@ -740,6 +741,7 @@ static int property_get_temporary_filesystems(
sd_bus_error *error) {
ExecContext *c = userdata;
unsigned i;
int r;
assert(bus);
@ -751,7 +753,7 @@ static int property_get_temporary_filesystems(
if (r < 0)
return r;
for (unsigned i = 0; i < c->n_temporary_filesystems; i++) {
for (i = 0; i < c->n_temporary_filesystems; i++) {
TemporaryFileSystem *t = c->temporary_filesystems + i;
r = sd_bus_message_append(
@ -775,6 +777,7 @@ static int property_get_log_extra_fields(
sd_bus_error *error) {
ExecContext *c = userdata;
size_t i;
int r;
assert(bus);
@ -786,7 +789,7 @@ static int property_get_log_extra_fields(
if (r < 0)
return r;
for (size_t i = 0; i < c->n_log_extra_fields; i++) {
for (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;

View File

@ -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, n;
int r, i, 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 (int i = 0; i < n; i ++) {
for (i = 0; i < n; i ++) {
_cleanup_free_ char *unit_path = NULL, *job_path = NULL;
job_path = job_dbus_path(list[i]);

View File

@ -1951,9 +1951,10 @@ static int install_error(
UnitFileChange *changes,
size_t n_changes) {
size_t i;
int r;
for (size_t i = 0; i < n_changes; i++)
for (i = 0; i < n_changes; i++)
switch(changes[i].type) {
@ -2020,6 +2021,7 @@ 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)) {
@ -2042,7 +2044,7 @@ static int reply_unit_file_changes_and_free(
if (r < 0)
goto fail;
for (size_t i = 0; i < n_changes; i++) {
for (i = 0; i < n_changes; i++) {
if (changes[i].type < 0) {
bad = true;

View File

@ -193,10 +193,11 @@ static const struct {
static int device_found_to_string_many(DeviceFound flags, char **ret) {
_cleanup_free_ char *s = NULL;
unsigned i;
assert(ret);
for (size_t i = 0; i < ELEMENTSOF(device_found_map); i++) {
for (i = 0; i < ELEMENTSOF(device_found_map); i++) {
if (!FLAGS_SET(flags, device_found_map[i].flag))
continue;

View File

@ -4911,7 +4911,9 @@ static void exec_command_done(ExecCommand *c) {
}
void exec_command_done_array(ExecCommand *c, size_t n) {
for (size_t i = 0; i < n; i++)
size_t i;
for (i = 0; i < n; i++)
exec_command_done(c+i);
}

View File

@ -312,9 +312,11 @@ 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 (size_t i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
const BindMount *b = binds + i;
*((*p)++) = (MountEntry) {
@ -388,12 +390,14 @@ 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 (size_t i = 0; i < n; i++)
for (i = 0; i < n; i++)
*((*p)++) = (MountEntry) {
.path_const = mount_entry_path(mounts+i),
.mode = mounts[i].mode,
@ -460,11 +464,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. */
assert(m || n == 0);
for (size_t i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
char *s;
if (m[i].has_prefix)
@ -1909,9 +1913,11 @@ finish:
}
void bind_mount_free_many(BindMount *b, size_t n) {
size_t i;
assert(b || n == 0);
for (size_t i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
free(b[i].source);
free(b[i].destination);
}
@ -1954,10 +1960,12 @@ 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 (size_t i = 0; i < *n; i++) {
for (i = 0; i < *n; i++) {
free(m[i].source);
free(m[i].destination);
mount_options_free_all(m[i].mount_options);
@ -2020,9 +2028,11 @@ 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 (size_t i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
free(t[i].path);
free(t[i].options);
}

View File

@ -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;
size_t n, k, i;
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 (size_t i = 0; i < n; ++i) {
for (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 (size_t i = 0; i < n; ++i)
for (i = 0; i < n; ++i)
free(ent[i]);
return r;

View File

@ -1183,13 +1183,15 @@ 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 (unsigned i = 1;; i++) {
for (i = 1;; i++) {
_cleanup_free_ char *dev = NULL, *d = NULL;
int prio = 0, k;

View File

@ -45,6 +45,7 @@ static int target_add_default_dependencies(Target *t) {
};
int r;
unsigned k;
assert(t);
@ -54,7 +55,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 (size_t k = 0; k < ELEMENTSOF(deps); k++) {
for (k = 0; k < ELEMENTSOF(deps); k++) {
Unit *other;
void *v;

View File

@ -210,13 +210,14 @@ static int fix_xattr(int fd, const Context *context) {
};
int r = 0;
unsigned i;
assert(fd >= 0);
/* Attach some metadata to coredumps via extended
* attributes. Just because we can. */
for (unsigned i = 0; i < _META_MAX; i++) {
for (i = 0; i < _META_MAX; i++) {
int k;
if (isempty(context->meta[i]) || !xattrs[i])
@ -807,7 +808,7 @@ log:
}
static int save_context(Context *context, const struct iovec_wrapper *iovw) {
unsigned count = 0;
unsigned n, i, count = 0;
const char *unit;
int r;
@ -817,10 +818,10 @@ static int save_context(Context *context, const struct iovec_wrapper *iovw) {
/* The context does not allocate any memory on its own */
for (size_t n = 0; n < iovw->count; n++) {
for (n = 0; n < iovw->count; n++) {
struct iovec *iovec = iovw->iovec + n;
for (size_t i = 0; i < ELEMENTSOF(meta_field_names); i++) {
for (i = 0; i < ELEMENTSOF(meta_field_names); i++) {
char *p;
/* Note that these strings are NUL terminated, because we made sure that a
@ -857,7 +858,7 @@ static int process_socket(int fd) {
Context context = {};
struct iovec_wrapper iovw = {};
struct iovec iovec;
int r;
int i, r;
assert(fd >= 0);
@ -935,7 +936,7 @@ static int process_socket(int fd) {
goto finish;
/* Make sure we received at least all fields we need. */
for (int i = 0; i < _META_MANDATORY_MAX; i++)
for (i = 0; i < _META_MANDATORY_MAX; i++)
if (!context.meta[i]) {
r = log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"A mandatory argument (%i) has not been sent, aborting.",
@ -957,6 +958,7 @@ static int send_iovec(const struct iovec_wrapper *iovw, int input_fd) {
.un.sun_path = "/run/systemd/coredump",
};
_cleanup_close_ int fd = -1;
size_t i;
int r;
assert(iovw);
@ -969,7 +971,7 @@ static int send_iovec(const struct iovec_wrapper *iovw, int input_fd) {
if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
return log_error_errno(errno, "Failed to connect to coredump service: %m");
for (size_t i = 0; i < iovw->count; i++) {
for (i = 0; i < iovw->count; i++) {
struct msghdr mh = {
.msg_iov = iovw->iovec + i,
.msg_iovlen = 1,
@ -1020,7 +1022,7 @@ static int gather_pid_metadata_from_argv(
int argc, char **argv) {
_cleanup_free_ char *free_timestamp = NULL;
int r, signo;
int i, r, signo;
char *t;
/* We gather all metadata that were passed via argv[] into an array of iovecs that
@ -1031,7 +1033,7 @@ static int gather_pid_metadata_from_argv(
"Not enough arguments passed by the kernel (%i, expected %i).",
argc, _META_ARGV_MAX);
for (int i = 0; i < _META_ARGV_MAX; i++) {
for (i = 0; i < _META_ARGV_MAX; i++) {
t = argv[i];
@ -1222,6 +1224,7 @@ static int process_backtrace(int argc, char *argv[]) {
Context context = {};
struct iovec_wrapper *iovw;
char *message;
size_t i;
int r;
_cleanup_(journal_importer_cleanup) JournalImporter importer = JOURNAL_IMPORTER_INIT(STDIN_FILENO);
@ -1271,7 +1274,7 @@ static int process_backtrace(int argc, char *argv[]) {
/* The imported iovecs are not supposed to be freed by us so let's store
* them at the end of the array so we can skip them while freeing the
* rest. */
for (size_t i = 0; i < importer.iovw.count; i++) {
for (i = 0; i < importer.iovw.count; i++) {
struct iovec *iovec = importer.iovw.iovec + i;
iovw_put(iovw, iovec->iov_base, iovec->iov_len);

View File

@ -18,14 +18,14 @@
#define MIN_NUMBER_OF_RUNS 4
int main(int argc, char **argv) {
int r;
int i, r;
size_t size;
char *name;
test_setup_logging(LOG_DEBUG);
for (int i = 1; i < argc; i++) {
for (i = 1; i < argc; i++) {
_cleanup_free_ char *buf = NULL;
size_t size;
char *name;
name = argv[i];
r = read_full_file(name, &buf, &size);

View File

@ -1057,12 +1057,13 @@ int sd_dhcp_server_start(sd_dhcp_server *server) {
}
int sd_dhcp_server_forcerenew(sd_dhcp_server *server) {
unsigned i;
int r = 0;
assert_return(server, -EINVAL);
assert(server->bound_leases);
for (uint32_t i = 0; i < server->pool_size; i++) {
for (i = 0; i < server->pool_size; i++) {
DHCPLease *lease = server->bound_leases[i];
if (!lease || lease == &server->invalid_lease)

View File

@ -40,8 +40,10 @@ void close_and_munmap(int fd, void *address, size_t size) {
}
void bus_flush_memfd(sd_bus *b) {
unsigned i;
assert(b);
for (unsigned i = 0; i < b->n_memfd_cache; i++)
for (i = 0; i < b->n_memfd_cache; i++)
close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped);
}

View File

@ -40,7 +40,7 @@ static void unsetenv_all(bool unset_environment) {
_public_ int sd_listen_fds(int unset_environment) {
const char *e;
int n, r;
int n, r, fd;
pid_t pid;
e = getenv("LISTEN_PID");
@ -75,7 +75,7 @@ _public_ int sd_listen_fds(int unset_environment) {
goto finish;
}
for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) {
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) {
r = fd_cloexec(fd, true);
if (r < 0)
goto finish;

View File

@ -63,9 +63,11 @@ _public_ int sd_device_enumerator_new(sd_device_enumerator **ret) {
}
static sd_device_enumerator *device_enumerator_free(sd_device_enumerator *enumerator) {
size_t i;
assert(enumerator);
for (size_t i = 0; i < enumerator->n_devices; i++)
for (i = 0; i < enumerator->n_devices; i++)
sd_device_unref(enumerator->devices[i]);
free(enumerator->devices);
@ -782,6 +784,7 @@ static void device_enumerator_dedup_devices(sd_device_enumerator *enumerator) {
int device_enumerator_scan_devices(sd_device_enumerator *enumerator) {
int r = 0, k;
size_t i;
assert(enumerator);
@ -789,7 +792,7 @@ int device_enumerator_scan_devices(sd_device_enumerator *enumerator) {
enumerator->type == DEVICE_ENUMERATION_TYPE_DEVICES)
return 0;
for (size_t i = 0; i < enumerator->n_devices; i++)
for (i = 0; i < enumerator->n_devices; i++)
sd_device_unref(enumerator->devices[i]);
enumerator->n_devices = 0;
@ -848,6 +851,7 @@ _public_ sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *e
int device_enumerator_scan_subsystems(sd_device_enumerator *enumerator) {
const char *subsysdir;
int r = 0, k;
size_t i;
assert(enumerator);
@ -855,7 +859,7 @@ int device_enumerator_scan_subsystems(sd_device_enumerator *enumerator) {
enumerator->type == DEVICE_ENUMERATION_TYPE_SUBSYSTEMS)
return 0;
for (size_t i = 0; i < enumerator->n_devices; i++)
for (i = 0; i < enumerator->n_devices; i++)
sd_device_unref(enumerator->devices[i]);
enumerator->n_devices = 0;

View File

@ -8,7 +8,7 @@ $ sudo test/run-integration-tests.sh
ninja: Entering directory `/home/zbyszek/src/systemd/build'
ninja: no work to do.
--x-- Running TEST-01-BASIC --x--
+ make -C TEST-01-BASIC clean setup run
+ make -C TEST-01-BASIC BUILD_DIR=/home/zbyszek/src/systemd/build clean setup run
make: Entering directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
TEST-01-BASIC CLEANUP: Basic systemd setup
TEST-01-BASIC SETUP: Basic systemd setup
@ -17,7 +17,7 @@ TEST-01-BASIC RUN: Basic systemd setup [OK]
make: Leaving directory '/home/zbyszek/src/systemd/test/TEST-01-BASIC'
--x-- Result of TEST-01-BASIC: 0 --x--
--x-- Running TEST-02-CRYPTSETUP --x--
+ make -C TEST-02-CRYPTSETUP clean setup run
+ make -C TEST-02-CRYPTSETUP BUILD_DIR=/home/zbyszek/src/systemd/build clean setup run
If one of the tests fails, then $subdir/test.log contains the log file of
the test.
@ -41,14 +41,6 @@ $ sudo make -C test/TEST-01-BASIC BUILD_DIR=../../some-other-build/ ...
Note that in the second case, the path is relative to the test case directory.
An absolute path may also be used in both cases.
Testing installed binaries instead of built
===========================================
To run the extended testsuite using the systemd installed on the system instead
of the systemd from a build, use the NO_BUILD=1:
$ sudo NO_BUILD=1 test/run-integration-tests
Configuration variables
=======================

View File

@ -1,4 +1,6 @@
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
all setup run clean clean-again:
@TEST_BASE_DIR=../ ./test.sh --$@
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
.PHONY: all setup run clean clean-again

View File

@ -9,9 +9,8 @@ TEST_REQUIRE_INSTALL_TESTS=0
test_append_files() {
# install tests manually so the test is functional even when -Dinstall-tests=false
local dst="$1/usr/lib/systemd/tests/testdata/units/"
mkdir -p "$dst"
cp -v $TEST_UNITS_DIR/{testsuite-01,end}.service $TEST_UNITS_DIR/testsuite.target "$dst"
mkdir -p $1/usr/lib/systemd/tests/testdata/units/
cp -v $(dirname $0)/../units/{testsuite-01,end}.service $1/usr/lib/systemd/tests/testdata/units/
}
do_test "$@" 01

View File

@ -1,5 +1,7 @@
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
all setup run clean clean-again:
@TEST_BASE_DIR=../ ./test.sh --$@
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
# finish option is used to run checks that can only be run outside of
# the test execution. Example case, honor first shutdown, proof is obtained
@ -9,6 +11,6 @@ all setup run clean clean-again:
# the test will loop and will be terminated via a command timeout.
# This just provides concrete confirmation.
finish:
@TEST_BASE_DIR=../ ./fini.sh --$@
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./fini.sh --$@
.PHONY: all setup run clean clean-again finish

View File

@ -1,46 +1,14 @@
#!/usr/bin/env bash
set -e
if [ "$NO_BUILD" ]; then
BUILD_DIR=""
elif BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"; then
ninja -C "$BUILD_DIR"
else
echo "No build found, please set BUILD_DIR or NO_BUILD" >&2
exit 1
fi
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
if [ $# -gt 0 ]; then
args="$*"
args="$@"
else
args="setup run clean-again"
fi
VALID_TARGETS="all setup run clean clean-again"
is_valid_target() {
for target in $VALID_TARGETS; do
[ "$1" = "$target" ] && return 0
done
return 1
}
# reject invalid make targets in $args
for arg in $args; do
if ! is_valid_target "$arg"; then
echo "Invalid target: $arg" >&2
exit 1
fi
done
CLEAN=0
CLEANAGAIN=0
# separate 'clean' and 'clean-again' operations
[[ "$args" =~ "clean-again" ]] && CLEANAGAIN=1
args=${args/clean-again}
[[ "$args" =~ "clean" ]] && CLEAN=1
args=${args/clean}
args_no_clean=$(sed -r 's/\bclean.*\b//g' <<<$args)
do_clean=$( [ "$args" = "$args_no_clean" ]; echo $? )
declare -A results
declare -A times
@ -50,6 +18,16 @@ FAILURES=0
cd "$(dirname "$0")"
# Let's always do the cleaning operation first, because it destroys the image
# cache.
if [ $do_clean = 1 ]; then
for TEST in TEST-??-* ; do
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean )
done
[ -n "$args_no_clean" ] || exit 0
fi
pass_deny_list() {
for marker in $DENY_LIST_MARKERS $BLACKLIST_MARKERS; do
if [ -f "$1/$marker" ]; then
@ -60,40 +38,28 @@ pass_deny_list() {
return 0
}
# Let's always do the cleaning operation first, because it destroys the image
# cache.
if [ $CLEAN = 1 ]; then
for TEST in TEST-??-* ; do
( set -x ; make -C "$TEST" clean )
done
fi
for TEST in TEST-??-* ; do
COUNT=$(($COUNT+1))
# Run actual tests (if requested)
if [[ $args =~ [a-z] ]]; then
for TEST in TEST-??-* ; do
COUNT=$(($COUNT+1))
pass_deny_list $TEST || continue
start=$(date +%s)
pass_deny_list $TEST || continue
start=$(date +%s)
echo -e "\n--x-- Running $TEST --x--"
set +e
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" $args_no_clean )
RESULT=$?
set -e
echo "--x-- Result of $TEST: $RESULT --x--"
echo -e "\n--x-- Running $TEST --x--"
set +e
( set -x ; make -C "$TEST" $args )
RESULT=$?
set -e
echo "--x-- Result of $TEST: $RESULT --x--"
results["$TEST"]="$RESULT"
times["$TEST"]=$(( $(date +%s) - $start ))
results["$TEST"]="$RESULT"
times["$TEST"]=$(( $(date +%s) - $start ))
[ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1))
done
[ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1))
done
fi
# Run clean-again, if requested, and if no tests failed
if [ $FAILURES -eq 0 -a $CLEANAGAIN = 1 ]; then
if [ $FAILURES -eq 0 -a $do_clean = 1 ]; then
for TEST in ${!results[@]}; do
( set -x ; make -C "$TEST" clean-again )
( set -x ; make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean-again )
done
fi

View File

@ -43,22 +43,6 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
ROOTLIBDIR=/usr/lib/systemd
fi
# The calling test.sh scripts have TEST_BASE_DIR set via their Makefile, but we don't need them to provide it
TEST_BASE_DIR=${TEST_BASE_DIR:-$(realpath $(dirname "$BASH_SOURCE"))}
TEST_UNITS_DIR="$TEST_BASE_DIR/units"
SOURCE_DIR=$(realpath "$TEST_BASE_DIR/..")
TOOLS_DIR="$SOURCE_DIR/tools"
# note that find-build-dir.sh will return $BUILD_DIR if provided, else it will try to find it
if ! BUILD_DIR=$($TOOLS_DIR/find-build-dir.sh); then
if [ "$NO_BUILD" ]; then
BUILD_DIR=$SOURCE_DIR
else
echo "ERROR: no build found, please set BUILD_DIR or use NO_BUILD" >&2
exit 1
fi
fi
PATH_TO_INIT=$ROOTLIBDIR/systemd
[ "$SYSTEMD_JOURNALD" ] || SYSTEMD_JOURNALD=$(which -a $BUILD_DIR/systemd-journald $ROOTLIBDIR/systemd-journald 2>/dev/null | grep '^/' -m1)
[ "$SYSTEMD_JOURNAL_REMOTE" ] || SYSTEMD_JOURNAL_REMOTE=$(which -a $BUILD_DIR/systemd-journal-remote $ROOTLIBDIR/systemd-journal-remote 2>/dev/null | grep '^/' -m1)
@ -66,17 +50,6 @@ PATH_TO_INIT=$ROOTLIBDIR/systemd
[ "$SYSTEMD_NSPAWN" ] || SYSTEMD_NSPAWN=$(which -a $BUILD_DIR/systemd-nspawn systemd-nspawn 2>/dev/null | grep '^/' -m1)
[ "$JOURNALCTL" ] || JOURNALCTL=$(which -a $BUILD_DIR/journalctl journalctl 2>/dev/null | grep '^/' -m1)
TESTFILE=${BASH_SOURCE[1]}
if [ -z "$TESTFILE" ]; then
echo "ERROR: test-functions must be sourced from one of the TEST-*/test.sh scripts" >&2
exit 1
fi
TESTNAME=$(basename $(dirname $(realpath $TESTFILE)))
STATEDIR="$BUILD_DIR/test/$TESTNAME"
STATEFILE="$STATEDIR/.testdir"
IMAGESTATEDIR="$STATEDIR/.."
TESTLOG="$STATEDIR/test.log"
BASICTOOLS=(
awk
basename
@ -175,6 +148,11 @@ DEBUGTOOLS=(
vi
)
STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
STATEFILE="$STATEDIR/.testdir"
IMAGESTATEDIR="$STATEDIR/.."
TESTLOG="$STATEDIR/test.log"
is_built_with_asan() {
if ! type -P objdump >/dev/null; then
ddebug "Failed to find objdump. Assuming systemd hasn't been built with ASAN."
@ -685,7 +663,7 @@ install_dmevent() {
fi
}
install_compiled_systemd() {
install_systemd() {
ddebug "Install compiled systemd"
local _ninja_bin=$(type -P ninja || type -P ninja-build)
@ -694,42 +672,6 @@ install_compiled_systemd() {
exit 1
fi
(set -x; DESTDIR=$initdir "$_ninja_bin" -C $BUILD_DIR install)
}
install_debian_systemd() {
ddebug "Install debian systemd"
local _systemd_pkgs=$(apt-cache showsrc systemd | grep -m 1 -E '^Binary:' | cut -d ':' -f 2 | tr -d ,)
local _files=""
for deb in $_systemd_pkgs; do
_files=$(dpkg-query -L $deb 2>/dev/null) || continue
ddebug "Install debian files from package $deb"
for file in $_files; do
[ -e "$file" ] || continue
[ -d "$file" ] && continue
inst $file
done
done
}
install_distro_systemd() {
ddebug "Install distro systemd"
if [ "$LOOKS_LIKE_DEBIAN" ]; then
install_debian_systemd
else
dfatal "NO_BUILD not supported for this distro"
exit 1
fi
}
install_systemd() {
if [ "$NO_BUILD" ]; then
install_distro_systemd
else
install_compiled_systemd
fi
# remove unneeded documentation
rm -fr $initdir/usr/share/{man,doc}

View File

@ -322,4 +322,4 @@ if __name__ == '__main__':
if opts.test and outdated:
exit(f'Outdated pages: {", ".join(outdated)}\n'
f'Hint: ninja -C {opts.build_dir} update-dbus-docs')
f'Hint: ninja -C {opts.build_dir} man/update-dbus-docs')

View File

@ -51,7 +51,7 @@ MESON_HEADER = '''\
# Do not edit. Generated by update-man-rules.py.
# Update with:
# ninja -C build update-man-rules
# ninja -C build man/update-man-rules
manpages = ['''
MESON_FOOTER = '''\