Since glibc-2.43 and ISO C23 [1]:
- For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type.
Add missing 'const' qualifiers to pointer variables that are assigned
from functions returning 'const char *' (e.g. strchr, strstr), which
caused -Wdiscarded-qualifiers warnings under glibc-2.43:
remotes/oci.c: In function 'ocierofs_parse_ref':
remotes/oci.c:1058:15: warning: assignment discards 'const' qualifier from
pointer target type [-Wdiscarded-qualifiers]
1058 | slash = strchr(ref_str, '/');
| ^
[1] https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html
Signed-off-by: Yifan Zhao <[email protected]>
---
lib/remotes/oci.c | 2 +-
lib/remotes/s3.c | 2 +-
mount/main.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/remotes/oci.c b/lib/remotes/oci.c
index 193464b..e5b2f7c 100644
--- a/lib/remotes/oci.c
+++ b/lib/remotes/oci.c
@@ -1047,7 +1047,7 @@ out_auth:
*/
static int ocierofs_parse_ref(struct ocierofs_ctx *ctx, const char *ref_str)
{
- char *slash, *colon, *dot;
+ const char *slash, *colon, *dot;
const char *repo_part;
size_t len;
char *tmp;
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index 5e4e9d3..768232a 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -897,7 +897,7 @@ s3erofs_create_object_iterator(struct erofs_s3 *s3, const
char *path,
const char *delimiter)
{
struct s3erofs_object_iterator *iter;
- char *prefix;
+ const char *prefix;
iter = calloc(1, sizeof(struct s3erofs_object_iterator));
if (!iter)
diff --git a/mount/main.c b/mount/main.c
index 5fdda81..3530b2c 100644
--- a/mount/main.c
+++ b/mount/main.c
@@ -122,7 +122,7 @@ static void version(void)
static int erofsmount_parse_oci_option(const char *option)
{
struct ocierofs_config *oci_cfg = &nbdsrc.ocicfg;
- char *p;
+ const char *p;
long idx;
if ((p = strstr(option, "oci.blob=")) != NULL) {
--
2.47.3