[PATCH v5 05/26] perf annotate: Normalize arch__dwarf_regnum() error return values

From: Tengda Wu

Date: Tue Sep 08 2026 - 10:34:40 EST


arch__dwarf_regnum() returns inconsistent error values: early path
returns -1 while the main lookup returns -ENOENT/-EINVAL from
get_dwarf_regnum(). Callers only check for -1, so genuine failures
can slip through.

Normalize all failures to -1 to match the callers' expectation.

Suggested-by: Shuai Xue <xueshuai@xxxxxxxxxxxxxxxxx>
Signed-off-by: Tengda Wu <wutengda@xxxxxxxxxxxxxxx>
---
tools/perf/util/annotate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index df70e95a8470..f3d17d153b67 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -2492,7 +2492,7 @@ static int arch__dwarf_regnum(const struct arch *arch, const char *str)

reg = get_dwarf_regnum(regname, arch->id.e_machine, arch->id.e_flags);
free(regname);
- return reg;
+ return reg < 0 ? -1 : reg;
}

/*
--
2.34.1