From: Lennart Poettering Date: Wed, 9 Aug 2023 08:48:47 +0000 (+0200) Subject: tree-wide: drop _pure_ + _const_ from local, static functions X-Git-Tag: v255-rc1~779 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d1e8e8b5ae3533a0a24006029872a98f2b9283fa;p=thirdparty%2Fsystemd.git tree-wide: drop _pure_ + _const_ from local, static functions This is supposed to be a help for compilers to apply optimizations on functions where they can't determine whether they are const/pure on their own. For static, local functions the compiler can do this on its own easily however, hence the decoration with pure/const is just noise. Let's drop it, and let the compiler to its thing better. (Use it for exported functions, since compilers can't 'reach-over' into other modules to determine if they are pure, except if LTO is used) --- diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 1730c9ab2d2..8640149af8c 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -191,7 +191,7 @@ int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec) { return ret; } -_pure_ static bool fd_in_set(int fd, const int fdset[], size_t n_fdset) { +static bool fd_in_set(int fd, const int fdset[], size_t n_fdset) { assert(n_fdset == 0 || fdset); for (size_t i = 0; i < n_fdset; i++) { diff --git a/src/basic/prioq.c b/src/basic/prioq.c index 7e335616888..5fbb9998b68 100644 --- a/src/basic/prioq.c +++ b/src/basic/prioq.c @@ -213,7 +213,7 @@ static void remove_item(Prioq *q, struct prioq_item *i) { } } -_pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) { +static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) { struct prioq_item *i; assert(q); diff --git a/src/core/device.c b/src/core/device.c index fd87b40306e..b3429f4b3d3 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -494,13 +494,13 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) { prefix, *i); } -_pure_ static UnitActiveState device_active_state(Unit *u) { +static UnitActiveState device_active_state(Unit *u) { assert(u); return state_translation_table[DEVICE(u)->state]; } -_pure_ static const char *device_sub_state_to_string(Unit *u) { +static const char *device_sub_state_to_string(Unit *u) { assert(u); return device_state_to_string(DEVICE(u)->state); diff --git a/src/core/mount.c b/src/core/mount.c index 70c8f088a09..5bd72a0b656 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1448,19 +1448,19 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F return 0; } -_pure_ static UnitActiveState mount_active_state(Unit *u) { +static UnitActiveState mount_active_state(Unit *u) { assert(u); return state_translation_table[MOUNT(u)->state]; } -_pure_ static const char *mount_sub_state_to_string(Unit *u) { +static const char *mount_sub_state_to_string(Unit *u) { assert(u); return mount_state_to_string(MOUNT(u)->state); } -_pure_ static bool mount_may_gc(Unit *u) { +static bool mount_may_gc(Unit *u) { Mount *m = MOUNT(u); assert(m); diff --git a/src/core/path.c b/src/core/path.c index 5fb14d9a10b..b06b97d7124 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -751,13 +751,13 @@ static int path_deserialize_item(Unit *u, const char *key, const char *value, FD return 0; } -_pure_ static UnitActiveState path_active_state(Unit *u) { +static UnitActiveState path_active_state(Unit *u) { assert(u); return state_translation_table[PATH(u)->state]; } -_pure_ static const char *path_sub_state_to_string(Unit *u) { +static const char *path_sub_state_to_string(Unit *u) { assert(u); return path_state_to_string(PATH(u)->state); diff --git a/src/core/scope.c b/src/core/scope.c index 72253421e23..4ab4c048b36 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -747,13 +747,13 @@ int scope_abandon(Scope *s) { return 0; } -_pure_ static UnitActiveState scope_active_state(Unit *u) { +static UnitActiveState scope_active_state(Unit *u) { assert(u); return state_translation_table[SCOPE(u)->state]; } -_pure_ static const char *scope_sub_state_to_string(Unit *u) { +static const char *scope_sub_state_to_string(Unit *u) { assert(u); return scope_state_to_string(SCOPE(u)->state); diff --git a/src/core/service.c b/src/core/service.c index 1b0af40b411..2a02279f565 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -2823,7 +2823,7 @@ static int service_reload(Unit *u) { return 1; } -_pure_ static bool service_can_reload(Unit *u) { +static bool service_can_reload(Unit *u) { Service *s = SERVICE(u); assert(s); @@ -3394,7 +3394,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, return 0; } -_pure_ static UnitActiveState service_active_state(Unit *u) { +static UnitActiveState service_active_state(Unit *u) { const UnitActiveState *table; assert(u); diff --git a/src/core/slice.c b/src/core/slice.c index 490aabfd35e..c6d142cebba 100644 --- a/src/core/slice.c +++ b/src/core/slice.c @@ -286,13 +286,13 @@ static int slice_deserialize_item(Unit *u, const char *key, const char *value, F return 0; } -_pure_ static UnitActiveState slice_active_state(Unit *u) { +static UnitActiveState slice_active_state(Unit *u) { assert(u); return state_translation_table[SLICE(u)->state]; } -_pure_ static const char *slice_sub_state_to_string(Unit *u) { +static const char *slice_sub_state_to_string(Unit *u) { assert(u); return slice_state_to_string(SLICE(u)->state); diff --git a/src/core/socket.c b/src/core/socket.c index aaa443432b0..023c0ba3882 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -286,7 +286,7 @@ static int socket_add_default_dependencies(Socket *s) { return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT); } -_pure_ static bool socket_has_exec(Socket *s) { +static bool socket_has_exec(Socket *s) { unsigned i; assert(s); @@ -548,7 +548,7 @@ int socket_acquire_peer(Socket *s, int fd, SocketPeer **p) { return 1; } -_const_ static const char* listen_lookup(int family, int type) { +static const char* listen_lookup(int family, int type) { if (family == AF_NETLINK) return "ListenNetlink"; @@ -2871,13 +2871,13 @@ static void socket_distribute_fds(Unit *u, FDSet *fds) { } } -_pure_ static UnitActiveState socket_active_state(Unit *u) { +static UnitActiveState socket_active_state(Unit *u) { assert(u); return state_translation_table[SOCKET(u)->state]; } -_pure_ static const char *socket_sub_state_to_string(Unit *u) { +static const char *socket_sub_state_to_string(Unit *u) { assert(u); return socket_state_to_string(SOCKET(u)->state); @@ -2945,7 +2945,7 @@ SocketType socket_port_type_from_string(const char *s) { return _SOCKET_TYPE_INVALID; } -_pure_ static bool socket_may_gc(Unit *u) { +static bool socket_may_gc(Unit *u) { Socket *s = SOCKET(u); assert(u); diff --git a/src/core/swap.c b/src/core/swap.c index 37642a64a61..c35545e031d 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -55,19 +55,19 @@ static bool SWAP_STATE_WITH_PROCESS(SwapState state) { SWAP_CLEANING); } -_pure_ static UnitActiveState swap_active_state(Unit *u) { +static UnitActiveState swap_active_state(Unit *u) { assert(u); return state_translation_table[SWAP(u)->state]; } -_pure_ static const char *swap_sub_state_to_string(Unit *u) { +static const char *swap_sub_state_to_string(Unit *u) { assert(u); return swap_state_to_string(SWAP(u)->state); } -_pure_ static bool swap_may_gc(Unit *u) { +static bool swap_may_gc(Unit *u) { Swap *s = SWAP(u); assert(s); @@ -78,7 +78,7 @@ _pure_ static bool swap_may_gc(Unit *u) { return true; } -_pure_ static bool swap_is_extrinsic(Unit *u) { +static bool swap_is_extrinsic(Unit *u) { assert(SWAP(u)); return MANAGER_IS_USER(u->manager); diff --git a/src/core/target.c b/src/core/target.c index 3519b4b653a..8f2a331f92b 100644 --- a/src/core/target.c +++ b/src/core/target.c @@ -169,13 +169,13 @@ static int target_deserialize_item(Unit *u, const char *key, const char *value, return 0; } -_pure_ static UnitActiveState target_active_state(Unit *u) { +static UnitActiveState target_active_state(Unit *u) { assert(u); return state_translation_table[TARGET(u)->state]; } -_pure_ static const char *target_sub_state_to_string(Unit *u) { +static const char *target_sub_state_to_string(Unit *u) { assert(u); return target_state_to_string(TARGET(u)->state); diff --git a/src/core/timer.c b/src/core/timer.c index f6e66055074..17faa5cbfbb 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -733,13 +733,13 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F return 0; } -_pure_ static UnitActiveState timer_active_state(Unit *u) { +static UnitActiveState timer_active_state(Unit *u) { assert(u); return state_translation_table[TIMER(u)->state]; } -_pure_ static const char *timer_sub_state_to_string(Unit *u) { +static const char *timer_sub_state_to_string(Unit *u) { assert(u); return timer_state_to_string(TIMER(u)->state); diff --git a/src/core/transaction.c b/src/core/transaction.c index ffc063a6842..85f673f447d 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -123,7 +123,7 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other transaction_delete_job(tr, other, true); } -_pure_ static bool job_is_conflicted_by(Job *j) { +static bool job_is_conflicted_by(Job *j) { assert(j); /* Returns true if this job is pulled in by a least one @@ -308,7 +308,7 @@ static void transaction_drop_redundant(Transaction *tr) { } while (again); } -_pure_ static bool job_matters_to_anchor(Job *job) { +static bool job_matters_to_anchor(Job *job) { assert(job); assert(!job->transaction_prev); diff --git a/src/libsystemd/sd-journal/fsprg.c b/src/libsystemd/sd-journal/fsprg.c index ab4cef9841c..e86be6af353 100644 --- a/src/libsystemd/sd-journal/fsprg.c +++ b/src/libsystemd/sd-journal/fsprg.c @@ -82,7 +82,7 @@ static void uint64_export(void *buf, size_t buflen, uint64_t x) { ((uint8_t*) buf)[7] = (x >> 0) & 0xff; } -_pure_ static uint64_t uint64_import(const void *buf, size_t buflen) { +static uint64_t uint64_import(const void *buf, size_t buflen) { assert(buflen == 8); return (uint64_t)(((uint8_t*) buf)[0]) << 56 | diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 3af463eb04e..81858f1aa18 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -3156,7 +3156,7 @@ found: return 1; } -_pure_ static int test_object_offset(JournalFile *f, uint64_t p, uint64_t needle) { +static int test_object_offset(JournalFile *f, uint64_t p, uint64_t needle) { assert(f); assert(p > 0); diff --git a/src/libsystemd/sd-journal/mmap-cache.c b/src/libsystemd/sd-journal/mmap-cache.c index 82407f9396e..b26183be769 100644 --- a/src/libsystemd/sd-journal/mmap-cache.c +++ b/src/libsystemd/sd-journal/mmap-cache.c @@ -132,7 +132,7 @@ static void window_free(Window *w) { free(w); } -_pure_ static bool window_matches(Window *w, uint64_t offset, size_t size) { +static bool window_matches(Window *w, uint64_t offset, size_t size) { assert(w); assert(size > 0); @@ -141,7 +141,7 @@ _pure_ static bool window_matches(Window *w, uint64_t offset, size_t size) { offset + size <= w->offset + w->size; } -_pure_ static bool window_matches_fd(Window *w, MMapFileDescriptor *f, uint64_t offset, size_t size) { +static bool window_matches_fd(Window *w, MMapFileDescriptor *f, uint64_t offset, size_t size) { assert(w); assert(f); diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index 3f1503ad484..4db127a4c52 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -20,7 +20,7 @@ #include "user-util.h" #include "utmp-wtmp.h" -_const_ static usec_t when_wall(usec_t n, usec_t elapse) { +static usec_t when_wall(usec_t n, usec_t elapse) { static const int wall_timers[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 40, 55, 70, 100, 130, 150, 180, diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c index b7f7c2b47aa..41a88b5c706 100644 --- a/src/shared/bus-polkit.c +++ b/src/shared/bus-polkit.c @@ -363,7 +363,7 @@ static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_e return r; } -_pure_ static int async_polkit_query_check_action( +static int async_polkit_query_check_action( AsyncPolkitQuery *q, const char *action, const char **details,