From c0c79c41527365ca7de30c75daaa018ea01fff97 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 27 Nov 2025 15:45:55 +0100 Subject: [PATCH] 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 --- libmount/src/optlist.c | 7 +++---- libmount/src/optstr.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c index 256c592fd..1d32c2dd6 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 ac20d8755..51526973d 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); -- 2.47.3