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)
This commit is contained in:
Lennart Poettering
2023-08-10 00:01:04 +08:00
committed by Mike Yuan
parent 07ba0bf7f5
commit d1e8e8b5ae
18 changed files with 36 additions and 36 deletions
+1 -1
View 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++) {
+1 -1
View 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);
+2 -2
View 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);
+3 -3
View 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);
+2 -2
View 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);
+2 -2
View 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);
+2 -2
View 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);
+2 -2
View 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);
+5 -5
View 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);
+4 -4
View 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);
+2 -2
View 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);
+2 -2
View 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);
+2 -2
View 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);
+1 -1
View 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 |
+1 -1
View 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);
+2 -2
View 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);
+1 -1
View 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,
+1 -1
View 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,