summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2025-01-13 16:35:13 +0100
committerMike Yuan <me@yhndnzj.com>2025-01-13 16:56:08 +0100
commit3f03d39ca3b2f25f521342f2b0e49f60c51246e1 (patch)
tree9707b066ce76e1f7c5f35553554eda52ce3add3d /src/shared
parentshared/bus-util: move string set append/get funcs to bus-message-util and bus... (diff)
downloadsystemd-3f03d39ca3b2f25f521342f2b0e49f60c51246e1.tar.xz
systemd-3f03d39ca3b2f25f521342f2b0e49f60c51246e1.zip
shared/serialize: make input params const
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/serialize.c9
-rw-r--r--src/shared/serialize.h4
2 files changed, 8 insertions, 5 deletions
diff --git a/src/shared/serialize.c b/src/shared/serialize.c
index 4d9ee6cc32..67311e4fa5 100644
--- a/src/shared/serialize.c
+++ b/src/shared/serialize.c
@@ -164,11 +164,14 @@ int serialize_dual_timestamp(FILE *f, const char *name, const dual_timestamp *t)
return serialize_item_format(f, name, USEC_FMT " " USEC_FMT, t->realtime, t->monotonic);
}
-int serialize_strv(FILE *f, const char *key, char **l) {
+int serialize_strv(FILE *f, const char *key, char * const *l) {
int ret = 0, r;
/* Returns the first error, or positive if anything was serialized, 0 otherwise. */
+ assert(f);
+ assert(key);
+
STRV_FOREACH(i, l) {
r = serialize_item_escaped(f, key, *i);
if ((ret >= 0 && r < 0) ||
@@ -267,8 +270,7 @@ int serialize_item_base64mem(FILE *f, const char *key, const void *p, size_t l)
return 1;
}
-int serialize_string_set(FILE *f, const char *key, Set *s) {
- const char *e;
+int serialize_string_set(FILE *f, const char *key, const Set *s) {
int r;
assert(f);
@@ -279,6 +281,7 @@ int serialize_string_set(FILE *f, const char *key, Set *s) {
/* Serialize as individual items, as each element might contain separators and escapes */
+ const char *e;
SET_FOREACH(e, s) {
r = serialize_item(f, key, e);
if (r < 0)
diff --git a/src/shared/serialize.h b/src/shared/serialize.h
index dc753465c4..6f5fcf44fe 100644
--- a/src/shared/serialize.h
+++ b/src/shared/serialize.h
@@ -21,10 +21,10 @@ int serialize_fd(FILE *f, FDSet *fds, const char *key, int fd);
int serialize_fd_many(FILE *f, FDSet *fds, const char *key, const int fd_array[], size_t n_fd_array);
int serialize_usec(FILE *f, const char *key, usec_t usec);
int serialize_dual_timestamp(FILE *f, const char *key, const dual_timestamp *t);
-int serialize_strv(FILE *f, const char *key, char **l);
+int serialize_strv(FILE *f, const char *key, char * const *l);
int serialize_pidref(FILE *f, FDSet *fds, const char *key, PidRef *pidref);
int serialize_ratelimit(FILE *f, const char *key, const RateLimit *rl);
-int serialize_string_set(FILE *f, const char *key, Set *s);
+int serialize_string_set(FILE *f, const char *key, const Set *s);
int serialize_image_policy(FILE *f, const char *key, const ImagePolicy *p);
static inline int serialize_bool(FILE *f, const char *key, bool b) {