[PATCH 4/9] perf pmu: Include the headers that are used
From: Ian Rogers
Date: Wed Sep 16 2026 - 02:18:37 EST
pmu.c uses errno, free() and the str*() functions but declares none of
them directly. <string.h> arrives by way of <linux/string.h>, and
<errno.h> and <stdlib.h> come from whatever the other headers happen to
drag in, which is fragile and breaks on C libraries that don't nest
their headers the same way.
Include the three directly.
<ctype.h> is deliberately not added. The isdigit(), tolower() and
toupper() used here are the macros from <linux/ctype.h>, which is
included on purpose and documents that it doesn't handle EOF the way the
standard C library does, so pulling in <ctype.h> would change which
implementation is used.
size_t is left alone too, as <stdio.h> is already included directly and
declares it.
No functional change.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/perf/util/pmu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 836e3b5615cd..744e253e851f 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -8,8 +8,11 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <stdio.h>
+#include <errno.h>
#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <dirent.h>
#include <api/fs/fs.h>
#include <api/io.h>
--
2.55.0.1032.g73a4cd73de-goog