diff options
-rw-r--r-- | src/core/cgroup.c | 2 | ||||
-rw-r--r-- | src/core/cgroup.h | 2 | ||||
-rw-r--r-- | src/core/unit-printf.c | 46 | ||||
-rw-r--r-- | src/core/unit.c | 2 | ||||
-rw-r--r-- | src/core/unit.h | 2 | ||||
-rw-r--r-- | src/resolve/resolved-dnssd.c | 2 | ||||
-rw-r--r-- | src/shared/install-printf.c | 13 | ||||
-rw-r--r-- | src/shared/install-printf.h | 2 | ||||
-rw-r--r-- | src/shared/specifier.c | 28 | ||||
-rw-r--r-- | src/shared/specifier.h | 32 | ||||
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 8 |
11 files changed, 69 insertions, 70 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 5590047976..ae7fc295a0 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -1491,7 +1491,7 @@ static const char *migrate_callback(CGroupMask mask, void *userdata) { return unit_get_realized_cgroup_path(userdata, mask); } -char *unit_default_cgroup_path(Unit *u) { +char *unit_default_cgroup_path(const Unit *u) { _cleanup_free_ char *escaped = NULL, *slice = NULL; int r; diff --git a/src/core/cgroup.h b/src/core/cgroup.h index 6d094e9ecd..266daa20a5 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -164,7 +164,7 @@ void unit_invalidate_cgroup_members_masks(Unit *u); void unit_add_to_cgroup_realize_queue(Unit *u); const char *unit_get_realized_cgroup_path(Unit *u, CGroupMask mask); -char *unit_default_cgroup_path(Unit *u); +char *unit_default_cgroup_path(const Unit *u); int unit_set_cgroup_path(Unit *u, const char *path); int unit_pick_cgroup_path(Unit *u); diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c index f57c099c39..a8e84ebe80 100644 --- a/src/core/unit-printf.c +++ b/src/core/unit-printf.c @@ -12,25 +12,25 @@ #include "unit.h" #include "user-util.h" -static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_prefix_and_instance(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; assert(u); return unit_name_to_prefix_and_instance(u->id, ret); } -static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_prefix(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; assert(u); return unit_name_to_prefix(u->id, ret); } -static int specifier_prefix_unescaped(char specifier, void *data, void *userdata, char **ret) { +static int specifier_prefix_unescaped(char specifier, const void *data, const void *userdata, char **ret) { _cleanup_free_ char *p = NULL; - Unit *u = userdata; + const Unit *u = userdata; int r; assert(u); @@ -42,16 +42,16 @@ static int specifier_prefix_unescaped(char specifier, void *data, void *userdata return unit_name_unescape(p, ret); } -static int specifier_instance_unescaped(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_instance_unescaped(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; assert(u); return unit_name_unescape(strempty(u->instance), ret); } -static int specifier_last_component(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_last_component(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; _cleanup_free_ char *prefix = NULL; char *dash; int r; @@ -70,7 +70,7 @@ static int specifier_last_component(char specifier, void *data, void *userdata, return 0; } -static int specifier_last_component_unescaped(char specifier, void *data, void *userdata, char **ret) { +static int specifier_last_component_unescaped(char specifier, const void *data, const void *userdata, char **ret) { _cleanup_free_ char *p = NULL; int r; @@ -81,8 +81,8 @@ static int specifier_last_component_unescaped(char specifier, void *data, void * return unit_name_unescape(p, ret); } -static int specifier_filename(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_filename(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; assert(u); @@ -92,12 +92,12 @@ static int specifier_filename(char specifier, void *data, void *userdata, char * return unit_name_to_path(u->id, ret); } -static void bad_specifier(Unit *u, char specifier) { +static void bad_specifier(const Unit *u, char specifier) { log_unit_warning(u, "Specifier '%%%c' used in unit configuration, which is deprecated. Please update your unit file, as it does not work as intended.", specifier); } -static int specifier_cgroup(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_cgroup(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; char *n; assert(u); @@ -115,8 +115,8 @@ static int specifier_cgroup(char specifier, void *data, void *userdata, char **r return 0; } -static int specifier_cgroup_root(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_cgroup_root(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; char *n; assert(u); @@ -131,8 +131,8 @@ static int specifier_cgroup_root(char specifier, void *data, void *userdata, cha return 0; } -static int specifier_cgroup_slice(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_cgroup_slice(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; char *n; assert(u); @@ -140,7 +140,7 @@ static int specifier_cgroup_slice(char specifier, void *data, void *userdata, ch bad_specifier(u, specifier); if (UNIT_ISSET(u->slice)) { - Unit *slice; + const Unit *slice; slice = UNIT_DEREF(u->slice); @@ -157,8 +157,8 @@ static int specifier_cgroup_slice(char specifier, void *data, void *userdata, ch return 0; } -static int specifier_special_directory(char specifier, void *data, void *userdata, char **ret) { - Unit *u = userdata; +static int specifier_special_directory(char specifier, const void *data, const void *userdata, char **ret) { + const Unit *u = userdata; char *n = NULL; assert(u); diff --git a/src/core/unit.c b/src/core/unit.c index 171567022f..bc72b5d673 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -132,7 +132,7 @@ int unit_new_for_name(Manager *m, size_t size, const char *name, Unit **ret) { return r; } -bool unit_has_name(Unit *u, const char *name) { +bool unit_has_name(const Unit *u, const char *name) { assert(u); assert(name); diff --git a/src/core/unit.h b/src/core/unit.h index 312742f11b..6fd39eaca3 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -648,7 +648,7 @@ int unit_set_default_slice(Unit *u); const char *unit_description(Unit *u) _pure_; -bool unit_has_name(Unit *u, const char *name); +bool unit_has_name(const Unit *u, const char *name); UnitActiveState unit_active_state(Unit *u); diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c index 2c28ec227a..b8e6a7abe1 100644 --- a/src/resolve/resolved-dnssd.c +++ b/src/resolve/resolved-dnssd.c @@ -141,7 +141,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) { return 0; } -static int specifier_dnssd_host_name(char specifier, void *data, void *userdata, char **ret) { +static int specifier_dnssd_host_name(char specifier, const void *data, const void *userdata, char **ret) { DnssdService *s = (DnssdService *) userdata; char *n; diff --git a/src/shared/install-printf.c b/src/shared/install-printf.c index b87d6b9d55..d2143beda3 100644 --- a/src/shared/install-printf.c +++ b/src/shared/install-printf.c @@ -14,7 +14,7 @@ #include "unit-name.h" #include "user-util.h" -static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) { +static int specifier_prefix_and_instance(char specifier, const void *data, const void *userdata, char **ret) { const UnitFileInstallInfo *i = userdata; _cleanup_free_ char *prefix = NULL; int r; @@ -38,7 +38,7 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd return 0; } -static int specifier_name(char specifier, void *data, void *userdata, char **ret) { +static int specifier_name(char specifier, const void *data, const void *userdata, char **ret) { const UnitFileInstallInfo *i = userdata; char *ans; @@ -54,7 +54,7 @@ static int specifier_name(char specifier, void *data, void *userdata, char **ret return 0; } -static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) { +static int specifier_prefix(char specifier, const void *data, const void *userdata, char **ret) { const UnitFileInstallInfo *i = userdata; assert(i); @@ -62,7 +62,7 @@ static int specifier_prefix(char specifier, void *data, void *userdata, char **r return unit_name_to_prefix(i->name, ret); } -static int specifier_instance(char specifier, void *data, void *userdata, char **ret) { +static int specifier_instance(char specifier, const void *data, const void *userdata, char **ret) { const UnitFileInstallInfo *i = userdata; char *instance; int r; @@ -83,7 +83,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char * return 0; } -static int specifier_last_component(char specifier, void *data, void *userdata, char **ret) { +static int specifier_last_component(char specifier, const void *data, const void *userdata, char **ret) { _cleanup_free_ char *prefix = NULL; char *dash; int r; @@ -104,8 +104,7 @@ static int specifier_last_component(char specifier, void *data, void *userdata, return 0; } -int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) { - +int install_full_printf(const UnitFileInstallInfo *i, const char *format, char **ret) { /* This is similar to unit_full_printf() but does not support * anything path-related. * diff --git a/src/shared/install-printf.h b/src/shared/install-printf.h index 378b3bfd92..fa8ea7ef81 100644 --- a/src/shared/install-printf.h +++ b/src/shared/install-printf.h @@ -3,4 +3,4 @@ #include "install.h" -int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret); +int install_full_printf(const UnitFileInstallInfo *i, const char *format, char **ret); diff --git a/src/shared/specifier.c b/src/shared/specifier.c index 78dda05b48..b8f7537f7a 100644 --- a/src/shared/specifier.c +++ b/src/shared/specifier.c @@ -27,7 +27,7 @@ * and "%" used for escaping. */ #define POSSIBLE_SPECIFIERS ALPHANUMERICAL "%" -int specifier_printf(const char *text, const Specifier table[], void *userdata, char **_ret) { +int specifier_printf(const char *text, const Specifier table[], const void *userdata, char **_ret) { size_t l, allocated = 0; _cleanup_free_ char *ret = NULL; char *t; @@ -102,7 +102,7 @@ int specifier_printf(const char *text, const Specifier table[], void *userdata, /* Generic handler for simple string replacements */ -int specifier_string(char specifier, void *data, void *userdata, char **ret) { +int specifier_string(char specifier, const void *data, const void *userdata, char **ret) { char *n; n = strdup(strempty(data)); @@ -113,7 +113,7 @@ int specifier_string(char specifier, void *data, void *userdata, char **ret) { return 0; } -int specifier_machine_id(char specifier, void *data, void *userdata, char **ret) { +int specifier_machine_id(char specifier, const void *data, const void *userdata, char **ret) { sd_id128_t id; char *n; int r; @@ -130,7 +130,7 @@ int specifier_machine_id(char specifier, void *data, void *userdata, char **ret) return 0; } -int specifier_boot_id(char specifier, void *data, void *userdata, char **ret) { +int specifier_boot_id(char specifier, const void *data, const void *userdata, char **ret) { sd_id128_t id; char *n; int r; @@ -147,7 +147,7 @@ int specifier_boot_id(char specifier, void *data, void *userdata, char **ret) { return 0; } -int specifier_host_name(char specifier, void *data, void *userdata, char **ret) { +int specifier_host_name(char specifier, const void *data, const void *userdata, char **ret) { char *n; n = gethostname_malloc(); @@ -158,7 +158,7 @@ int specifier_host_name(char specifier, void *data, void *userdata, char **ret) return 0; } -int specifier_kernel_release(char specifier, void *data, void *userdata, char **ret) { +int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret) { struct utsname uts; char *n; int r; @@ -175,7 +175,7 @@ int specifier_kernel_release(char specifier, void *data, void *userdata, char ** return 0; } -int specifier_group_name(char specifier, void *data, void *userdata, char **ret) { +int specifier_group_name(char specifier, const void *data, const void *userdata, char **ret) { char *t; t = gid_to_name(getgid()); @@ -186,14 +186,14 @@ int specifier_group_name(char specifier, void *data, void *userdata, char **ret) return 0; } -int specifier_group_id(char specifier, void *data, void *userdata, char **ret) { +int specifier_group_id(char specifier, const void *data, const void *userdata, char **ret) { if (asprintf(ret, UID_FMT, getgid()) < 0) return -ENOMEM; return 0; } -int specifier_user_name(char specifier, void *data, void *userdata, char **ret) { +int specifier_user_name(char specifier, const void *data, const void *userdata, char **ret) { char *t; /* If we are UID 0 (root), this will not result in NSS, otherwise it might. This is good, as we want to be able @@ -211,7 +211,7 @@ int specifier_user_name(char specifier, void *data, void *userdata, char **ret) return 0; } -int specifier_user_id(char specifier, void *data, void *userdata, char **ret) { +int specifier_user_id(char specifier, const void *data, const void *userdata, char **ret) { if (asprintf(ret, UID_FMT, getuid()) < 0) return -ENOMEM; @@ -219,7 +219,7 @@ int specifier_user_id(char specifier, void *data, void *userdata, char **ret) { return 0; } -int specifier_user_home(char specifier, void *data, void *userdata, char **ret) { +int specifier_user_home(char specifier, const void *data, const void *userdata, char **ret) { /* On PID 1 (which runs as root) this will not result in NSS, * which is good. See above */ @@ -227,7 +227,7 @@ int specifier_user_home(char specifier, void *data, void *userdata, char **ret) return get_home_dir(ret); } -int specifier_user_shell(char specifier, void *data, void *userdata, char **ret) { +int specifier_user_shell(char specifier, const void *data, const void *userdata, char **ret) { /* On PID 1 (which runs as root) this will not result in NSS, * which is good. See above */ @@ -235,7 +235,7 @@ int specifier_user_shell(char specifier, void *data, void *userdata, char **ret) return get_shell(ret); } -int specifier_tmp_dir(char specifier, void *data, void *userdata, char **ret) { +int specifier_tmp_dir(char specifier, const void *data, const void *userdata, char **ret) { const char *p; char *copy; int r; @@ -252,7 +252,7 @@ int specifier_tmp_dir(char specifier, void *data, void *userdata, char **ret) { return 0; } -int specifier_var_tmp_dir(char specifier, void *data, void *userdata, char **ret) { +int specifier_var_tmp_dir(char specifier, const void *data, const void *userdata, char **ret) { const char *p; char *copy; int r; diff --git a/src/shared/specifier.h b/src/shared/specifier.h index 722200b998..d0221ef714 100644 --- a/src/shared/specifier.h +++ b/src/shared/specifier.h @@ -3,32 +3,32 @@ #include "string-util.h" -typedef int (*SpecifierCallback)(char specifier, void *data, void *userdata, char **ret); +typedef int (*SpecifierCallback)(char specifier, const void *data, const void *userdata, char **ret); typedef struct Specifier { const char specifier; const SpecifierCallback lookup; - void *data; + const void *data; } Specifier; -int specifier_printf(const char *text, const Specifier table[], void *userdata, char **ret); +int specifier_printf(const char *text, const Specifier table[], const void *userdata, char **ret); -int specifier_string(char specifier, void *data, void *userdata, char **ret); +int specifier_string(char specifier, const void *data, const void *userdata, char **ret); -int specifier_machine_id(char specifier, void *data, void *userdata, char **ret); -int specifier_boot_id(char specifier, void *data, void *userdata, char **ret); -int specifier_host_name(char specifier, void *data, void *userdata, char **ret); -int specifier_kernel_release(char specifier, void *data, void *userdata, char **ret); +int specifier_machine_id(char specifier, const void *data, const void *userdata, char **ret); +int specifier_boot_id(char specifier, const void *data, const void *userdata, char **ret); +int specifier_host_name(char specifier, const void *data, const void *userdata, char **ret); +int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret); -int specifier_group_name(char specifier, void *data, void *userdata, char **ret); -int specifier_group_id(char specifier, void *data, void *userdata, char **ret); -int specifier_user_name(char specifier, void *data, void *userdata, char **ret); -int specifier_user_id(char specifier, void *data, void *userdata, char **ret); -int specifier_user_home(char specifier, void *data, void *userdata, char **ret); -int specifier_user_shell(char specifier, void *data, void *userdata, char **ret); +int specifier_group_name(char specifier, const void *data, const void *userdata, char **ret); +int specifier_group_id(char specifier, const void *data, const void *userdata, char **ret); +int specifier_user_name(char specifier, const void *data, const void *userdata, char **ret); +int specifier_user_id(char specifier, const void *data, const void *userdata, char **ret); +int specifier_user_home(char specifier, const void *data, const void *userdata, char **ret); +int specifier_user_shell(char specifier, const void *data, const void *userdata, char **ret); -int specifier_tmp_dir(char specifier, void *data, void *userdata, char **ret); -int specifier_var_tmp_dir(char specifier, void *data, void *userdata, char **ret); +int specifier_tmp_dir(char specifier, const void *data, const void *userdata, char **ret); +int specifier_var_tmp_dir(char specifier, const void *data, const void *userdata, char **ret); static inline char* specifier_escape(const char *string) { return strreplace(string, "%", "%%"); diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 08c57a3fb1..19225f8cfd 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -180,8 +180,8 @@ STATIC_DESTRUCTOR_REGISTER(arg_include_prefixes, freep); STATIC_DESTRUCTOR_REGISTER(arg_exclude_prefixes, freep); STATIC_DESTRUCTOR_REGISTER(arg_root, freep); -static int specifier_machine_id_safe(char specifier, void *data, void *userdata, char **ret); -static int specifier_directory(char specifier, void *data, void *userdata, char **ret); +static int specifier_machine_id_safe(char specifier, const void *data, const void *userdata, char **ret); +static int specifier_directory(char specifier, const void *data, const void *userdata, char **ret); static const Specifier specifier_table[] = { { 'm', specifier_machine_id_safe, NULL }, @@ -204,7 +204,7 @@ static const Specifier specifier_table[] = { {} }; -static int specifier_machine_id_safe(char specifier, void *data, void *userdata, char **ret) { +static int specifier_machine_id_safe(char specifier, const void *data, const void *userdata, char **ret) { int r; /* If /etc/machine_id is missing or empty (e.g. in a chroot environment) @@ -218,7 +218,7 @@ static int specifier_machine_id_safe(char specifier, void *data, void *userdata, return r; } -static int specifier_directory(char specifier, void *data, void *userdata, char **ret) { +static int specifier_directory(char specifier, const void *data, const void *userdata, char **ret) { struct table_entry { uint64_t type; const char *suffix; |