]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: make local variable 'const'
authorAndrew Burgess <aburgess@redhat.com>
Fri, 5 Dec 2025 14:15:11 +0000 (14:15 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 5 Dec 2025 14:23:30 +0000 (14:23 +0000)
This build error was reported to me off list:

  common/callback.c:993:13: error: initializing 'char *' with an expression of type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    993 |       char *q = strchr (m, ',');
        |             ^   ~~~~~~~~~~~~~~~

This is because with C23, strchr returns 'const char *' if a 'const
char *' is passed as an argument.

In this case M is 'const char *', so Q should also be 'const char *'.
And indeed, we don't write via Q at any time, so lets make it 'const'.

There should be no user visible changes after this commit.

sim/common/callback.c

index 54b9476ff7ea87b59d50321c6999a3a0b5bfa5c9..7f4ee81bc8b7c23fa3b8dfdbb13b26a13cbe92b3 100644 (file)
@@ -990,7 +990,7 @@ cb_host_to_target_stat (host_callback *cb, const struct stat *hs, void *ts)
 
   while (m)
     {
-      char *q = strchr (m, ',');
+      const char *q = strchr (m, ',');
       int size;
 
       /* FIXME: Use sscanf? */