]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: drop _pure_ + _const_ from local, static functions
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Aug 2023 08:48:47 +0000 (10:48 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 9 Aug 2023 16:01:04 +0000 (00:01 +0800)
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)

18 files changed:
src/basic/fd-util.c
src/basic/prioq.c
src/core/device.c
src/core/mount.c
src/core/path.c
src/core/scope.c
src/core/service.c
src/core/slice.c
src/core/socket.c
src/core/swap.c
src/core/target.c
src/core/timer.c
src/core/transaction.c
src/libsystemd/sd-journal/fsprg.c
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/mmap-cache.c
src/login/logind-utmp.c
src/shared/bus-polkit.c

index 1730c9ab2d266f76eb9a1be728a4214413a108a0..8640149af8c03fb39b136ec63ac5d0476a52b6cc 100644 (file)
@@ -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++) {
index 7e3356168880876da9d5255e491bb107d49956ce..5fbb9998b68f8d4d791c55b90042e5269706157e 100644 (file)
@@ -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);
index fd87b40306e3c3a733d94f2362043d725ef3479d..b3429f4b3d33e826fa11a6a9bcb6712268c99abd 100644 (file)
@@ -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);
index 70c8f088a09208fc857a5be364c4d0fad0083ff9..5bd72a0b656ce7ef9c12ae43d65b3d585ce33e8a 100644 (file)
@@ -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);
index 5fb14d9a10b4521ec796cfe965e238f69fce0e77..b06b97d7124de7eb0a8af3b29c058b05a0cf783d 100644 (file)
@@ -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);
index 72253421e232b94bd24bbef6123700e064632e9e..4ab4c048b36b88f2bc98a57f7b02744f96a93baa 100644 (file)
@@ -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);
index 1b0af40b4113116dc8f86c14c025433c431d4071..2a02279f5653986bda758094d34d9e36da3676e6 100644 (file)
@@ -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);
index 490aabfd35ebe4ad3ede038030d1aafe53424256..c6d142cebbaba7626b13bf57ebf8ce06cec35a90 100644 (file)
@@ -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);
index aaa443432b0f830f087508a46d01903ef05d22d7..023c0ba3882a0e97fb5e918d5d735661a9a4109c 100644 (file)
@@ -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);
index 37642a64a61c97fc840f04dcbd1837b23a65ad39..c35545e031d2a8c4480f66198522dfb8bebf52fa 100644 (file)
@@ -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);
index 3519b4b653a05b1a4b6ca63bc42811e3c67ce083..8f2a331f92b9df10cfb1867bb4efb78315df91c3 100644 (file)
@@ -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);
index f6e660550749814df23e167771335d9cf6ce5461..17faa5cbfbb4bc0a03e0474d5e62c101db24505e 100644 (file)
@@ -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);
index ffc063a6842106cf7dcc58dd9379f546f228d71a..85f673f447ddc3c6c3cf7f5e2accf768ec2b9783 100644 (file)
@@ -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);
 
index ab4cef9841c50087147c611f463570c7fc1ff361..e86be6af3539f24c052750dfcd1b1c2251d23744 100644 (file)
@@ -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 |
index 3af463eb04e617947302820f4803e1f5f373cac7..81858f1aa18e225e351390971ce907786bb214cb 100644 (file)
@@ -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);
 
index 82407f9396ebb58d0eadda7511825ef8d74dd15d..b26183be7697b72eabfef6f5b2181358885417e4 100644 (file)
@@ -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);
 
index 3f1503ad4842fdf6db35fb98e982f96edd1128fc..4db127a4c5212d907d5f21f473014bb384eb108a 100644 (file)
@@ -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,
index b7f7c2b47aaa088a79b66f783368ed58a8ad238d..41a88b5c706a6329f9019725b6bf5da30a5d68c5 100644 (file)
@@ -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,