[PATCH 4/4] ld: Fix discarded-qualifiers problems in ldelf.c
Mark Wielaard
mark@klomp.org
Sun May 3 12:34:22 GMT 2026
Hi Calvin,
On Fri, Apr 24, 2026 at 07:19:47PM -0700, Calvin Owens wrote:
> ../../ld/ldelf.c: In function ‘ldelf_search_needed’:
> ../../ld/ldelf.c:538:34: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> 538 | if ((slash = strrchr (replacement, '/')) != NULL)
> | ^
>
> Fix this by passing the obviously equal non-const pointer to strrchr(),
> instead of the const one.
This one I also found and fixed in almost the same way in
https://inbox.sourceware.org/binutils/20260502170132.3303884-3-mark@klomp.org/
>
> ../../ld/ldelf.c: In function ‘ldelf_parse_ld_so_conf_include’:
> ../../ld/ldelf.c:797:17: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> 797 | char *p = strrchr (filename, '/');
> | ^~~~~~~
>
> Fix this by declaring the local pointer varaible as const, since it is
> not modified.
Likewise.
Again my apologies for not seeing your patch earlier. It would have
saved me some unnecessary work.
Cheers,
Mark
More information about the Binutils
mailing list