[PATCH 3/9] perf libbfd: Include the headers that are used

From: Ian Rogers

Date: Wed Sep 16 2026 - 02:13:38 EST


libbfd.c uses errno, PATH_MAX, strdup(), strlen(), strcmp(), memcpy()
and pthread_once() but relies on other headers to drag in <errno.h>,
<limits.h>, <string.h> and <pthread.h>. The BPF disassembly code needs
<inttypes.h> for PRIx64 and <stdint.h> for uintptr_t for the same
reason.

Include them directly and group the includes so that the system ones
come before perf's own.

No functional change.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/perf/util/libbfd.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/libbfd.c b/tools/perf/util/libbfd.c
index 131bfedf48cd..1b23a261a9ce 100644
--- a/tools/perf/util/libbfd.c
+++ b/tools/perf/util/libbfd.c
@@ -1,5 +1,19 @@
// SPDX-License-Identifier: GPL-2.0
#include "libbfd.h"
+
+#include <errno.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <tools/dis-asm-compat.h>
+
#include "annotate.h"
#include "bpf-event.h"
#include "bpf-utils.h"
@@ -11,15 +25,13 @@
#include "symbol.h"
#include "symbol_conf.h"
#include "util.h"
-#include <tools/dis-asm-compat.h>
+
#ifdef HAVE_LIBBPF_SUPPORT
#include <bpf/bpf.h>
#include <bpf/btf.h>
#include <bpf/libbpf.h>
#endif
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
+
#define PACKAGE "perf"
#include <bfd.h>

--
2.55.0.1032.g73a4cd73de-goog