summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.h8
-rw-r--r--src/core/cgroup-attr.h4
-rw-r--r--src/core/cgroup.h2
-rw-r--r--src/core/condition.h4
-rw-r--r--src/core/device.c4
-rw-r--r--src/core/device.h4
-rw-r--r--src/core/execute.c4
-rw-r--r--src/core/execute.h8
-rw-r--r--src/core/job.c4
-rw-r--r--src/core/job.h26
-rw-r--r--src/core/kill.h10
-rw-r--r--src/core/manager.h2
-rw-r--r--src/core/mount.c10
-rw-r--r--src/core/mount.h12
-rw-r--r--src/core/path.c4
-rw-r--r--src/core/path.h12
-rw-r--r--src/core/selinux-access.c2
-rw-r--r--src/core/service.c8
-rw-r--r--src/core/service.h28
-rw-r--r--src/core/snapshot.c4
-rw-r--r--src/core/snapshot.h4
-rw-r--r--src/core/socket.c10
-rw-r--r--src/core/socket.h14
-rw-r--r--src/core/swap.c6
-rw-r--r--src/core/swap.h12
-rw-r--r--src/core/target.c4
-rw-r--r--src/core/target.h4
-rw-r--r--src/core/timer.c4
-rw-r--r--src/core/timer.h12
-rw-r--r--src/core/transaction.c4
-rw-r--r--src/core/unit.c4
-rw-r--r--src/core/unit.h26
32 files changed, 133 insertions, 131 deletions
diff --git a/src/core/automount.h b/src/core/automount.h
index 827605135..0c6b8a72e 100644
--- a/src/core/automount.h
+++ b/src/core/automount.h
@@ -64,8 +64,8 @@ int automount_send_ready(Automount *a, int status);
int automount_add_one_mount_link(Automount *a, Mount *m);
-const char* automount_state_to_string(AutomountState i);
-AutomountState automount_state_from_string(const char *s);
+const char* automount_state_to_string(AutomountState i) _const_;
+AutomountState automount_state_from_string(const char *s) _pure_;
-const char* automount_result_to_string(AutomountResult i);
-AutomountResult automount_result_from_string(const char *s);
+const char* automount_result_to_string(AutomountResult i) _const_;
+AutomountResult automount_result_from_string(const char *s) _pure_;
diff --git a/src/core/cgroup-attr.h b/src/core/cgroup-attr.h
index 0b542981e..3a13b7c92 100644
--- a/src/core/cgroup-attr.h
+++ b/src/core/cgroup-attr.h
@@ -42,8 +42,8 @@ struct CGroupAttribute {
int cgroup_attribute_apply(CGroupAttribute *a, CGroupBonding *b);
int cgroup_attribute_apply_list(CGroupAttribute *first, CGroupBonding *b);
-bool cgroup_attribute_matches(CGroupAttribute *a, const char *controller, const char *name);
-CGroupAttribute *cgroup_attribute_find_list(CGroupAttribute *first, const char *controller, const char *name);
+bool cgroup_attribute_matches(CGroupAttribute *a, const char *controller, const char *name) _pure_;
+CGroupAttribute *cgroup_attribute_find_list(CGroupAttribute *first, const char *controller, const char *name) _pure_;
void cgroup_attribute_free(CGroupAttribute *a);
void cgroup_attribute_free_list(CGroupAttribute *first);
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 2ff39e576..6555d89e3 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -76,7 +76,7 @@ void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root);
int cgroup_bonding_is_empty(CGroupBonding *b);
int cgroup_bonding_is_empty_list(CGroupBonding *first);
-CGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller);
+CGroupBonding *cgroup_bonding_find_list(CGroupBonding *first, const char *controller) _pure_;
char *cgroup_bonding_to_string(CGroupBonding *b);
diff --git a/src/core/condition.h b/src/core/condition.h
index 1797385d2..50ed955af 100644
--- a/src/core/condition.h
+++ b/src/core/condition.h
@@ -66,5 +66,5 @@ bool condition_test_list(Condition *c);
void condition_dump(Condition *c, FILE *f, const char *prefix);
void condition_dump_list(Condition *c, FILE *f, const char *prefix);
-const char* condition_type_to_string(ConditionType t);
-int condition_type_from_string(const char *s);
+const char* condition_type_to_string(ConditionType t) _const_;
+int condition_type_from_string(const char *s) _pure_;
diff --git a/src/core/device.c b/src/core/device.c
index 734d3f32e..e83e79778 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -124,13 +124,13 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) {
prefix, strna(d->sysfs));
}
-static UnitActiveState device_active_state(Unit *u) {
+_pure_ static UnitActiveState device_active_state(Unit *u) {
assert(u);
return state_translation_table[DEVICE(u)->state];
}
-static const char *device_sub_state_to_string(Unit *u) {
+_pure_ 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/device.h b/src/core/device.h
index 3c4604f60..41e8de970 100644
--- a/src/core/device.h
+++ b/src/core/device.h
@@ -52,5 +52,5 @@ extern const UnitVTable device_vtable;
void device_fd_event(Manager *m, int events);
-const char* device_state_to_string(DeviceState i);
-DeviceState device_state_from_string(const char *s);
+const char* device_state_to_string(DeviceState i) _const_;
+DeviceState device_state_from_string(const char *s) _pure_;
diff --git a/src/core/execute.c b/src/core/execute.c
index 5767037ac..3959ef962 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -144,7 +144,7 @@ static int flags_fds(const int fds[], unsigned n_fds, bool nonblock) {
return 0;
}
-static const char *tty_path(const ExecContext *context) {
+_pure_ static const char *tty_path(const ExecContext *context) {
assert(context);
if (context->tty_path)
@@ -509,7 +509,7 @@ fail:
return r;
}
-static int write_confirm_message(const char *format, ...) {
+_printf_attr_(1, 2) static int write_confirm_message(const char *format, ...) {
int fd;
va_list ap;
diff --git a/src/core/execute.h b/src/core/execute.h
index 3ce9221ab..15574dc97 100644
--- a/src/core/execute.h
+++ b/src/core/execute.h
@@ -210,8 +210,8 @@ void exec_status_start(ExecStatus *s, pid_t pid);
void exec_status_exit(ExecStatus *s, ExecContext *context, pid_t pid, int code, int status);
void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix);
-const char* exec_output_to_string(ExecOutput i);
-ExecOutput exec_output_from_string(const char *s);
+const char* exec_output_to_string(ExecOutput i) _const_;
+ExecOutput exec_output_from_string(const char *s) _pure_;
-const char* exec_input_to_string(ExecInput i);
-ExecInput exec_input_from_string(const char *s);
+const char* exec_input_to_string(ExecInput i) _const_;
+ExecInput exec_input_from_string(const char *s) _pure_;
diff --git a/src/core/job.c b/src/core/job.c
index 9a425a6da..d304a16d0 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -569,7 +569,7 @@ int job_run_and_invalidate(Job *j) {
return r;
}
-static const char *job_get_status_message_format(Unit *u, JobType t, JobResult result) {
+_pure_ static const char *job_get_status_message_format(Unit *u, JobType t, JobResult result) {
const UnitStatusMessageFormats *format_table;
assert(u);
@@ -588,7 +588,7 @@ static const char *job_get_status_message_format(Unit *u, JobType t, JobResult r
return NULL;
}
-static const char *job_get_status_message_format_try_harder(Unit *u, JobType t, JobResult result) {
+_pure_ static const char *job_get_status_message_format_try_harder(Unit *u, JobType t, JobResult result) {
const char *format;
assert(u);
diff --git a/src/core/job.h b/src/core/job.h
index 45d048745..d90bc96b7 100644
--- a/src/core/job.h
+++ b/src/core/job.h
@@ -183,22 +183,22 @@ void job_dependency_free(JobDependency *l);
int job_merge(Job *j, Job *other);
-JobType job_type_lookup_merge(JobType a, JobType b);
+JobType job_type_lookup_merge(JobType a, JobType b) _pure_;
-static inline bool job_type_is_mergeable(JobType a, JobType b) {
+_pure_ static inline bool job_type_is_mergeable(JobType a, JobType b) {
return job_type_lookup_merge(a, b) >= 0;
}
-static inline bool job_type_is_conflicting(JobType a, JobType b) {
+_pure_ static inline bool job_type_is_conflicting(JobType a, JobType b) {
return !job_type_is_mergeable(a, b);
}
-static inline bool job_type_is_superset(JobType a, JobType b) {
+_pure_ static inline bool job_type_is_superset(JobType a, JobType b) {
/* Checks whether operation a is a "superset" of b in its actions */
return a == job_type_lookup_merge(a, b);
}
-bool job_type_is_redundant(JobType a, UnitActiveState b);
+bool job_type_is_redundant(JobType a, UnitActiveState b) _pure_;
/* Collapses a state-dependent job type into a simpler type by observing
* the state of the unit which it is going to be applied to. */
@@ -221,14 +221,14 @@ char *job_dbus_path(Job *j);
void job_shutdown_magic(Job *j);
-const char* job_type_to_string(JobType t);
-JobType job_type_from_string(const char *s);
+const char* job_type_to_string(JobType t) _const_;
+JobType job_type_from_string(const char *s) _pure_;
-const char* job_state_to_string(JobState t);
-JobState job_state_from_string(const char *s);
+const char* job_state_to_string(JobState t) _const_;
+JobState job_state_from_string(const char *s) _pure_;
-const char* job_mode_to_string(JobMode t);
-JobMode job_mode_from_string(const char *s);
+const char* job_mode_to_string(JobMode t) _const_;
+JobMode job_mode_from_string(const char *s) _pure_;
-const char* job_result_to_string(JobResult t);
-JobResult job_result_from_string(const char *s);
+const char* job_result_to_string(JobResult t) _const_;
+JobResult job_result_from_string(const char *s) _pure_;
diff --git a/src/core/kill.h b/src/core/kill.h
index 3c9b0ab8d..71a0513e8 100644
--- a/src/core/kill.h
+++ b/src/core/kill.h
@@ -26,6 +26,8 @@ typedef struct KillContext KillContext;
#include <stdbool.h>
#include <stdio.h>
+#include "macro.h"
+
typedef enum KillMode {
/* The kill mode is a property of a unit. */
KILL_CONTROL_GROUP = 0,
@@ -53,8 +55,8 @@ typedef enum KillWho {
void kill_context_init(KillContext *c);
void kill_context_dump(KillContext *c, FILE *f, const char *prefix);
-const char *kill_mode_to_string(KillMode k);
-KillMode kill_mode_from_string(const char *s);
+const char *kill_mode_to_string(KillMode k) _const_;
+KillMode kill_mode_from_string(const char *s) _pure_;
-const char *kill_who_to_string(KillWho k);
-KillWho kill_who_from_string(const char *s);
+const char *kill_who_to_string(KillWho k) _const_;
+KillWho kill_who_from_string(const char *s) _pure_;
diff --git a/src/core/manager.h b/src/core/manager.h
index b9bd2099f..bf833540a 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -284,7 +284,7 @@ int manager_distribute_fds(Manager *m, FDSet *fds);
int manager_reload(Manager *m);
-bool manager_is_reloading_or_reexecuting(Manager *m);
+bool manager_is_reloading_or_reexecuting(Manager *m) _pure_;
void manager_reset_failed(Manager *m);
diff --git a/src/core/mount.c b/src/core/mount.c
index 4f245555f..10073b50b 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -136,7 +136,7 @@ static void mount_done(Unit *u) {
unit_unwatch_timer(u, &m->timer_watch);
}
-static MountParameters* get_mount_parameters_fragment(Mount *m) {
+_pure_ static MountParameters* get_mount_parameters_fragment(Mount *m) {
assert(m);
if (m->from_fragment)
@@ -145,7 +145,7 @@ static MountParameters* get_mount_parameters_fragment(Mount *m) {
return NULL;
}
-static MountParameters* get_mount_parameters(Mount *m) {
+_pure_ static MountParameters* get_mount_parameters(Mount *m) {
assert(m);
if (m->from_proc_self_mountinfo)
@@ -1260,19 +1260,19 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
return 0;
}
-static UnitActiveState mount_active_state(Unit *u) {
+_pure_ static UnitActiveState mount_active_state(Unit *u) {
assert(u);
return state_translation_table[MOUNT(u)->state];
}
-static const char *mount_sub_state_to_string(Unit *u) {
+_pure_ static const char *mount_sub_state_to_string(Unit *u) {
assert(u);
return mount_state_to_string(MOUNT(u)->state);
}
-static bool mount_check_gc(Unit *u) {
+_pure_ static bool mount_check_gc(Unit *u) {
Mount *m = MOUNT(u);
assert(m);
diff --git a/src/core/mount.h b/src/core/mount.h
index 30c6d9b24..bcc10ee0d 100644
--- a/src/core/mount.h
+++ b/src/core/mount.h
@@ -111,13 +111,13 @@ extern const UnitVTable mount_vtable;
void mount_fd_event(Manager *m, int events);
-const char* mount_state_to_string(MountState i);
-MountState mount_state_from_string(const char *s);
+const char* mount_state_to_string(MountState i) _const_;
+MountState mount_state_from_string(const char *s) _pure_;
-const char* mount_exec_command_to_string(MountExecCommand i);
-MountExecCommand mount_exec_command_from_string(const char *s);
+const char* mount_exec_command_to_string(MountExecCommand i) _const_;
+MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
-const char* mount_result_to_string(MountResult i);
-MountResult mount_result_from_string(const char *s);
+const char* mount_result_to_string(MountResult i) _const_;
+MountResult mount_result_from_string(const char *s) _pure_;
void warn_if_dir_nonempty(const char *unit, const char* where);
diff --git a/src/core/path.c b/src/core/path.c
index ab1fe2eb6..8a09deb4f 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -680,13 +680,13 @@ static int path_deserialize_item(Unit *u, const char *key, const char *value, FD
return 0;
}
-static UnitActiveState path_active_state(Unit *u) {
+_pure_ static UnitActiveState path_active_state(Unit *u) {
assert(u);
return state_translation_table[PATH(u)->state];
}
-static const char *path_sub_state_to_string(Unit *u) {
+_pure_ 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/path.h b/src/core/path.h
index 974041539..6adab5897 100644
--- a/src/core/path.h
+++ b/src/core/path.h
@@ -98,11 +98,11 @@ void path_free_specs(Path *p);
extern const UnitVTable path_vtable;
-const char* path_state_to_string(PathState i);
-PathState path_state_from_string(const char *s);
+const char* path_state_to_string(PathState i) _const_;
+PathState path_state_from_string(const char *s) _pure_;
-const char* path_type_to_string(PathType i);
-PathType path_type_from_string(const char *s);
+const char* path_type_to_string(PathType i) _const_;
+PathType path_type_from_string(const char *s) _pure_;
-const char* path_result_to_string(PathResult i);
-PathResult path_result_from_string(const char *s);
+const char* path_result_to_string(PathResult i) _const_;
+PathResult path_result_from_string(const char *s) _pure_;
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index bc195f3c5..426aed07d 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -174,7 +174,7 @@ static int audit_callback(
user_avc's into the /var/log/audit/audit.log, otherwise they will be
sent to syslog.
*/
-static int log_callback(int type, const char *fmt, ...) {
+_printf_attr_(2, 3) static int log_callback(int type, const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
diff --git a/src/core/service.c b/src/core/service.c
index 5803f798e..3617c2471 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1878,7 +1878,7 @@ static int main_pid_good(Service *s) {
return -EAGAIN;
}
-static int control_pid_good(Service *s) {
+_pure_ static int control_pid_good(Service *s) {
assert(s);
return s->control_pid > 0;
@@ -2570,7 +2570,7 @@ static int service_reload(Unit *u) {
return 0;
}
-static bool service_can_reload(Unit *u) {
+_pure_ static bool service_can_reload(Unit *u) {
Service *s = SERVICE(u);
assert(s);
@@ -2782,7 +2782,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
return 0;
}
-static UnitActiveState service_active_state(Unit *u) {
+_pure_ static UnitActiveState service_active_state(Unit *u) {
const UnitActiveState *table;
assert(u);
@@ -2818,7 +2818,7 @@ static bool service_check_gc(Unit *u) {
return false;
}
-static bool service_check_snapshot(Unit *u) {
+_pure_ static bool service_check_snapshot(Unit *u) {
Service *s = SERVICE(u);
assert(s);
diff --git a/src/core/service.h b/src/core/service.h
index d1e53bf72..703d3faa4 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -203,23 +203,23 @@ struct Socket;
int service_set_socket_fd(Service *s, int fd, struct Socket *socket);
-const char* service_state_to_string(ServiceState i);
-ServiceState service_state_from_string(const char *s);
+const char* service_state_to_string(ServiceState i) _const_;
+ServiceState service_state_from_string(const char *s) _pure_;
-const char* service_restart_to_string(ServiceRestart i);
-ServiceRestart service_restart_from_string(const char *s);
+const char* service_restart_to_string(ServiceRestart i) _const_;
+ServiceRestart service_restart_from_string(const char *s) _pure_;
-const char* service_type_to_string(ServiceType i);
-ServiceType service_type_from_string(const char *s);
+const char* service_type_to_string(ServiceType i) _const_;
+ServiceType service_type_from_string(const char *s) _pure_;
-const char* service_exec_command_to_string(ServiceExecCommand i);
-ServiceExecCommand service_exec_command_from_string(const char *s);
+const char* service_exec_command_to_string(ServiceExecCommand i) _const_;
+ServiceExecCommand service_exec_command_from_string(const char *s) _pure_;
-const char* notify_access_to_string(NotifyAccess i);
-NotifyAccess notify_access_from_string(const char *s);
+const char* notify_access_to_string(NotifyAccess i) _const_;
+NotifyAccess notify_access_from_string(const char *s) _pure_;
-const char* service_result_to_string(ServiceResult i);
-ServiceResult service_result_from_string(const char *s);
+const char* service_result_to_string(ServiceResult i) _const_;
+ServiceResult service_result_from_string(const char *s) _pure_;
-const char* start_limit_action_to_string(StartLimitAction i);
-StartLimitAction start_limit_action_from_string(const char *s);
+const char* start_limit_action_to_string(StartLimitAction i) _const_;
+StartLimitAction start_limit_action_from_string(const char *s) _pure_;
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index a3f5e908e..a63eccd8d 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -173,13 +173,13 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
return 0;
}
-static UnitActiveState snapshot_active_state(Unit *u) {
+_pure_ static UnitActiveState snapshot_active_state(Unit *u) {
assert(u);
return state_translation_table[SNAPSHOT(u)->state];
}
-static const char *snapshot_sub_state_to_string(Unit *u) {
+_pure_ static const char *snapshot_sub_state_to_string(Unit *u) {
assert(u);
return snapshot_state_to_string(SNAPSHOT(u)->state);
diff --git a/src/core/snapshot.h b/src/core/snapshot.h
index 9662d9316..56f87cff4 100644
--- a/src/core/snapshot.h
+++ b/src/core/snapshot.h
@@ -46,5 +46,5 @@ extern const UnitVTable snapshot_vtable;
int snapshot_create(Manager *m, const char *name, bool cleanup, DBusError *e, Snapshot **s);
void snapshot_remove(Snapshot *s);
-const char* snapshot_state_to_string(SnapshotState i);
-SnapshotState snapshot_state_from_string(const char *s);
+const char* snapshot_state_to_string(SnapshotState i) _const_;
+SnapshotState snapshot_state_from_string(const char *s) _pure_;
diff --git a/src/core/socket.c b/src/core/socket.c
index c276afe38..8c829d304 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -344,7 +344,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, NULL, true);
}
-static bool socket_has_exec(Socket *s) {
+_pure_ static bool socket_has_exec(Socket *s) {
unsigned i;
assert(s);
@@ -410,7 +410,7 @@ static int socket_load(Unit *u) {
return socket_verify(s);
}
-static const char* listen_lookup(int family, int type) {
+_const_ static const char* listen_lookup(int family, int type) {
if (family == AF_NETLINK)
return "ListenNetlink";
@@ -1957,13 +1957,13 @@ static int socket_distribute_fds(Unit *u, FDSet *fds) {
return 0;
}
-static UnitActiveState socket_active_state(Unit *u) {
+_pure_ static UnitActiveState socket_active_state(Unit *u) {
assert(u);
return state_translation_table[SOCKET(u)->state];
}
-static const char *socket_sub_state_to_string(Unit *u) {
+_pure_ static const char *socket_sub_state_to_string(Unit *u) {
assert(u);
return socket_state_to_string(SOCKET(u)->state);
@@ -1991,7 +1991,7 @@ const char* socket_port_type_to_string(SocketPort *p) {
}
}
-static bool socket_check_gc(Unit *u) {
+_pure_ static bool socket_check_gc(Unit *u) {
Socket *s = SOCKET(u);
assert(u);
diff --git a/src/core/socket.h b/src/core/socket.h
index dbc363217..4826bb331 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -167,13 +167,13 @@ void socket_free_ports(Socket *s);
extern const UnitVTable socket_vtable;
-const char* socket_state_to_string(SocketState i);
-SocketState socket_state_from_string(const char *s);
+const char* socket_state_to_string(SocketState i) _const_;
+SocketState socket_state_from_string(const char *s) _pure_;
-const char* socket_exec_command_to_string(SocketExecCommand i);
-SocketExecCommand socket_exec_command_from_string(const char *s);
+const char* socket_exec_command_to_string(SocketExecCommand i) _const_;
+SocketExecCommand socket_exec_command_from_string(const char *s) _pure_;
-const char* socket_result_to_string(SocketResult i);
-SocketResult socket_result_from_string(const char *s);
+const char* socket_result_to_string(SocketResult i) _const_;
+SocketResult socket_result_from_string(const char *s) _pure_;
-const char* socket_port_type_to_string(SocketPort *p);
+const char* socket_port_type_to_string(SocketPort *p) _pure_;
diff --git a/src/core/swap.c b/src/core/swap.c
index e7cc19596..d503fe20d 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -899,19 +899,19 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD
return 0;
}
-static UnitActiveState swap_active_state(Unit *u) {
+_pure_ static UnitActiveState swap_active_state(Unit *u) {
assert(u);
return state_translation_table[SWAP(u)->state];
}
-static const char *swap_sub_state_to_string(Unit *u) {
+_pure_ static const char *swap_sub_state_to_string(Unit *u) {
assert(u);
return swap_state_to_string(SWAP(u)->state);
}
-static bool swap_check_gc(Unit *u) {
+_pure_ static bool swap_check_gc(Unit *u) {
Swap *s = SWAP(u);
assert(s);
diff --git a/src/core/swap.h b/src/core/swap.h
index 35d47fd46..121889d1d 100644
--- a/src/core/swap.h
+++ b/src/core/swap.h
@@ -111,11 +111,11 @@ int swap_add_one_mount_link(Swap *s, Mount *m);
int swap_dispatch_reload(Manager *m);
int swap_fd_event(Manager *m, int events);
-const char* swap_state_to_string(SwapState i);
-SwapState swap_state_from_string(const char *s);
+const char* swap_state_to_string(SwapState i) _const_;
+SwapState swap_state_from_string(const char *s) _pure_;
-const char* swap_exec_command_to_string(SwapExecCommand i);
-SwapExecCommand swap_exec_command_from_string(const char *s);
+const char* swap_exec_command_to_string(SwapExecCommand i) _const_;
+SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
-const char* swap_result_to_string(SwapResult i);
-SwapResult swap_result_from_string(const char *s);
+const char* swap_result_to_string(SwapResult i) _const_;
+SwapResult swap_result_from_string(const char *s) _pure_;
diff --git a/src/core/target.c b/src/core/target.c
index 981424132..3fffa0d2f 100644
--- a/src/core/target.c
+++ b/src/core/target.c
@@ -184,13 +184,13 @@ static int target_deserialize_item(Unit *u, const char *key, const char *value,
return 0;
}
-static UnitActiveState target_active_state(Unit *u) {
+_pure_ static UnitActiveState target_active_state(Unit *u) {
assert(u);
return state_translation_table[TARGET(u)->state];
}
-static const char *target_sub_state_to_string(Unit *u) {
+_pure_ 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/target.h b/src/core/target.h
index 1676553ad..a5398d9e9 100644
--- a/src/core/target.h
+++ b/src/core/target.h
@@ -40,5 +40,5 @@ struct Target {
extern const UnitVTable target_vtable;
-const char* target_state_to_string(TargetState i);
-TargetState target_state_from_string(const char *s);
+const char* target_state_to_string(TargetState i) _const_;
+TargetState target_state_from_string(const char *s) _pure_;
diff --git a/src/core/timer.c b/src/core/timer.c
index ff8c30583..9166c1e2f 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -464,13 +464,13 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F
return 0;
}
-static UnitActiveState timer_active_state(Unit *u) {
+_pure_ static UnitActiveState timer_active_state(Unit *u) {
assert(u);
return state_translation_table[TIMER(u)->state];
}
-static const char *timer_sub_state_to_string(Unit *u) {
+_pure_ 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/timer.h b/src/core/timer.h
index fed15e916..4168553e9 100644
--- a/src/core/timer.h
+++ b/src/core/timer.h
@@ -87,11 +87,11 @@ void timer_free_values(Timer *t);
extern const UnitVTable timer_vtable;
-const char *timer_state_to_string(TimerState i);
-TimerState timer_state_from_string(const char *s);
+const char *timer_state_to_string(TimerState i) _const_;
+TimerState timer_state_from_string(const char *s) _pure_;
-const char *timer_base_to_string(TimerBase i);
-TimerBase timer_base_from_string(const char *s);
+const char *timer_base_to_string(TimerBase i) _const_;
+TimerBase timer_base_from_string(const char *s) _pure_;
-const char* timer_result_to_string(TimerResult i);
-TimerResult timer_result_from_string(const char *s);
+const char* timer_result_to_string(TimerResult i) _const_;
+TimerResult timer_result_from_string(const char *s) _pure_;
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 610344eff..fa97b6975 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -140,7 +140,7 @@ static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other
transaction_delete_job(tr, other, true);
}
-static bool job_is_conflicted_by(Job *j) {
+_pure_ static bool job_is_conflicted_by(Job *j) {
JobDependency *l;
assert(j);
@@ -320,7 +320,7 @@ rescan:
}
}
-static bool unit_matters_to_anchor(Unit *u, Job *j) {
+_pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) {
assert(u);
assert(!j->transaction_prev);
diff --git a/src/core/unit.c b/src/core/unit.c
index c0f156c92..dc8bf8338 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -949,7 +949,7 @@ bool unit_condition_test(Unit *u) {
return u->condition_result;
}
-static const char* unit_get_status_message_format(Unit *u, JobType t) {
+_pure_ static const char* unit_get_status_message_format(Unit *u, JobType t) {
const UnitStatusMessageFormats *format_table;
assert(u);
@@ -966,7 +966,7 @@ static const char* unit_get_status_message_format(Unit *u, JobType t) {
return format_table->starting_stopping[t == JOB_STOP];
}
-static const char *unit_get_status_message_format_try_harder(Unit *u, JobType t) {
+_pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, JobType t) {
const char *format;
assert(u);
diff --git a/src/core/unit.h b/src/core/unit.h
index 0f121e244..b04475e4f 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -468,13 +468,13 @@ void unit_add_to_gc_queue(Unit *u);
int unit_merge(Unit *u, Unit *other);
int unit_merge_by_name(Unit *u, const char *other);
-Unit *unit_follow_merge(Unit *u);
+Unit *unit_follow_merge(Unit *u) _pure_;
int unit_load_fragment_and_dropin(Unit *u);
int unit_load_fragment_and_dropin_optional(Unit *u);
int unit_load(Unit *unit);
-const char *unit_description(Unit *u);
+const char *unit_description(Unit *u) _pure_;
bool unit_has_name(Unit *u, const char *name);
@@ -484,9 +484,9 @@ const char* unit_sub_state_to_string(Unit *u);
void unit_dump(Unit *u, FILE *f, const char *prefix);
-bool unit_can_reload(Unit *u);
-bool unit_can_start(Unit *u);
-bool unit_can_isolate(Unit *u);
+bool unit_can_reload(Unit *u) _pure_;
+bool unit_can_start(Unit *u) _pure_;
+bool unit_can_isolate(Unit *u) _pure_;
int unit_start(Unit *u);
int unit_stop(Unit *u);
@@ -518,7 +518,7 @@ char *unit_dbus_path(Unit *u);
int unit_load_related_unit(Unit *u, const char *type, Unit **_found);
int unit_get_related_unit(Unit *u, const char *type, Unit **_found);
-bool unit_can_serialize(Unit *u);
+bool unit_can_serialize(Unit *u) _pure_;
int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs);
void unit_serialize_item_format(Unit *u, FILE *f, const char *key, const char *value, ...) _printf_attr_(4,5);
void unit_serialize_item(Unit *u, FILE *f, const char *key, const char *value);
@@ -536,8 +536,8 @@ void unit_reset_failed(Unit *u);
Unit *unit_following(Unit *u);
-bool unit_stop_pending(Unit *u);
-bool unit_inactive_or_pending(Unit *u);
+bool unit_stop_pending(Unit *u) _pure_;
+bool unit_inactive_or_pending(Unit *u) _pure_;
bool unit_active_or_pending(Unit *u);
int unit_add_default_target_dependency(Unit *u, Unit *target);
@@ -563,18 +563,18 @@ int unit_add_mount_links(Unit *u);
int unit_exec_context_defaults(Unit *u, ExecContext *c);
-ExecContext *unit_get_exec_context(Unit *u);
+ExecContext *unit_get_exec_context(Unit *u) _pure_;
int unit_write_drop_in(Unit *u, bool runtime, const char *name, const char *data);
int unit_remove_drop_in(Unit *u, bool runtime, const char *name);
int unit_kill_context(Unit *u, KillContext *c, bool sigkill, pid_t main_pid, pid_t control_pid, bool main_pid_alien);
-const char *unit_active_state_to_string(UnitActiveState i);
-UnitActiveState unit_active_state_from_string(const char *s);
+const char *unit_active_state_to_string(UnitActiveState i) _const_;
+UnitActiveState unit_active_state_from_string(const char *s) _pure_;
-const char *unit_dependency_to_string(UnitDependency i);
-UnitDependency unit_dependency_from_string(const char *s);
+const char *unit_dependency_to_string(UnitDependency i) _const_;
+UnitDependency unit_dependency_from_string(const char *s) _pure_;
/* Macros which append UNIT= or USER_UNIT= to the message */