From fa5a025167eb861b30d384d3dc293b71914aa006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 8 Nov 2023 08:41:16 +0100 Subject: [PATCH 1/3] Rename {dual,triple}_timestamp_get to {dual,triple}_timestamp_now Those functions take a pointer to a timestamp and return a timestamp pointer, so the reader would be justified to think that those are just getters. Rename them to avoid confusion. --- src/basic/time-util.c | 4 ++-- src/basic/time-util.h | 4 ++-- src/core/execute.c | 4 ++-- src/core/main.c | 6 +++--- src/core/manager.c | 12 ++++++------ src/core/service.c | 2 +- src/core/timer.c | 4 ++-- src/core/unit-serialize.c | 2 +- src/core/unit.c | 6 +++--- src/libsystemd-network/icmp6-util-unix.c | 2 +- src/libsystemd-network/icmp6-util.c | 2 +- src/libsystemd-network/sd-dhcp-lease.c | 2 +- src/libsystemd-network/sd-dhcp-server.c | 2 +- src/libsystemd-network/sd-dhcp6-lease.c | 2 +- src/libsystemd-network/sd-lldp-rx.c | 2 +- src/libsystemd/sd-event/sd-event.c | 2 +- src/libsystemd/sd-journal/journal-file.c | 2 +- src/libsystemd/sd-journal/test-journal-append.c | 2 +- .../sd-journal/test-journal-interleaving.c | 2 +- src/libsystemd/sd-journal/test-journal-stream.c | 2 +- src/libsystemd/sd-journal/test-journal-verify.c | 2 +- src/libsystemd/sd-journal/test-journal.c | 4 ++-- src/login/logind-device.c | 2 +- src/login/logind-inhibit.c | 2 +- src/login/logind-session.c | 4 ++-- src/login/logind-user.c | 2 +- src/machine/machine.c | 2 +- src/shared/boot-timestamps.c | 2 +- src/systemctl/systemctl-list-units.c | 2 +- src/systemctl/systemctl-show.c | 2 +- src/timesync/timesyncd-manager.c | 2 +- 31 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 695b998b57..f9014dc560 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -64,7 +64,7 @@ nsec_t now_nsec(clockid_t clock_id) { return timespec_load_nsec(&ts); } -dual_timestamp* dual_timestamp_get(dual_timestamp *ts) { +dual_timestamp* dual_timestamp_now(dual_timestamp *ts) { assert(ts); ts->realtime = now(CLOCK_REALTIME); @@ -73,7 +73,7 @@ dual_timestamp* dual_timestamp_get(dual_timestamp *ts) { return ts; } -triple_timestamp* triple_timestamp_get(triple_timestamp *ts) { +triple_timestamp* triple_timestamp_now(triple_timestamp *ts) { assert(ts); ts->realtime = now(CLOCK_REALTIME); diff --git a/src/basic/time-util.h b/src/basic/time-util.h index 73ba8b9544..ed4c1aabd4 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -79,12 +79,12 @@ nsec_t now_nsec(clockid_t clock); usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock); -dual_timestamp* dual_timestamp_get(dual_timestamp *ts); +dual_timestamp* dual_timestamp_now(dual_timestamp *ts); dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u); -triple_timestamp* triple_timestamp_get(triple_timestamp *ts); +triple_timestamp* triple_timestamp_now(triple_timestamp *ts); triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u); triple_timestamp* triple_timestamp_from_boottime(triple_timestamp *ts, usec_t u); diff --git a/src/core/execute.c b/src/core/execute.c index e63137440a..1e48e88ee8 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1797,7 +1797,7 @@ void exec_status_start(ExecStatus *s, pid_t pid) { .pid = pid, }; - dual_timestamp_get(&s->start_timestamp); + dual_timestamp_now(&s->start_timestamp); } void exec_status_exit(ExecStatus *s, const ExecContext *context, pid_t pid, int code, int status) { @@ -1808,7 +1808,7 @@ void exec_status_exit(ExecStatus *s, const ExecContext *context, pid_t pid, int .pid = pid, }; - dual_timestamp_get(&s->exit_timestamp); + dual_timestamp_now(&s->exit_timestamp); s->code = code; s->status = status; diff --git a/src/core/main.c b/src/core/main.c index cfa29f3a58..2ac59dabf5 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2687,7 +2687,7 @@ static int initialize_security( assert(security_finish_timestamp); assert(ret_error_message); - dual_timestamp_get(security_start_timestamp); + dual_timestamp_now(security_start_timestamp); r = mac_selinux_setup(loaded_policy); if (r < 0) { @@ -2713,7 +2713,7 @@ static int initialize_security( return r; } - dual_timestamp_get(security_finish_timestamp); + dual_timestamp_now(security_finish_timestamp); return 0; } @@ -2819,7 +2819,7 @@ int main(int argc, char *argv[]) { /* Take timestamps early on */ dual_timestamp_from_monotonic(&kernel_timestamp, 0); - dual_timestamp_get(&userspace_timestamp); + dual_timestamp_now(&userspace_timestamp); /* Figure out whether we need to do initialize the system, or if we already did that because we are * reexecuting. */ diff --git a/src/core/manager.c b/src/core/manager.c index 6b9ce2d2ec..10f2e8e00e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1947,7 +1947,7 @@ static void manager_ready(Manager *m) { Manager* manager_reloading_start(Manager *m) { m->n_reloading++; - dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_UNITS_LOAD); + dual_timestamp_now(m->timestamps + MANAGER_TIMESTAMP_UNITS_LOAD); return m; } @@ -1971,11 +1971,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo if (r < 0) return r; - dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_START)); + dual_timestamp_now(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_START)); r = manager_run_environment_generators(m); if (r >= 0) r = manager_run_generators(m); - dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_FINISH)); + dual_timestamp_now(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_FINISH)); if (r < 0) return r; @@ -1997,10 +1997,10 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo reloading = manager_reloading_start(m); /* First, enumerate what we can from all config files */ - dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_UNITS_LOAD_START)); + dual_timestamp_now(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_UNITS_LOAD_START)); manager_enumerate_perpetual(m); manager_enumerate(m); - dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_UNITS_LOAD_FINISH)); + dual_timestamp_now(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_UNITS_LOAD_FINISH)); /* Second, deserialize if there is something to deserialize */ if (serialization) { @@ -3890,7 +3890,7 @@ void manager_check_finished(Manager *m) { /* This is no longer the first boot */ manager_set_first_boot(m, false); - dual_timestamp_get(m->timestamps + MANAGER_TIMESTAMP_FINISH); + dual_timestamp_now(m->timestamps + MANAGER_TIMESTAMP_FINISH); manager_notify_finished(m); diff --git a/src/core/service.c b/src/core/service.c index d3e8d45854..b9eb40c555 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -378,7 +378,7 @@ static void service_extend_timeout(Service *s, usec_t extend_timeout_usec) { static void service_reset_watchdog(Service *s) { assert(s); - dual_timestamp_get(&s->watchdog_timestamp); + dual_timestamp_now(&s->watchdog_timestamp); service_start_watchdog(s); } diff --git a/src/core/timer.c b/src/core/timer.c index 97233a88f6..3c41a250b0 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -382,7 +382,7 @@ static void timer_enter_waiting(Timer *t, bool time_change) { goto fail; } - triple_timestamp_get(&ts); + triple_timestamp_now(&ts); t->next_elapse_monotonic_or_boottime = t->next_elapse_realtime = 0; LIST_FOREACH(value, v, t->values) { @@ -618,7 +618,7 @@ static void timer_enter_running(Timer *t) { goto fail; } - dual_timestamp_get(&t->last_trigger); + dual_timestamp_now(&t->last_trigger); ACTIVATION_DETAILS_TIMER(details)->last_trigger = t->last_trigger; job_set_activation_details(job, details); diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c index 0ffcceaf53..3bb63d15d6 100644 --- a/src/core/unit-serialize.c +++ b/src/core/unit-serialize.c @@ -526,7 +526,7 @@ int unit_deserialize_state(Unit *u, FILE *f, FDSet *fds) { * reboots. */ if (!dual_timestamp_is_set(&u->state_change_timestamp)) - dual_timestamp_get(&u->state_change_timestamp); + dual_timestamp_now(&u->state_change_timestamp); /* Let's make sure that everything that is deserialized also gets any potential new cgroup settings * applied after we are done. For that we invalidate anything already realized, so that we can diff --git a/src/core/unit.c b/src/core/unit.c index 4bff7ced08..e865c393a3 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1779,7 +1779,7 @@ static bool unit_test_condition(Unit *u) { assert(u); - dual_timestamp_get(&u->condition_timestamp); + dual_timestamp_now(&u->condition_timestamp); r = manager_get_effective_environment(u->manager, &env); if (r < 0) { @@ -1803,7 +1803,7 @@ static bool unit_test_assert(Unit *u) { assert(u); - dual_timestamp_get(&u->assert_timestamp); + dual_timestamp_now(&u->assert_timestamp); r = manager_get_effective_environment(u->manager, &env); if (r < 0) { @@ -2740,7 +2740,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su /* Update timestamps for state changes */ if (!MANAGER_IS_RELOADING(m)) { - dual_timestamp_get(&u->state_change_timestamp); + dual_timestamp_now(&u->state_change_timestamp); if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns)) u->inactive_exit_timestamp = u->state_change_timestamp; diff --git a/src/libsystemd-network/icmp6-util-unix.c b/src/libsystemd-network/icmp6-util-unix.c index 95e050083b..01edb854df 100644 --- a/src/libsystemd-network/icmp6-util-unix.c +++ b/src/libsystemd-network/icmp6-util-unix.c @@ -44,7 +44,7 @@ int icmp6_receive( assert_se(read (fd, iov_base, iov_len) == (ssize_t) iov_len); if (ret_timestamp) - triple_timestamp_get(ret_timestamp); + triple_timestamp_now(ret_timestamp); if (ret_sender) *ret_sender = dummy_link_local; diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c index a0521f0562..25fd70b1b1 100644 --- a/src/libsystemd-network/icmp6-util.c +++ b/src/libsystemd-network/icmp6-util.c @@ -214,7 +214,7 @@ int icmp6_receive( if (triple_timestamp_is_set(&t)) *ret_timestamp = t; else - triple_timestamp_get(ret_timestamp); + triple_timestamp_now(ret_timestamp); } if (ret_sender) diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index a6e78dd071..4925fa8f19 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -39,7 +39,7 @@ void dhcp_lease_set_timestamp(sd_dhcp_lease *lease, const triple_timestamp *time if (timestamp && triple_timestamp_is_set(timestamp)) lease->timestamp = *timestamp; else - triple_timestamp_get(&lease->timestamp); + triple_timestamp_now(&lease->timestamp); } int sd_dhcp_lease_get_timestamp(sd_dhcp_lease *lease, clockid_t clock, uint64_t *ret) { diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 45c0f14d2c..ce576c24eb 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -903,7 +903,7 @@ static void request_set_timestamp(DHCPRequest *req, const triple_timestamp *time if (timestamp && triple_timestamp_is_set(timestamp)) req->timestamp = *timestamp; else - triple_timestamp_get(&req->timestamp); + triple_timestamp_now(&req->timestamp); } static int request_get_lifetime_timestamp(DHCPRequest *req, clockid_t clock, usec_t *ret) { diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index bbd005bb63..674248b83d 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -20,7 +20,7 @@ static void dhcp6_lease_set_timestamp(sd_dhcp6_lease *lease, const triple_timest if (timestamp && triple_timestamp_is_set(timestamp)) lease->timestamp = *timestamp; else - triple_timestamp_get(&lease->timestamp); + triple_timestamp_now(&lease->timestamp); } int sd_dhcp6_lease_get_timestamp(sd_dhcp6_lease *lease, clockid_t clock, uint64_t *ret) { diff --git a/src/libsystemd-network/sd-lldp-rx.c b/src/libsystemd-network/sd-lldp-rx.c index 7e2ffd4eab..2fc9a55323 100644 --- a/src/libsystemd-network/sd-lldp-rx.c +++ b/src/libsystemd-network/sd-lldp-rx.c @@ -229,7 +229,7 @@ static int lldp_rx_receive_datagram(sd_event_source *s, int fd, uint32_t revents if (ioctl(fd, SIOCGSTAMPNS, &ts) >= 0) triple_timestamp_from_realtime(&n->timestamp, timespec_load(&ts)); else - triple_timestamp_get(&n->timestamp); + triple_timestamp_now(&n->timestamp); (void) lldp_rx_handle_datagram(lldp_rx, n); return 0; diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index aba458185b..288798a0dc 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -4612,7 +4612,7 @@ static int process_epoll(sd_event *e, usec_t timeout, int64_t threshold, int64_t /* Set timestamp only when this is called first time. */ if (threshold == INT64_MAX) - triple_timestamp_get(&e->timestamp); + triple_timestamp_now(&e->timestamp); for (size_t i = 0; i < m; i++) { diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 4b74d06997..f72498c2e7 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -2530,7 +2530,7 @@ int journal_file_append_entry( "Invalid monotomic timestamp %" PRIu64 ", refusing entry.", ts->monotonic); } else { - dual_timestamp_get(&_ts); + dual_timestamp_now(&_ts); ts = &_ts; } diff --git a/src/libsystemd/sd-journal/test-journal-append.c b/src/libsystemd/sd-journal/test-journal-append.c index 90a7ccb00f..24b98c8b4a 100644 --- a/src/libsystemd/sd-journal/test-journal-append.c +++ b/src/libsystemd/sd-journal/test-journal-append.c @@ -27,7 +27,7 @@ static int journal_append_message(JournalFile *mj, const char *message) { assert(mj); assert(message); - dual_timestamp_get(&ts); + dual_timestamp_now(&ts); iovec = IOVEC_MAKE_STRING(message); return journal_file_append_entry( mj, diff --git a/src/libsystemd/sd-journal/test-journal-interleaving.c b/src/libsystemd/sd-journal/test-journal-interleaving.c index fe97a9e4a6..eff908bde0 100644 --- a/src/libsystemd/sd-journal/test-journal-interleaving.c +++ b/src/libsystemd/sd-journal/test-journal-interleaving.c @@ -64,7 +64,7 @@ static void append_number(JournalFile *f, int n, const sd_id128_t *boot_id, uint struct iovec iovec[2]; size_t n_iov = 0; - dual_timestamp_get(&ts); + dual_timestamp_now(&ts); if (ts.monotonic <= previous_ts.monotonic) ts.monotonic = previous_ts.monotonic + 1; diff --git a/src/libsystemd/sd-journal/test-journal-stream.c b/src/libsystemd/sd-journal/test-journal-stream.c index 1dbfdcd607..3a370ef311 100644 --- a/src/libsystemd/sd-journal/test-journal-stream.c +++ b/src/libsystemd/sd-journal/test-journal-stream.c @@ -85,7 +85,7 @@ static void run_test(void) { dual_timestamp ts; struct iovec iovec[2]; - dual_timestamp_get(&ts); + dual_timestamp_now(&ts); if (ts.monotonic <= previous_ts.monotonic) ts.monotonic = previous_ts.monotonic + 1; diff --git a/src/libsystemd/sd-journal/test-journal-verify.c b/src/libsystemd/sd-journal/test-journal-verify.c index d05312c88f..edce44049a 100644 --- a/src/libsystemd/sd-journal/test-journal-verify.c +++ b/src/libsystemd/sd-journal/test-journal-verify.c @@ -108,7 +108,7 @@ static int run_test(const char *verification_key, ssize_t max_iterations) { struct iovec iovec; struct dual_timestamp ts; - dual_timestamp_get(&ts); + dual_timestamp_now(&ts); assert_se(asprintf(&test, "RANDOM=%li", random() % RANDOM_RANGE)); iovec = IOVEC_MAKE_STRING(test); assert_se(journal_file_append_entry( diff --git a/src/libsystemd/sd-journal/test-journal.c b/src/libsystemd/sd-journal/test-journal.c index badf6cdb45..96f2b6719e 100644 --- a/src/libsystemd/sd-journal/test-journal.c +++ b/src/libsystemd/sd-journal/test-journal.c @@ -41,7 +41,7 @@ static void test_non_empty_one(void) { assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, JOURNAL_COMPRESS|JOURNAL_SEAL, 0666, UINT64_MAX, NULL, m, NULL, &f) == 0); - assert_se(dual_timestamp_get(&ts)); + assert_se(dual_timestamp_now(&ts)); assert_se(sd_id128_randomize(&fake_boot_id) == 0); iovec = IOVEC_MAKE_STRING(test); @@ -196,7 +196,7 @@ static bool check_compressed(uint64_t compress_threshold, uint64_t data_size) { assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, JOURNAL_COMPRESS|JOURNAL_SEAL, 0666, compress_threshold, NULL, m, NULL, &f) == 0); - dual_timestamp_get(&ts); + dual_timestamp_now(&ts); iovec = IOVEC_MAKE(data, data_size); assert_se(journal_file_append_entry(f, &ts, NULL, &iovec, 1, NULL, NULL, NULL, NULL) == 0); diff --git a/src/login/logind-device.c b/src/login/logind-device.c index f605034526..376cd0d42f 100644 --- a/src/login/logind-device.c +++ b/src/login/logind-device.c @@ -27,7 +27,7 @@ Device* device_new(Manager *m, const char *sysfs, bool master) { d->manager = m; d->master = master; - dual_timestamp_get(&d->timestamp); + dual_timestamp_now(&d->timestamp); return d; } diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 62c38f2f12..af7879f561 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -176,7 +176,7 @@ int inhibitor_start(Inhibitor *i) { if (i->started) return 0; - dual_timestamp_get(&i->since); + dual_timestamp_now(&i->since); log_debug("Inhibitor %s (%s) pid="PID_FMT" uid="UID_FMT" mode=%s started.", strna(i->who), strna(i->why), diff --git a/src/login/logind-session.c b/src/login/logind-session.c index fa62c60a9f..3f5decd8d9 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -794,7 +794,7 @@ int session_start(Session *s, sd_bus_message *properties, sd_bus_error *error) { LOG_MESSAGE("New session %s of user %s.", s->id, s->user->user_record->user_name)); if (!dual_timestamp_is_set(&s->timestamp)) - dual_timestamp_get(&s->timestamp); + dual_timestamp_now(&s->timestamp); if (s->seat) seat_read_active_vt(s->seat); @@ -1088,7 +1088,7 @@ int session_set_idle_hint(Session *s, bool b) { return 0; s->idle_hint = b; - dual_timestamp_get(&s->idle_hint_timestamp); + dual_timestamp_now(&s->idle_hint_timestamp); session_send_changed(s, "IdleHint", "IdleSinceHint", "IdleSinceHintMonotonic", NULL); diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 7a6056086a..641050f8ba 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -460,7 +460,7 @@ int user_start(User *u) { if (!u->started) { if (!dual_timestamp_is_set(&u->timestamp)) - dual_timestamp_get(&u->timestamp); + dual_timestamp_now(&u->timestamp); user_send_signal(u, true); u->started = true; } diff --git a/src/machine/machine.c b/src/machine/machine.c index ae64b430cf..44ff5c190b 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -470,7 +470,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { LOG_MESSAGE("New machine %s.", m->name)); if (!dual_timestamp_is_set(&m->timestamp)) - dual_timestamp_get(&m->timestamp); + dual_timestamp_now(&m->timestamp); m->started = true; diff --git a/src/shared/boot-timestamps.c b/src/shared/boot-timestamps.c index 8786e89c0e..e49bd8f1f2 100644 --- a/src/shared/boot-timestamps.c +++ b/src/shared/boot-timestamps.c @@ -15,7 +15,7 @@ int boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_time assert(loader); if (!n) { - dual_timestamp_get(&_n); + dual_timestamp_now(&_n); n = &_n; } diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index 34abc3cc9b..e48cf45333 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -769,7 +769,7 @@ int verb_list_timers(int argc, char *argv[], void *userdata) { if (n < 0) return n; - dual_timestamp_get(&nw); + dual_timestamp_now(&nw); FOREACH_ARRAY(u, unit_infos, n) { r = add_timer_info(bus, u, &nw, &timers, &n_timers); diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 1667ba4004..94f037615b 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -484,7 +484,7 @@ static void print_status_info( dual_timestamp nw, next = {i->next_elapse_real, i->next_elapse_monotonic}; usec_t next_elapse; - dual_timestamp_get(&nw); + dual_timestamp_now(&nw); next_elapse = calc_next_elapse(&nw, &next); if (timestamp_is_set(next_elapse)) diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 82fe668bf9..1317bc0f76 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -566,7 +566,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re m->poll_interval_usec / USEC_PER_SEC); /* Get current monotonic/realtime clocks immediately before adjusting the latter */ - triple_timestamp_get(&dts); + triple_timestamp_now(&dts); if (!spike) { /* Fix up our idea of the time. */ From ffcf54d4fb422e39c3d0a6c5f2ec62889d971bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 8 Nov 2023 09:11:07 +0100 Subject: [PATCH 2/3] core/unit: use assert for checking internal call sanity The only way this could be called with an invalid value would be if somebody forgot to initialize unit type. In such cases, it's better to fail hard immediately. --- src/core/unit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index e865c393a3..66ac9c91ec 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -5079,10 +5079,7 @@ bool unit_type_supported(UnitType t) { static int8_t cache[_UNIT_TYPE_MAX] = {}; /* -1: disabled, 1: enabled: 0: don't know */ int r; - if (_unlikely_(t < 0)) - return false; - if (_unlikely_(t >= _UNIT_TYPE_MAX)) - return false; + assert(t >= 0 && t < _UNIT_TYPE_MAX); if (cache[t] == 0) { char *e; From cee60fc36fe915c3aee52f68caa87b0b8e56cc50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 8 Nov 2023 13:50:39 +0100 Subject: [PATCH 3/3] tree-wide: use the usual spelling of "cannot" (There's a bunch more in src/basic/linux/, but those files are copied from the kernel and should not be modified.) --- meson.build | 2 +- .../cryptsetup-tokens/cryptsetup-token-systemd-fido2.c | 6 +++--- .../cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c | 2 +- .../cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c | 8 ++++---- src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c | 2 +- src/locale/localed.c | 2 +- src/resolve/resolved-dnstls-openssl.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 32a181e50d..bc61ca4801 100644 --- a/meson.build +++ b/meson.build @@ -1230,7 +1230,7 @@ libcryptsetup = get_option('libcryptsetup') libcryptsetup_plugins = get_option('libcryptsetup-plugins') if libcryptsetup_plugins.enabled() if libcryptsetup.disabled() - error('libcryptsetup-plugins can not be requested without libcryptsetup') + error('libcryptsetup-plugins cannot be requested without libcryptsetup') endif libcryptsetup = libcryptsetup_plugins endif diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c index 3027804065..fdb3b17d2d 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c @@ -45,7 +45,7 @@ _public_ int cryptsetup_token_open_pin( r = crypt_normalize_pin(pin, pin_size, &pin_string); if (r < 0) - return crypt_log_debug_errno(cd, r, "Can not normalize PIN: %m"); + return crypt_log_debug_errno(cd, r, "Cannot normalize PIN: %m"); return acquire_luks2_key(cd, json, (const char *)usrptr, pin_string, password, password_len); } @@ -104,11 +104,11 @@ _public_ void cryptsetup_token_dump( r = crypt_dump_buffer_to_hex_string(cid, cid_size, &cid_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); r = crypt_dump_buffer_to_hex_string(salt, salt_size, &salt_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); if (required & FIDO2ENROLL_PIN) client_pin_req_str = "true"; diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c index c3e7fbd061..2ac8a270c5 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c @@ -95,7 +95,7 @@ _public_ void cryptsetup_token_dump( r = crypt_dump_buffer_to_hex_string(pkcs11_key, pkcs11_key_size, &key_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); crypt_log(cd, "\tpkcs11-uri: %s\n", pkcs11_uri); crypt_log(cd, "\tpkcs11-key: %s\n", key_str); diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c index 6da80896cd..6fee8319a7 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c @@ -68,7 +68,7 @@ _public_ int cryptsetup_token_open_pin( r = crypt_normalize_pin(pin, pin_size, &pin_string); if (r < 0) - return crypt_log_debug_errno(cd, r, "Can not normalize PIN: %m"); + return crypt_log_debug_errno(cd, r, "Cannot normalize PIN: %m"); if (usrptr) params = *(systemd_tpm2_plugin_params *)usrptr; @@ -222,15 +222,15 @@ _public_ void cryptsetup_token_dump( r = crypt_dump_buffer_to_hex_string(blob, blob_size, &blob_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); r = crypt_dump_buffer_to_hex_string(pubkey, pubkey_size, &pubkey_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); r = crypt_dump_buffer_to_hex_string(policy_hash, policy_hash_size, &policy_hash_str); if (r < 0) - return (void) crypt_log_debug_errno(cd, r, "Can not dump " TOKEN_NAME " content: %m"); + return (void) crypt_log_debug_errno(cd, r, "Cannot dump " TOKEN_NAME " content: %m"); crypt_log(cd, "\ttpm2-hash-pcrs: %s\n", strna(hash_pcrs_str)); crypt_log(cd, "\ttpm2-pcr-bank: %s\n", strna(tpm2_hash_alg_to_string(pcr_bank))); diff --git a/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c b/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c index 8cbb1f7d88..178fc7a87b 100644 --- a/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c +++ b/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c @@ -217,7 +217,7 @@ int acquire_luks2_key( base64_encoded_size = base64mem(decrypted_key, decrypted_key_size, &base64_encoded); if (base64_encoded_size < 0) - return crypt_log_error_errno(cd, (int) base64_encoded_size, "Can not base64 encode key: %m"); + return crypt_log_error_errno(cd, (int) base64_encoded_size, "Cannot base64 encode key: %m"); *ret_password = TAKE_PTR(base64_encoded); *ret_password_size = base64_encoded_size; diff --git a/src/locale/localed.c b/src/locale/localed.c index f544a73580..5d96237fae 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -192,7 +192,7 @@ static int locale_gen_process_locale(char *new_locale[static _VARIABLE_LC_MAX], log_error_errno(r, "Failed to enable invalid locale %s for generation.", new_locale[p]); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, - "Can not enable locale generation for invalid locale: %s", + "Cannot enable locale generation for invalid locale: %s", new_locale[p]); } if (r < 0) { diff --git a/src/resolve/resolved-dnstls-openssl.c b/src/resolve/resolved-dnstls-openssl.c index b217417a1a..fbcee7fc63 100644 --- a/src/resolve/resolved-dnstls-openssl.c +++ b/src/resolve/resolved-dnstls-openssl.c @@ -327,7 +327,7 @@ ssize_t dnstls_stream_writev(DnsStream *stream, const struct iovec *iov, size_t if (iovcnt == 1) return dnstls_stream_write(stream, iov[0].iov_base, iov[0].iov_len); - /* As of now, OpenSSL can not accumulate multiple writes, so join into a + /* As of now, OpenSSL cannot accumulate multiple writes, so join into a single buffer. Suboptimal, but better than multiple SSL_write calls. */ count = iovec_total_size(iov, iovcnt); buf = new(char, count);