From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, Zecheng Li <zli94@ncsu.edu>,
Yanbo Zhao <yzhao62@ncsu.edu>,
Tengda Wu <wutengda@huaweicloud.com>,
Shuai Xue <xueshuai@linux.alibaba.com>
Subject: [PATCH v5 2/4] perf annotate-data: A small cleanup in __add_member_cb()
Date: Fri, 18 Sep 2026 23:37:43 -0700 [thread overview]
Message-ID: <20260919063745.48444-3-namhyung@kernel.org> (raw)
In-Reply-To: <20260919063745.48444-1-namhyung@kernel.org>
Check return value of strbuf_init() and die_get_typename() to make sure
if typename of a member gets never NULL.
Also remove the check for typedef by just using die_get_real_type().
It can get rid of member_type variable as well.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/annotate-data.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
index aff60a630fd05b01..845a5d8c2b84b6a6 100644
--- a/tools/perf/util/annotate-data.c
+++ b/tools/perf/util/annotate-data.c
@@ -226,7 +226,7 @@ static int __add_member_cb(Dwarf_Die *die, void *arg)
{
struct annotated_member *parent = arg;
struct annotated_member *member;
- Dwarf_Die member_type, die_mem;
+ Dwarf_Die die_mem;
Dwarf_Word size, loc, bit_size = 0;
Dwarf_Attribute attr;
struct strbuf sb;
@@ -239,14 +239,15 @@ static int __add_member_cb(Dwarf_Die *die, void *arg)
if (member == NULL)
return DIE_FIND_CB_END;
- strbuf_init(&sb, 32);
- die_get_typename(die, &sb);
+ if (strbuf_init(&sb, 32) < 0) {
+ free(member);
+ return DIE_FIND_CB_END;
+ }
- __die_get_real_type(die, &member_type);
- if (dwarf_tag(&member_type) == DW_TAG_typedef)
- die_get_real_type(&member_type, &die_mem);
- else
- die_mem = member_type;
+ if (die_get_typename(die, &sb) < 0)
+ strbuf_add(&sb, "(unknown type)", 14);
+
+ die_get_real_type(die, &die_mem);
if (dwarf_aggregate_size(&die_mem, &size) < 0)
size = 0;
--
2.55.0
next prev parent reply other threads:[~2026-09-19 6:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 6:37 [PATCH v5 0/4] perf annotate-data: Support flexible array types Namhyung Kim
2026-09-19 6:37 ` [PATCH v5 1/4] perf dwarf-aux: Add die_has_flex_array() helper Namhyung Kim
2026-09-19 6:42 ` sashiko-bot
2026-09-19 6:37 ` Namhyung Kim [this message]
2026-09-19 6:43 ` [PATCH v5 2/4] perf annotate-data: A small cleanup in __add_member_cb() sashiko-bot
2026-09-19 6:37 ` [PATCH v5 3/4] perf annotate-data: Allow out-of-size access for flex-array types Namhyung Kim
2026-09-19 6:45 ` sashiko-bot
2026-09-19 6:37 ` [PATCH v5 4/4] perf annotate-data: Adjust type offset for flex-array Namhyung Kim
2026-09-19 6:46 ` sashiko-bot
2026-09-19 7:19 ` Namhyung Kim
2026-09-19 16:18 ` [PATCH v5 0/4] perf annotate-data: Support flexible array types Ian Rogers
2026-09-19 17:56 ` Namhyung Kim
2026-09-19 22:44 ` Ian Rogers
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=20260919063745.48444-3-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=wutengda@huaweicloud.com \
--cc=xueshuai@linux.alibaba.com \
--cc=yzhao62@ncsu.edu \
--cc=zli94@ncsu.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.