aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-11-27 15:45:55 +0100
committerKarel Zak <kzak@redhat.com>2025-11-27 15:45:55 +0100
commitc0c79c41527365ca7de30c75daaa018ea01fff97 (patch)
treea5fbffa99e819d8540eee895f9678514123cb8cf
parentdbe4c16973d5d0f69ba3bf1bd8942a51de9a0933 (diff)
downloadutil-linux-c0c79c41527365ca7de30c75daaa018ea01fff97.tar.gz
libmount: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in optlist_add_flags(), mnt_opt_value_with(), and mnt_optstr_apply_flags() functions. These warnings are reported by gcc 15 which defaults to the C23 standard. The strchr() and strstr() functions return pointers into const strings, so the receiving variables must be declared as const char *. Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libmount/src/optlist.c7
-rw-r--r--libmount/src/optstr.c2
2 files changed, 4 insertions, 5 deletions
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
index 256c592fde..1d32c2dd6e 100644
--- a/libmount/src/optlist.c
+++ b/libmount/src/optlist.c
@@ -601,7 +601,7 @@ static int optlist_add_flags(struct libmnt_optlist *ls, unsigned long flags,
for (ent = map; ent && ent->name; ent++) {
- char *p;
+ const char *p;
size_t sz;
struct libmnt_opt *opt;
@@ -621,7 +621,7 @@ static int optlist_add_flags(struct libmnt_optlist *ls, unsigned long flags,
sz = p - ent->name;
p -= sz;
} else {
- p = (char *) ent->name;
+ p = ent->name;
sz = strlen(ent->name); /* alone "name" */
}
@@ -1162,8 +1162,7 @@ const char *mnt_opt_get_value(struct libmnt_opt *opt)
/* check if option value is @str or comma separated @str */
int mnt_opt_value_with(struct libmnt_opt *opt, const char *str)
{
- char *p;
- const char *start = opt->value;
+ const char *p, *start = opt->value;
size_t len;
if (!str || !opt->value || !*opt->value)
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index ac20d87557..51526973df 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -807,7 +807,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags,
const struct libmnt_optmap *ent;
struct ul_buffer buf = UL_INIT_BUFFER;
size_t sz;
- char *p;
+ const char *p;
ul_buffer_refer_string(&buf, *optstr);