[PATCH v3 2/2] perf disasm: Fix compilation error with stubs

Masami Hiramatsu (Google)
2024-11-13T00:21:33Z

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Commit 333ea1451083 ("perf disasm: Define stubs for the LLVM and capstone
disassemblers") introduces stubs but that causes compilation errors when
LIBCAPSTONE=n or LIBLLVM=n. This fixes those errors.

Fixes: 333ea1451083 ("perf disasm: Define stubs for the LLVM and capstone disassemblers")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
tools/perf/util/disasm.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index df6c172c9c7f..88f71f6e5e70 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -1422,14 +1422,14 @@ read_symbol(const char *filename, struct map *map, struct symbol *sym,
free(buf);
return NULL;
}
-#else // defined(HAVE_LIBCAPSTONE_SUPPORT) || defined(HAVE_LIBLLVM_SUPPORT)
+#endif // defined(HAVE_LIBCAPSTONE_SUPPORT) || defined(HAVE_LIBLLVM_SUPPORT)
+
static void symbol__disassembler_missing(const char *disassembler, const char *filename,
struct symbol *sym)
{
pr_debug("The %s disassembler isn't linked in for %s in %s\n",
disassembler, sym->name, filename);
}
-#endif

#ifdef HAVE_LIBCAPSTONE_SUPPORT
static void print_capstone_detail(cs_insn *insn, char *buf, size_t len,
@@ -1724,7 +1724,8 @@ static int symbol__disassemble_capstone(char *filename, struct symbol *sym,
}
#else // HAVE_LIBCAPSTONE_SUPPORT
static int symbol__disassemble_capstone(char *filename, struct symbol *sym,
- struct annotate_args *args)
+ struct annotate_args *args __maybe_unused)
+{
symbol__disassembler_missing("capstone", filename, sym);
return -1;
}