From 1d03d970a1d5fe33b47f8fb6e73cfd6dad1445d4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 25 Dec 2023 01:19:25 +0900 Subject: [PATCH 1/3] tree-wide: insert space after for and switch --- src/coredump/coredump.c | 2 +- src/dissect/dissect.c | 2 +- src/libsystemd/sd-bus/bus-objects.c | 2 +- src/shared/libfido2-util.c | 2 +- src/test/test-macro.c | 12 ++++++------ src/test/test-mountpoint-util.c | 2 +- src/test/test-tpm2.c | 2 +- src/udev/dmi_memory_id/dmi_memory_id.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 32c17664fd..2b6222b308 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1479,7 +1479,7 @@ static int forward_coredump_to_container(Context *context) { char buf[DECIMAL_STR_MAX(pid_t)]; const char *t = context->meta[i]; - switch(i) { + switch (i) { case META_ARGV_PID: xsprintf(buf, PID_FMT, ucred.pid); diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index f9f47cf7aa..571683cd4b 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -684,7 +684,7 @@ static int parse_argv_as_mount_helper(int argc, char *argv[]) { /* Implements util-linux "external helper" command line interface, as per mount(8) man page. */ while ((c = getopt(argc, argv, "sfnvN:o:t:")) >= 0) { - switch(c) { + switch (c) { case 'f': fake = true; diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index c25c40ff37..e528987a6d 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -1701,7 +1701,7 @@ static bool names_are_valid(const char *signature, const char **names, names_fla if ((*flags & NAMES_FIRST_PART || *flags & NAMES_SINGLE_PART) && **names != '\0') *flags |= NAMES_PRESENT; - for (;*flags & NAMES_PRESENT;) { + while (*flags & NAMES_PRESENT) { size_t l; if (!*signature) diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index 1cc3afe6b9..43efa3529a 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -574,7 +574,7 @@ static int fido2_use_hmac_hash_specific_token( /* COSE_ECDH_ES256 is not usable with fido_cred_set_type() thus it's not listed here. */ static const char *fido2_algorithm_to_string(int alg) { - switch(alg) { + switch (alg) { case COSE_ES256: return "es256"; case COSE_RS256: diff --git a/src/test/test-macro.c b/src/test/test-macro.c index b91a1f96ac..95b70142aa 100644 --- a/src/test/test-macro.c +++ b/src/test/test-macro.c @@ -306,7 +306,7 @@ TEST(FOREACH_VA_ARGS) { i = 0; uint8_t u8, u8_1 = 1, u8_2 = 2, u8_3 = 3; VA_ARGS_FOREACH(u8, u8_2, 8, 0xff, u8_1, u8_3, 0, 1) { - switch(i++) { + switch (i++) { case 0: assert_se(u8 == u8_2); break; case 1: assert_se(u8 == 8); break; case 2: assert_se(u8 == 0xff); break; @@ -336,7 +336,7 @@ TEST(FOREACH_VA_ARGS) { i = 0; uint32_t u32, u32_1 = 0xffff0000, u32_2 = 10, u32_3 = 0xffff; VA_ARGS_FOREACH(u32, 1, 100, u32_2, 1000, u32_3, u32_1, 1, 0) { - switch(i++) { + switch (i++) { case 0: assert_se(u32 == 1); break; case 1: assert_se(u32 == 100); break; case 2: assert_se(u32 == u32_2); break; @@ -367,7 +367,7 @@ TEST(FOREACH_VA_ARGS) { i = 0; uint64_t u64, u64_1 = 0xffffffffffffffff, u64_2 = 50, u64_3 = 0xffff; VA_ARGS_FOREACH(u64, 44, 0, u64_3, 100, u64_2, u64_1, 50000) { - switch(i++) { + switch (i++) { case 0: assert_se(u64 == 44); break; case 1: assert_se(u64 == 0); break; case 2: assert_se(u64 == u64_3); break; @@ -406,7 +406,7 @@ TEST(FOREACH_VA_ARGS) { s_3 = { .a = 0xff, .b = 'q', }, s_4 = { .a = 1, .b = 'x', }; VA_ARGS_FOREACH(s, s_1, (struct test){ .a = 10, .b = 'd', }, s_2, (struct test){}, s_3, s_4) { - switch(i++) { + switch (i++) { case 0: assert_se(s.a == 0 ); assert_se(s.b == 'c'); break; case 1: assert_se(s.a == 10 ); assert_se(s.b == 'd'); break; case 2: assert_se(s.a == 100000); assert_se(s.b == 'z'); break; @@ -430,7 +430,7 @@ TEST(FOREACH_VA_ARGS) { i = 0; struct test *p, *p_1 = &s_1, *p_2 = &s_2, *p_3 = &s_3, *p_4 = &s_4; VA_ARGS_FOREACH(p, p_1, NULL, p_2, p_3, NULL, p_4, NULL) { - switch(i++) { + switch (i++) { case 0: assert_se(p == p_1); break; case 1: assert_se(p == NULL); break; case 2: assert_se(p == p_2); break; @@ -455,7 +455,7 @@ TEST(FOREACH_VA_ARGS) { void *v, *v_1 = p_1, *v_2 = p_2, *v_3 = p_3; uint32_t *u32p = &u32; VA_ARGS_FOREACH(v, v_1, NULL, u32p, v_3, p_2, p_4, v_2, NULL) { - switch(i++) { + switch (i++) { case 0: assert_se(v == v_1); break; case 1: assert_se(v == NULL); break; case 2: assert_se(v == u32p); break; diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 40b12dd088..0c1b849c89 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -69,7 +69,7 @@ TEST(mnt_id) { assert_se(sscanf(line, "%i %*s %*s %*s %ms", &mnt_id, &path) == 2); #if HAS_FEATURE_MEMORY_SANITIZER /* We don't know the length of the string, so we need to unpoison it one char at a time */ - for (const char *c = path; ;c++) { + for (const char *c = path; ; c++) { msan_unpoison(c, 1); if (!*c) break; diff --git a/src/test/test-tpm2.c b/src/test/test-tpm2.c index 06b9800dec..19881c6e91 100644 --- a/src/test/test-tpm2.c +++ b/src/test/test-tpm2.c @@ -74,7 +74,7 @@ TEST(tpm2_util_pbkdf2_hmac_sha256) { }; uint8_t res[SHA256_DIGEST_SIZE]; - for(size_t i = 0; i < sizeof(test_vectors)/sizeof(test_vectors[0]); i++) { + for (size_t i = 0; i < sizeof(test_vectors)/sizeof(test_vectors[0]); i++) { int rc = tpm2_util_pbkdf2_hmac_sha256( test_vectors[i].pass, diff --git a/src/udev/dmi_memory_id/dmi_memory_id.c b/src/udev/dmi_memory_id/dmi_memory_id.c index 37c098adc8..9ad41403ba 100644 --- a/src/udev/dmi_memory_id/dmi_memory_id.c +++ b/src/udev/dmi_memory_id/dmi_memory_id.c @@ -96,7 +96,7 @@ static const char *dmi_string(const struct dmi_header *dm, uint8_t s) { return "Not Specified"; bp += dm->length; - for (;s > 1 && !isempty(bp); s--) + for (; s > 1 && !isempty(bp); s--) bp += strlen(bp) + 1; if (isempty(bp)) From b3a9d980f303ab49614eee336fb9c54e98c9e530 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 25 Dec 2023 01:41:11 +0900 Subject: [PATCH 2/3] tree-wide: drop space between variable and an increment/decrement --- src/basic/env-util.c | 2 +- src/basic/path-util.h | 2 +- src/basic/socket-util.c | 2 +- src/boot/bootctl.c | 2 +- src/core/dbus-job.c | 2 +- src/core/namespace.c | 8 ++++---- src/core/path.c | 2 +- src/core/service.c | 2 +- src/core/unit.c | 2 +- src/cryptenroll/cryptenroll-tpm2.c | 2 +- src/cryptenroll/cryptenroll.c | 2 +- src/delta/delta.c | 4 ++-- src/firstboot/firstboot.c | 2 +- src/home/user-record-sign.c | 4 ++-- src/import/qcow2-util.c | 2 +- src/journal/journald-context.c | 2 +- src/libsystemd-network/dhcp-option.c | 4 ++-- src/libsystemd/sd-bus/bus-creds.c | 2 +- src/libsystemd/sd-daemon/sd-daemon.c | 2 +- src/libsystemd/sd-device/sd-device.c | 2 +- src/libsystemd/sd-event/sd-event.c | 6 +++--- src/machine/machinectl.c | 2 +- src/network/networkd-dhcp-server.c | 2 +- src/nspawn/nspawn-bind-user.c | 2 +- src/nspawn/nspawn-oci.c | 2 +- src/nspawn/nspawn.c | 2 +- src/resolve/resolved-dns-transaction.c | 2 +- src/shared/bitmap.c | 4 ++-- src/shared/compare-operator.c | 2 +- src/shared/cryptsetup-fido2.c | 2 +- src/shared/dissect-image.c | 2 +- src/shared/fdset.c | 2 +- src/shared/format-table.c | 2 +- src/shared/fstab-util.c | 4 ++-- src/shared/hwdb-util.c | 2 +- src/shared/install.c | 2 +- src/shared/json.c | 10 +++++----- src/shared/loopback-setup.c | 6 +++--- src/shared/mount-setup.c | 2 +- src/shared/rm-rf.c | 2 +- src/shared/varlink-idl.c | 4 ++-- src/shutdown/detach-dm.c | 2 +- src/shutdown/detach-md.c | 2 +- src/sysext/sysext.c | 2 +- src/sysv-generator/sysv-generator.c | 2 +- src/test/test-bus-util.c | 2 +- src/test/test-capability.c | 2 +- src/test/test-mempool.c | 8 ++++---- 48 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 7ac47732ba..23a128bfd1 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -683,7 +683,7 @@ int replace_env_full( pu = ret_unset_variables ? &unset_variables : NULL; pb = ret_bad_variables ? &bad_variables : NULL; - for (e = format, i = 0; *e && i < n; e ++, i ++) + for (e = format, i = 0; *e && i < n; e++, i++) switch (state) { case WORD: diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 6d943e967f..39b6714525 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -156,7 +156,7 @@ int fsck_exists_for_fstype(const char *fstype); char *_p, *_n; \ size_t _l; \ while (_path[0] == '/' && _path[1] == '/') \ - _path ++; \ + _path++; \ if (isempty(_root)) \ _ret = _path; \ else { \ diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 4f28d16b5e..86472c8847 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -547,7 +547,7 @@ int sockaddr_pretty( } else { if (path[path_len - 1] == '\0') /* We expect a terminating NUL and don't print it */ - path_len --; + path_len--; p = cescape_length(path, path_len); } diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 4614ca1780..f608e8cc8e 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -324,7 +324,7 @@ static int parse_argv(int argc, char *argv[]) { break; case 'R': - arg_print_root_device ++; + arg_print_root_device++; break; case ARG_NO_VARIABLES: diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index c88d8c2dd5..56ad88570f 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -87,7 +87,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 (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/namespace.c b/src/core/namespace.c index 50d7b05aa0..df6d0b4485 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1469,7 +1469,7 @@ static int follow_symlink( mount_entry_consume_prefix(m, TAKE_PTR(target)); - m->n_followed ++; + m->n_followed++; return 0; } @@ -2625,7 +2625,7 @@ int bind_mount_add(BindMount **b, size_t *n, const BindMount *item) { *b = c; - c[(*n) ++] = (BindMount) { + c[(*n)++] = (BindMount) { .source = TAKE_PTR(s), .destination = TAKE_PTR(d), .read_only = item->read_only, @@ -2694,7 +2694,7 @@ int mount_image_add(MountImage **m, size_t *n, const MountImage *item) { *m = c; - c[(*n) ++] = (MountImage) { + c[(*n)++] = (MountImage) { .source = TAKE_PTR(s), .destination = TAKE_PTR(d), .mount_options = TAKE_PTR(options), @@ -2745,7 +2745,7 @@ int temporary_filesystem_add( *t = c; - c[(*n) ++] = (TemporaryFileSystem) { + c[(*n)++] = (TemporaryFileSystem) { .path = TAKE_PTR(p), .options = TAKE_PTR(o), }; diff --git a/src/core/path.c b/src/core/path.c index 471d159d81..f6b5683467 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -90,7 +90,7 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) { /* If this is a symlink watch both the symlink inode and where it points to. If the inode is * not a symlink both calls will install the same watch, which is redundant and doesn't * hurt. */ - for (int follow_symlink = 0; follow_symlink < 2; follow_symlink ++) { + for (int follow_symlink = 0; follow_symlink < 2; follow_symlink++) { uint32_t f = flags; SET_FLAG(f, IN_DONT_FOLLOW, !follow_symlink); diff --git a/src/core/service.c b/src/core/service.c index 7bd4e99b11..c6251079c6 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2529,7 +2529,7 @@ static void service_enter_restart(Service *s) { /* Count the jobs we enqueue for restarting. This counter is maintained as long as the unit isn't * fully stopped, i.e. as long as it remains up or remains in auto-start states. The user can reset * the counter explicitly however via the usual "systemctl reset-failure" logic. */ - s->n_restarts ++; + s->n_restarts++; s->flush_n_restarts = false; s->notify_access_override = _NOTIFY_ACCESS_INVALID; diff --git a/src/core/unit.c b/src/core/unit.c index 0772a67001..c5d8483791 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2314,7 +2314,7 @@ void unit_start_on_failure( log_unit_warning_errno( u, r, "Failed to enqueue %s job, ignoring: %s", dependency_name, bus_error_message(&error, r)); - n_jobs ++; + n_jobs++; } if (n_jobs >= 0) diff --git a/src/cryptenroll/cryptenroll-tpm2.c b/src/cryptenroll/cryptenroll-tpm2.c index 653ad4452a..0268d8f772 100644 --- a/src/cryptenroll/cryptenroll-tpm2.c +++ b/src/cryptenroll/cryptenroll-tpm2.c @@ -25,7 +25,7 @@ static int search_policy_hash( if (hash_size == 0) return 0; - for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token ++) { + for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; _cleanup_free_ void *thash = NULL; size_t thash_size = 0; diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c index 5a7f7c3bff..687b908f06 100644 --- a/src/cryptenroll/cryptenroll.c +++ b/src/cryptenroll/cryptenroll.c @@ -571,7 +571,7 @@ static int check_for_homed(struct crypt_device *cd) { /* Politely refuse operating on homed volumes. The enrolled tokens for the user record and the LUKS2 * volume should not get out of sync. */ - for (int token = 0; token < crypt_token_max(CRYPT_LUKS2); token ++) { + for (int token = 0; token < crypt_token_max(CRYPT_LUKS2); token++) { r = cryptsetup_get_token_as_json(cd, token, "systemd-homed", NULL); if (IN_SET(r, -ENOENT, -EINVAL, -EMEDIUMTYPE)) continue; diff --git a/src/delta/delta.c b/src/delta/delta.c index 3337b7f081..3433250549 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -314,7 +314,7 @@ static int enumerate_dir( dirs[n_dirs] = strdup(de->d_name); if (!dirs[n_dirs]) return -ENOMEM; - n_dirs ++; + n_dirs++; } if (!dirent_is_file(de)) @@ -326,7 +326,7 @@ static int enumerate_dir( files[n_files] = strdup(de->d_name); if (!files[n_files]) return -ENOMEM; - n_files ++; + n_files++; } strv_sort(dirs); diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 5dd7bdb1e7..0e92c56e80 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -166,7 +166,7 @@ static int show_menu(char **x, unsigned n_columns, unsigned width, unsigned perc for (i = 0; i < per_column; i++) { - for (j = 0; j < n_columns; j ++) { + for (j = 0; j < n_columns; j++) { _cleanup_free_ char *e = NULL; if (j * per_column + i >= n) diff --git a/src/home/user-record-sign.c b/src/home/user-record-sign.c index dd099a0a6f..25618d0343 100644 --- a/src/home/user-record-sign.c +++ b/src/home/user-record-sign.c @@ -136,11 +136,11 @@ int user_record_verify(UserRecord *ur, EVP_PKEY *public_key) { return -EIO; if (EVP_DigestVerify(md_ctx, signature, signature_size, (uint8_t*) text, strlen(text)) <= 0) { - n_bad ++; + n_bad++; continue; } - n_good ++; + n_good++; } return n_good > 0 ? (n_bad == 0 ? USER_RECORD_SIGNED_EXCLUSIVE : USER_RECORD_SIGNED) : diff --git a/src/import/qcow2-util.c b/src/import/qcow2-util.c index c70656bc0e..fc34f30603 100644 --- a/src/import/qcow2-util.c +++ b/src/import/qcow2-util.c @@ -273,7 +273,7 @@ int qcow2_convert(int qcow2_fd, int raw_fd) { if ((uint64_t) l != sz) return -EIO; - for (i = 0; i < HEADER_L1_SIZE(&header); i ++) { + for (i = 0; i < HEADER_L1_SIZE(&header); i++) { uint64_t l2_begin, j; r = normalize_offset(&header, l1_table[i], &l2_begin, NULL, NULL); diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index 78401f9857..b44f70006b 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -612,7 +612,7 @@ static void client_context_try_shrink_to(Server *s, size_t limit) { if (pid_is_unwaited(c->pid) == 0) client_context_free(s, c); else - idx ++; + idx++; } s->last_cache_pid_flush = t; diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c index 5e216c5139..4025dd3632 100644 --- a/src/libsystemd-network/dhcp-option.c +++ b/src/libsystemd-network/dhcp-option.c @@ -283,7 +283,7 @@ static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overlo int r; while (offset < buflen) { - code = options[offset ++]; + code = options[offset++]; switch (code) { case SD_DHCP_OPTION_PAD: @@ -296,7 +296,7 @@ static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overlo if (buflen < offset + 1) return -ENOBUFS; - len = options[offset ++]; + len = options[offset++]; if (buflen < offset + len) return -EINVAL; diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index c6d8caaf6d..33ae2a00f6 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -731,7 +731,7 @@ static int parse_caps(sd_bus_creds *c, unsigned offset, const char *p) { return -ENOMEM; } - for (i = 0; i < sz; i ++) { + for (i = 0; i < sz; i++) { uint32_t v = 0; for (j = 0; j < 8; ++j) { diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 6a60cde4bb..0eb0797e08 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -76,7 +76,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 (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) { r = fd_cloexec(fd, true); if (r < 0) goto finish; diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 1847ca4de0..071e72707e 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -2488,7 +2488,7 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, /* drop trailing newlines */ while (len > 0 && strchr(NEWLINE, _value[len - 1])) - len --; + len--; /* value length is limited to 4k */ if (len > 4096) diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 288798a0dc..b556fdb534 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -1165,10 +1165,10 @@ static int source_set_pending(sd_event_source *s, bool b) { assert(s->inotify.inode_data->inotify_data); if (b) - s->inotify.inode_data->inotify_data->n_pending ++; + s->inotify.inode_data->inotify_data->n_pending++; else { assert(s->inotify.inode_data->inotify_data->n_pending > 0); - s->inotify.inode_data->inotify_data->n_pending --; + s->inotify.inode_data->inotify_data->n_pending--; } } @@ -4000,7 +4000,7 @@ static int process_inotify(sd_event *e) { if (r < 0) return r; if (r > 0) - done ++; + done++; } return done; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 3eadb5f4e7..c762e76fc6 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -2740,7 +2740,7 @@ static int parse_argv(int argc, char *argv[]) { /* If we already found the "shell" verb on the command line, and now found the next * non-option argument, then this is the machine name and we should stop processing * further arguments. */ - optind --; /* don't process this argument, go one step back */ + optind--; /* don't process this argument, go one step back */ goto done; } if (streq(optarg, "shell")) diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c index 607fe0053c..a486fd8927 100644 --- a/src/network/networkd-dhcp-server.c +++ b/src/network/networkd-dhcp-server.c @@ -423,7 +423,7 @@ static int dhcp4_server_configure(Link *link) { return log_link_warning_errno(link, r, "Failed to %s Rapid Commit support for DHCPv4 server instance: %m", enable_disable(link->network->dhcp_server_rapid_commit)); - for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) { + for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type++) { if (!link->network->dhcp_server_emit[type].emit) continue; diff --git a/src/nspawn/nspawn-bind-user.c b/src/nspawn/nspawn-bind-user.c index 0a8653033d..810ddbb45a 100644 --- a/src/nspawn/nspawn-bind-user.c +++ b/src/nspawn/nspawn-bind-user.c @@ -153,7 +153,7 @@ static int find_free_uid(const char *directory, uid_t max_uid, uid_t *current_ui assert(directory); assert(current_uid); - for (;; (*current_uid) ++) { + for (;; (*current_uid)++) { if (*current_uid > MAP_UID_MAX || *current_uid > max_uid) return log_error_errno( SYNTHETIC_ERRNO(EBUSY), diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index 8f1ac7ccad..e3b6f895d1 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -2082,7 +2082,7 @@ static int oci_hooks_array(const char *name, JsonVariant *v, JsonDispatchFlags f return r; } - (*n_array) ++; + (*n_array)++; } return 0; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index fb9df3d053..4d3783e00a 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -4455,7 +4455,7 @@ static int merge_settings(Settings *settings, const char *path) { #endif } - for (rl = 0; rl < _RLIMIT_MAX; rl ++) { + for (rl = 0; rl < _RLIMIT_MAX; rl++) { if ((arg_settings_mask & (SETTING_RLIMIT_FIRST << rl))) continue; diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index fe88e502e7..c1d0603a18 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -489,7 +489,7 @@ static int dns_transaction_pick_server(DnsTransaction *t) { dns_server_unref(t->server); t->server = dns_server_ref(server); - t->n_picked_servers ++; + t->n_picked_servers++; log_debug("Using DNS server %s for transaction %u.", strna(dns_server_string_full(t->server)), t->id); diff --git a/src/shared/bitmap.c b/src/shared/bitmap.c index 6cf08b898f..9aa766139b 100644 --- a/src/shared/bitmap.c +++ b/src/shared/bitmap.c @@ -163,9 +163,9 @@ bool bitmap_iterate(const Bitmap *b, Iterator *i, unsigned *n) { rem = BITMAP_NUM_TO_REM(i->idx); bitmask = UINT64_C(1) << rem; - for (; offset < b->n_bitmaps; offset ++) { + for (; offset < b->n_bitmaps; offset++) { if (b->bitmaps[offset]) { - for (; bitmask; bitmask <<= 1, rem ++) { + for (; bitmask; bitmask <<= 1, rem++) { if (b->bitmaps[offset] & bitmask) { *n = BITMAP_OFFSET_TO_NUM(offset, rem); i->idx = *n + 1; diff --git a/src/shared/compare-operator.c b/src/shared/compare-operator.c index 0da28fc5c6..233e9c6b00 100644 --- a/src/shared/compare-operator.c +++ b/src/shared/compare-operator.c @@ -40,7 +40,7 @@ CompareOperator parse_compare_operator(const char **s, CompareOperatorParseFlags * parse_compare_operator() are use on the same string? */ return _COMPARE_OPERATOR_INVALID; - for (size_t i = 0; i < ELEMENTSOF(table); i ++) { + for (size_t i = 0; i < ELEMENTSOF(table); i++) { const char *e; if (table[i].need_mask != 0 && !FLAGS_SET(flags, table[i].need_mask)) diff --git a/src/shared/cryptsetup-fido2.c b/src/shared/cryptsetup-fido2.c index 285b82a7e2..6e559e17f4 100644 --- a/src/shared/cryptsetup-fido2.c +++ b/src/shared/cryptsetup-fido2.c @@ -150,7 +150,7 @@ int acquire_fido2_key_auto( /* Loads FIDO2 metadata from LUKS2 JSON token headers. */ - for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token ++) { + for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL; JsonVariant *w; _cleanup_free_ void *salt = NULL; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 98690367a1..6b0e5fe248 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -3396,7 +3396,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_ assert(m); - for (; n_meta_initialized < _META_MAX; n_meta_initialized ++) { + for (; n_meta_initialized < _META_MAX; n_meta_initialized++) { assert(paths[n_meta_initialized]); if (pipe2(fds + 2*n_meta_initialized, O_CLOEXEC) < 0) { diff --git a/src/shared/fdset.c b/src/shared/fdset.c index e5b8e92e80..b408a38c37 100644 --- a/src/shared/fdset.c +++ b/src/shared/fdset.c @@ -246,7 +246,7 @@ int fdset_new_listen_fds(FDSet **ret, bool unset) { return -ENOMEM; n = sd_listen_fds(unset); - for (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 = fdset_put(s, fd); if (r < 0) return r; diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 41471dade0..66704f4660 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -2632,7 +2632,7 @@ int table_print(Table *t, FILE *f) { } fputc('\n', f); - n_subline ++; + n_subline++; } while (more_sublines); } diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c index 55e76b6e16..ef3dae5b62 100644 --- a/src/shared/fstab-util.c +++ b/src/shared/fstab-util.c @@ -226,9 +226,9 @@ int fstab_filter_options( if (IN_SET(*end, ',', '\0')) break; assert(*end == '\\'); - end ++; /* Skip the backslash */ + end++; /* Skip the backslash */ if (*end != '\0') - end ++; /* Skip the escaped char, but watch out for a trailing comma */ + end++; /* Skip the escaped char, but watch out for a trailing comma */ } NULSTR_FOREACH(name, names) { diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c index 648bfc5026..d96902c7f2 100644 --- a/src/shared/hwdb-util.c +++ b/src/shared/hwdb-util.c @@ -484,7 +484,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr if (r == 0) break; - line_number ++; + line_number++; /* comment line */ if (line[0] == '#') diff --git a/src/shared/install.c b/src/shared/install.c index 265407f080..ad30e9b49c 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1810,7 +1810,7 @@ int unit_file_verify_alias( _cleanup_free_ char *dir = NULL; char *p; - path_alias ++; /* skip over slash */ + path_alias++; /* skip over slash */ r = path_extract_directory(dst, &dir); if (r < 0) diff --git a/src/shared/json.c b/src/shared/json.c index 06c9e850ea..af2fc9aa70 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -559,7 +559,7 @@ static int _json_variant_array_put_element(JsonVariant *array, JsonVariant *elem return -ELNRNG; if (d >= array->depth) array->depth = d + 1; - array->n_elements ++; + array->n_elements++; *w = (JsonVariant) { .is_embedded = true, @@ -2310,7 +2310,7 @@ static int json_variant_copy(JsonVariant **nv, JsonVariant *v) { source = json_variant_string(v); k = strnlen(source, INLINE_STRING_MAX + 1); if (k <= INLINE_STRING_MAX) { - k ++; + k++; break; } @@ -2594,7 +2594,7 @@ static int json_parse_string(const char **p, char **ret) { return -ENOMEM; s[n++] = ch; - c ++; + c++; continue; } @@ -4574,7 +4574,7 @@ int json_dispatch_full( } } - done ++; + done++; } else { /* Didn't find a matching entry! ☹️ */ @@ -4589,7 +4589,7 @@ int json_dispatch_full( return r; } else - done ++; + done++; } else { json_log(value, flags, 0, "Unexpected object field '%s'.", json_variant_string(key)); diff --git a/src/shared/loopback-setup.c b/src/shared/loopback-setup.c index a02baf8399..84d723487a 100644 --- a/src/shared/loopback-setup.c +++ b/src/shared/loopback-setup.c @@ -60,7 +60,7 @@ static int start_loopback(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - s->n_messages ++; + s->n_messages++; return 0; } @@ -95,7 +95,7 @@ static int add_ipv4_address(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - s->n_messages ++; + s->n_messages++; return 0; } @@ -136,7 +136,7 @@ static int add_ipv6_address(sd_netlink *rtnl, struct state *s) { if (r < 0) return r; - s->n_messages ++; + s->n_messages++; return 0; } diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c index 1226ca121e..d9de2789a5 100644 --- a/src/shared/mount-setup.c +++ b/src/shared/mount-setup.c @@ -135,7 +135,7 @@ bool mount_point_is_api(const char *path) { /* Checks if this mount point is considered "API", and hence * should be ignored */ - for (size_t i = 0; i < ELEMENTSOF(mount_table); i ++) + for (size_t i = 0; i < ELEMENTSOF(mount_table); i++) if (path_equal(path, mount_table[i].where)) return true; diff --git a/src/shared/rm-rf.c b/src/shared/rm-rf.c index 4664215e90..767db48cc0 100644 --- a/src/shared/rm-rf.c +++ b/src/shared/rm-rf.c @@ -326,7 +326,7 @@ static int rm_rf_children_impl( dirname = mfree(dirname); /* And now let's back out one level up */ - n_todo --; + n_todo--; d = TAKE_PTR(todos[n_todo].dir); dirname = TAKE_PTR(todos[n_todo].dirname); old_mode = todos[n_todo].old_mode; diff --git a/src/shared/varlink-idl.c b/src/shared/varlink-idl.c index 655324c6c3..858b493d2f 100644 --- a/src/shared/varlink-idl.c +++ b/src/shared/varlink-idl.c @@ -401,7 +401,7 @@ static int varlink_interface_realloc(VarlinkInterface **interface, size_t n_symb assert(interface); - n_symbols ++; /* Space for trailing NULL end marker symbol */ + n_symbols++; /* Space for trailing NULL end marker symbol */ /* Overflow check */ if (n_symbols > (SIZE_MAX - offsetof(VarlinkInterface, symbols)) / sizeof(VarlinkSymbol*)) @@ -420,7 +420,7 @@ static int varlink_symbol_realloc(VarlinkSymbol **symbol, size_t n_fields) { assert(symbol); - n_fields ++; /* Space for trailing end marker field */ + n_fields++; /* Space for trailing end marker field */ /* Overflow check */ if (n_fields > (SIZE_MAX - offsetof(VarlinkSymbol, fields)) / sizeof(VarlinkField)) diff --git a/src/shutdown/detach-dm.c b/src/shutdown/detach-dm.c index 8b8f72d678..f6f672c75a 100644 --- a/src/shutdown/detach-dm.c +++ b/src/shutdown/detach-dm.c @@ -132,7 +132,7 @@ static int dm_points_list_detach(DeviceMapper **head, bool *changed, bool last_t if ((major(rootdev) != 0 && rootdev == m->devnum) || (major(usrdev) != 0 && usrdev == m->devnum)) { log_debug("Not detaching DM %s that backs the OS itself, skipping.", m->path); - n_failed ++; + n_failed++; continue; } diff --git a/src/shutdown/detach-md.c b/src/shutdown/detach-md.c index cf3130d4a7..ac46670f04 100644 --- a/src/shutdown/detach-md.c +++ b/src/shutdown/detach-md.c @@ -153,7 +153,7 @@ static int md_points_list_detach(RaidDevice **head, bool *changed, bool last_try if ((major(rootdev) != 0 && rootdev == m->devnum) || (major(usrdev) != 0 && usrdev == m->devnum)) { log_debug("Not detaching MD %s that backs the OS itself, skipping.", m->path); - n_failed ++; + n_failed++; continue; } diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 33cb8c1963..fe11fe0f07 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -854,7 +854,7 @@ static int merge_subprocess( if (r < 0) return log_oom(); - n_extensions ++; + n_extensions++; } /* Nothing left? Then shortcut things */ diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 4485e2e368..5689a60d78 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -807,7 +807,7 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic return r; STRV_FOREACH(p, sysvrcnd_path) - for (unsigned i = 0; i < ELEMENTSOF(rcnd_table); i ++) { + for (unsigned i = 0; i < ELEMENTSOF(rcnd_table); i++) { _cleanup_closedir_ DIR *d = NULL; _cleanup_free_ char *path = NULL; diff --git a/src/test/test-bus-util.c b/src/test/test-bus-util.c index 2f52bca59a..2cf44d6e5a 100644 --- a/src/test/test-bus-util.c +++ b/src/test/test-bus-util.c @@ -11,7 +11,7 @@ static int callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) static void destroy_callback(void *userdata) { int *n_called = userdata; - (*n_called) ++; + (*n_called)++; } TEST(destroy_callback) { diff --git a/src/test/test-capability.c b/src/test/test-capability.c index e8a0569737..9df5f5ba07 100644 --- a/src/test/test-capability.c +++ b/src/test/test-capability.c @@ -54,7 +54,7 @@ static void test_last_cap_probe(void) { unsigned long p = (unsigned long)CAP_LAST_CAP; if (prctl(PR_CAPBSET_READ, p) < 0) { - for (p--; p > 0; p --) + for (p--; p > 0; p--) if (prctl(PR_CAPBSET_READ, p) >= 0) break; } else { diff --git a/src/test/test-mempool.c b/src/test/test-mempool.c index d3bc173fd4..1f071dba05 100644 --- a/src/test/test-mempool.c +++ b/src/test/test-mempool.c @@ -35,7 +35,7 @@ TEST(mempool_trim) { assert_se(!a[x] || a[x]->value == x); if (a[x]) - n_freed ++; + n_freed++; a[x] = mempool_free_tile(&test_mempool, a[x]); } @@ -46,7 +46,7 @@ TEST(mempool_trim) { for (size_t i = 2; i < NN; i += 3) { assert_se(!a[i] || a[i]->value == i); if (a[i]) - n_freed ++; + n_freed++; a[i] = mempool_free_tile(&test_mempool, a[i]); } @@ -66,7 +66,7 @@ TEST(mempool_trim) { for (size_t i = 0; i < NN; i += 1) { assert_se(!a[i] || a[i]->value == i); if (a[i]) - n_freed ++; + n_freed++; a[i] = mempool_free_tile(&test_mempool, a[i]); } @@ -77,7 +77,7 @@ TEST(mempool_trim) { for (size_t i = 0; i < NN; i += 1) { assert_se(!b[i] || b[i]->value == ~(uint64_t) i); if (b[i]) - n_freed ++; + n_freed++; b[i] = mempool_free_tile(&test_mempool, b[i]); } From 07e8c3055d1a25ef340185603dc79476288b1085 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 25 Dec 2023 02:13:49 +0900 Subject: [PATCH 3/3] tree-wide: drop several doubled space --- src/analyze/analyze-security.c | 10 +++++----- src/basic/alloc-util.h | 2 +- src/basic/cgroup-util.h | 2 +- src/basic/env-file.c | 2 +- src/shared/firewall-util.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c index 5f1b5e6970..030b206f1e 100644 --- a/src/analyze/analyze-security.c +++ b/src/analyze/analyze-security.c @@ -1651,7 +1651,7 @@ static uint64_t access_weight(const struct security_assessor *a, JsonVariant *po assert(a); val = security_assessor_find_in_policy(a, policy, "weight"); - if (val) { + if (val) { if (json_variant_is_unsigned(val)) return json_variant_unsigned(val); log_debug("JSON field 'weight' of policy for %s is not an unsigned integer, ignoring.", a->id); @@ -1666,7 +1666,7 @@ static uint64_t access_range(const struct security_assessor *a, JsonVariant *pol assert(a); val = security_assessor_find_in_policy(a, policy, "range"); - if (val) { + if (val) { if (json_variant_is_unsigned(val)) return json_variant_unsigned(val); log_debug("JSON field 'range' of policy for %s is not an unsigned integer, ignoring.", a->id); @@ -1681,7 +1681,7 @@ static const char *access_description_na(const struct security_assessor *a, Json assert(a); val = security_assessor_find_in_policy(a, policy, "description_na"); - if (val) { + if (val) { if (json_variant_is_string(val)) return json_variant_string(val); log_debug("JSON field 'description_na' of policy for %s is not a string, ignoring.", a->id); @@ -1696,7 +1696,7 @@ static const char *access_description_good(const struct security_assessor *a, Js assert(a); val = security_assessor_find_in_policy(a, policy, "description_good"); - if (val) { + if (val) { if (json_variant_is_string(val)) return json_variant_string(val); log_debug("JSON field 'description_good' of policy for %s is not a string, ignoring.", a->id); @@ -1711,7 +1711,7 @@ static const char *access_description_bad(const struct security_assessor *a, Jso assert(a); val = security_assessor_find_in_policy(a, policy, "description_bad"); - if (val) { + if (val) { if (json_variant_is_string(val)) return json_variant_string(val); log_debug("JSON field 'description_bad' of policy for %s is not a string, ignoring.", a->id); diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index 4f86334d7d..5fbfff0af4 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -112,7 +112,7 @@ static inline bool size_multiply_overflow(size_t size, size_t need) { return _unlikely_(need != 0 && size > (SIZE_MAX / need)); } -_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t size, size_t need) { +_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t size, size_t need) { if (size_multiply_overflow(size, need)) return NULL; diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h index 6ab14c753d..be97258d16 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -215,7 +215,7 @@ int cg_is_delegated_fd(int fd); int cg_has_coredump_receive(const char *path); -typedef enum { +typedef enum { CG_KEY_MODE_GRACEFUL = 1 << 0, } CGroupKeyMode; diff --git a/src/basic/env-file.c b/src/basic/env-file.c index c2cbff4d84..2fff98f8fb 100644 --- a/src/basic/env-file.c +++ b/src/basic/env-file.c @@ -125,7 +125,7 @@ static int parse_env_file_internal( state = VALUE; if (!GREEDY_REALLOC(value, n_value+2)) - return -ENOMEM; + return -ENOMEM; value[n_value++] = c; } diff --git a/src/shared/firewall-util.h b/src/shared/firewall-util.h index 14e35bec8d..25ba0d4b3b 100644 --- a/src/shared/firewall-util.h +++ b/src/shared/firewall-util.h @@ -43,7 +43,7 @@ typedef enum NFTSetSource { NFT_SET_SOURCE_GROUP, _NFT_SET_SOURCE_MAX, _NFT_SET_SOURCE_INVALID = -EINVAL, -} NFTSetSource; +} NFTSetSource; typedef struct NFTSet { NFTSetSource source;