perf session: Don't write to memory pointed to a const pointer

Since it is freshly allocated just attribute it to a non-const pointer
and then change it via that pointer.

That way we avoid const-correctness warnings in recent glibc versions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2026-01-27 02:09:37 -03:00
parent 678ed6b707
commit f1321cce84

View File

@ -2676,7 +2676,7 @@ bool perf_session__has_switch_events(struct perf_session *session)
int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, u64 addr)
{
char *bracket;
char *bracket, *name;
struct ref_reloc_sym *ref;
struct kmap *kmap;
@ -2684,13 +2684,13 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, u6
if (ref == NULL)
return -ENOMEM;
ref->name = strdup(symbol_name);
ref->name = name = strdup(symbol_name);
if (ref->name == NULL) {
free(ref);
return -ENOMEM;
}
bracket = strchr(ref->name, ']');
bracket = strchr(name, ']');
if (bracket)
*bracket = '\0';