[PATCH] Fix the strrchr error for DOS based filesystem

H.J. Lu hjl.tools@gmail.com
Sun May 3 00:32:51 GMT 2026


On Sun, May 3, 2026 at 6:52 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, May 3, 2026 at 1:02 AM Mark Wielaard <mark@klomp.org> wrote:
> >
> > In annotate_source strrchr is called on a const char *. So the result
> > should also be stored in a const char *.
> >
> >         * gprof/source.c (annotate_source): Make name_only a const char *.
> > ---
> >  gprof/source.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/gprof/source.c b/gprof/source.c
> > index 494f6ecc9b20..aae55f6d758f 100644
> > --- a/gprof/source.c
> > +++ b/gprof/source.c
> > @@ -98,7 +98,8 @@ annotate_source (Source_File *sf, unsigned int max_width,
> >    bool new_line;
> >    char buf[8192];
> >    char *fname;
> > -  char *annotation, *name_only;
> > +  char *annotation;
> > +  const char *name_only;
> >    FILE *ifp, *ofp;
> >    Search_List_Elem *sle = src_search_list.head;
> >
> > --
> > 2.54.0
> >
>
> We should  combine this strrchr patch set with the patch set from
> Calvin Owens <calvin@wbinvd.org>:
>
> https://patchwork.sourceware.org/project/binutils/list/?series=60290
>

Calvin's patch has been checked in.   Here is another one 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/

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

gprof/

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

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-the-strrchr-error-for-DOS-based-filesystem.patch
Type: application/x-patch
Size: 2274 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260503/d93a82f7/attachment.bin>


More information about the Binutils mailing list