From 0a6b52352759efffddd7a5d7dd982f0025b3771a Mon Sep 17 00:00:00 2001 From: Simon Halvorsen Date: Thu, 18 Jun 2026 13:21:43 +0200 Subject: [PATCH] Fix: discarded-qualifiers compiler warnings (cherry picked from commit 6dd05a961ff212dab1f45e106c7b340911a08432) Signed-off-by: Lars Erik Wik --- cf-serverd/strlist.c | 4 ++-- cf-testd/cf-testd.c | 2 +- libenv/sysinfo.c | 2 +- libpromises/class.c | 2 +- libpromises/eval_context.c | 2 +- libpromises/generic_agent.c | 2 +- libpromises/keyring.c | 2 +- libpromises/policy.c | 4 ++-- libpromises/promises.c | 2 +- libpromises/verify_vars.c | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cf-serverd/strlist.c b/cf-serverd/strlist.c index 72f72b86b50..a35d950a00d 100644 --- a/cf-serverd/strlist.c +++ b/cf-serverd/strlist.c @@ -401,7 +401,7 @@ size_t StrList_bsearch(const StrList *sl, { if (sl != NULL && sl->len > 0) { - struct string **ret = + struct string *const*ret = bsearch(&s, sl->list, sl->len, sizeof(sl->list[0]), (int (*)(const void *, const void *)) comparator); struct string * const *base = &sl->list[0]; @@ -625,7 +625,7 @@ size_t StrList_SearchLongestPrefix(const StrList *sl, * no reason to keep going. */ while (longer_match_possible && (s_prefix_len < s_len)) { - char *separator_at; + const char *separator_at; if (direction_forward) { /* Find next separator, skipping the previous one. */ diff --git a/cf-testd/cf-testd.c b/cf-testd/cf-testd.c index d2dde9dc26f..933f6cce18b 100644 --- a/cf-testd/cf-testd.c +++ b/cf-testd/cf-testd.c @@ -738,7 +738,7 @@ static char *IncrementIPaddress(const char *ip_str) } int step = 1; - char *last_dot = strrchr(ip_str, '.'); + const char *last_dot = strrchr(ip_str, '.'); assert(last_dot != NULL); /* the doc comment says there must be dots! */ if (StringEqual(last_dot + 1, "255")) { diff --git a/libenv/sysinfo.c b/libenv/sysinfo.c index a41f144633b..1aa07396b25 100644 --- a/libenv/sysinfo.c +++ b/libenv/sysinfo.c @@ -325,7 +325,7 @@ void CalculateDomainName(const char *nodename, const char *dnsname, { /* If hostname is qualified */ - char *p = strchr(nodename, '.'); + const char *p = strchr(nodename, '.'); if (p != NULL) { diff --git a/libpromises/class.c b/libpromises/class.c index 01bf7af5107..dcd4f5c6bd8 100644 --- a/libpromises/class.c +++ b/libpromises/class.c @@ -294,7 +294,7 @@ void ClassTableIteratorDestroy(ClassTableIterator *iter) ClassRef ClassRefParse(const char *expr) { - char *name_start = strchr(expr, ':'); + const char *name_start = strchr(expr, ':'); if (!name_start) { return (ClassRef) { .ns = NULL, .name = xstrdup(expr) }; diff --git a/libpromises/eval_context.c b/libpromises/eval_context.c index 1c82b1dcb2f..4d25864eafa 100644 --- a/libpromises/eval_context.c +++ b/libpromises/eval_context.c @@ -1911,7 +1911,7 @@ bool EvalContextClassPutSoftTagsSetWithComment(EvalContext *ctx, const char *nam { bool ret; char *ns = NULL; - char *delim = strchr(name, ':'); + const char *delim = strchr(name, ':'); if (delim) { diff --git a/libpromises/generic_agent.c b/libpromises/generic_agent.c index b5ba2982303..a982f9a106c 100644 --- a/libpromises/generic_agent.c +++ b/libpromises/generic_agent.c @@ -344,7 +344,7 @@ static inline bool CanSetVariable(const EvalContext *ctx, VarRef *var_ref) static inline bool CanSetClass(const EvalContext *ctx, const char *class_spec) { char *ns = NULL; - char *ns_delim = strchr(class_spec, ':'); + const char *ns_delim = strchr(class_spec, ':'); if (ns_delim != NULL) { ns = xstrndup(class_spec, ns_delim - class_spec); diff --git a/libpromises/keyring.c b/libpromises/keyring.c index 9c5b2cb1914..72136e933d7 100644 --- a/libpromises/keyring.c +++ b/libpromises/keyring.c @@ -79,7 +79,7 @@ int RemovePublicKey(const char *id) while ((dirp = DirRead(dirh)) != NULL) { - char *c = strstr(dirp->d_name, suffix); + const char *c = strstr(dirp->d_name, suffix); if (c && c[strlen(suffix)] == '\0') /* dirp->d_name ends with suffix */ { diff --git a/libpromises/policy.c b/libpromises/policy.c index d539dd4532d..0b9fc3ae496 100644 --- a/libpromises/policy.c +++ b/libpromises/policy.c @@ -311,7 +311,7 @@ const char *PolicyGetPolicyFileHash(const Policy *policy, const char *policy_fil static const char *StripNamespace(const char *full_symbol) { - char *sep = strchr(full_symbol, CF_NS); + const char *sep = strchr(full_symbol, CF_NS); if (sep == NULL) { @@ -871,7 +871,7 @@ char *QualifiedNameNamespaceComponent(const char *qualified_name) */ char *QualifiedNameScopeComponent(const char *qualified_name) { - char *sep = strchr(qualified_name, CF_NS); + const char *sep = strchr(qualified_name, CF_NS); if (sep) { return xstrdup(sep + 1); diff --git a/libpromises/promises.c b/libpromises/promises.c index 9e955f54965..76cbdda4215 100644 --- a/libpromises/promises.c +++ b/libpromises/promises.c @@ -639,7 +639,7 @@ static void DereferenceAndPutComment(Promise* pp, const char *comment) { free(pp->comment); - char *sp; + const char *sp; if ((sp = strstr(comment, "$(this.promiser)")) != NULL || (sp = strstr(comment, "${this.promiser}")) != NULL) { diff --git a/libpromises/verify_vars.c b/libpromises/verify_vars.c index 234aa061073..17a3164df19 100644 --- a/libpromises/verify_vars.c +++ b/libpromises/verify_vars.c @@ -73,8 +73,8 @@ static bool IsLegalVariableName(EvalContext *ctx, const Promise *pp) return false; } - char *bracket = strchr(var_name, '['); - char *dot = strchr(var_name, '.'); + const char *bracket = strchr(var_name, '['); + const char *dot = strchr(var_name, '.'); /* we only care about variable name prefix, not dots inside array keys */ if ((dot != NULL) && ((bracket == NULL) || (dot < bracket))) {