]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix the strrchr error for DOS based filesystem
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 3 May 2026 00:25:28 +0000 (08:25 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 3 May 2026 03:49:59 +0000 (11:49 +0800)
Fix the strrchr error like:

gprof/source.c:130:28: error: initialization discards â€˜const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
  130 |             char *bslash = strrchr (sf->name, '\\');

binutils/

* bucomm.c (template_in_dir): Make bslash const char *.

gprof/

* source.c (annotate_source): Make bslash const char *.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
binutils/bucomm.c
gprof/source.c

index 14a0db22425ce0a8dc285bd221c3ef45753eb105..da704bcf838a145e1cea65b4bff5627e405d27f4 100644 (file)
@@ -502,7 +502,7 @@ template_in_dir (const char *path)
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
   {
     /* We could have foo/bar\\baz, or foo\\bar, or d:bar.  */
-    char *bslash = strrchr (path, '\\');
+    const char *bslash = strrchr (path, '\\');
 
     if (slash == NULL || (bslash != NULL && bslash > slash))
       slash = bslash;
index 494f6ecc9b2053497c4ad31739b4fd9d211dffb6..860c0b5fec02518f9663fe22297336050dfbea42 100644 (file)
@@ -126,7 +126,7 @@ annotate_source (Source_File *sf, unsigned int max_width,
          name_only = strrchr (sf->name, '/');
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
          {
-           char *bslash = strrchr (sf->name, '\\');
+           const char *bslash = strrchr (sf->name, '\\');
            if (name_only == NULL || (bslash != NULL && bslash > name_only))
              name_only = bslash;
            if (name_only == NULL && sf->name[0] != '\0' && sf->name[1] == ':')
@@ -183,7 +183,7 @@ annotate_source (Source_File *sf, unsigned int max_width,
       filename = strrchr (sf->name, '/');
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
        {
-         char *bslash = strrchr (sf->name, '\\');
+         const char *bslash = strrchr (sf->name, '\\');
          if (filename == NULL || (bslash != NULL && bslash > filename))
            filename = bslash;
          if (filename == NULL && sf->name[0] != '\0' && sf->name[1] == ':')