From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracefs: Do not discard const ename for updating it
Date: Sun, 8 Nov 2026 03:48:11 -0500 [thread overview]
Message-ID: <20261108034811.70c1681c@fedora> (raw)
From: Steven Rostedt <rostedt@goodmis.org>
The const char *ename is set as the event name that is passed into
kprobe_alloc(). If the event isn't defined, then it uses the address
instead. It creates a copy of the addr and zeros out a ':' if it exists.
Currently, this is done by pointing ename at the newly allocated addr copy
and it is modified by a temp variable. But the compiler complains that the
temp variable discards the const (which it does).
Instead of playing games with the const ename, use a new char *aname
variable to copy the addr with and do the updates. Then set ename to point
to this variable when the event name doesn't exist.
By initializing aname to NULL it can always be freed without having to
test if event is defined or not. This removes having to typecast ename to
free it too.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
src/tracefs-kprobes.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/tracefs-kprobes.c b/src/tracefs-kprobes.c
index 09b09d7ace04..2297d078b330 100644
--- a/src/tracefs-kprobes.c
+++ b/src/tracefs-kprobes.c
@@ -27,6 +27,7 @@ kprobe_alloc(enum tracefs_dynevent_type type, const char *system, const char *ev
struct tracefs_dynevent *kp;
const char *sys = system;
const char *ename = event;
+ char *aname = NULL;
char *tmp;
if (!addr) {
@@ -37,17 +38,17 @@ kprobe_alloc(enum tracefs_dynevent_type type, const char *system, const char *ev
sys = KPROBE_DEFAULT_GROUP;
if (!event) {
- ename = strdup(addr);
- if (!ename)
+ aname = strdup(addr);
+ if (!aname)
return NULL;
- tmp = strchr(ename, ':');
+ tmp = strchr(aname, ':');
if (tmp)
*tmp = '\0';
+ ename = aname;
}
kp = tfs_dynevent_alloc(type, sys, ename, addr, format);
- if (!event)
- free((char *)ename);
+ free(aname);
return kp;
}
--
2.53.0
reply other threads:[~2026-11-08 8:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261108034811.70c1681c@fedora \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox