[binutils-gdb/binutils-2_46-branch] Fix the strrchr error for DOS based filesystem
H.J. Lu
hjl@sourceware.org
Thu May 7 12:25:49 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b88558ce1a1c405db0846b938960c22e4ceb41f8
commit b88558ce1a1c405db0846b938960c22e4ceb41f8
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 3 08:25:28 2026 +0800
Fix the strrchr error for DOS based filesystem
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/
PR binutils/34125
* bucomm.c (template_in_dir): Make bslash const char *.
gprof/
PR binutils/34125
* source.c (annotate_source): Make bslash const char *.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 365fc34606d2d566855e8ba3db9c4f7986ed3bcc)
Diff:
---
binutils/bucomm.c | 2 +-
gprof/source.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
index 0f25a3c4038..3e8f5907363 100644
--- a/binutils/bucomm.c
+++ b/binutils/bucomm.c
@@ -500,7 +500,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;
diff --git a/gprof/source.c b/gprof/source.c
index aae55f6d758..4aa7504e8df 100644
--- a/gprof/source.c
+++ b/gprof/source.c
@@ -127,7 +127,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] == ':')
@@ -184,7 +184,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] == ':')
More information about the Binutils-cvs
mailing list