Web lists-archives.com

[tip:perf/core] perf tools: Include errno.h where needed




Commit-ID:  a43783aeec5fac8ef372ff8c0a5bbb3056fc0604
Gitweb:     http://git.kernel.org/tip/a43783aeec5fac8ef372ff8c0a5bbb3056fc0604
Author:     Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
AuthorDate: Tue, 18 Apr 2017 10:46:11 -0300
Committer:  Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Wed, 19 Apr 2017 13:01:51 -0300

perf tools: Include errno.h where needed

Removing it from util.h, part of an effort to disentangle the includes
hell, that makes changes to util.h or something included by it to cause
a complete rebuild of the tools.

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-ztrjy52q1rqcchuy3rubfgt2@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
 tools/perf/arch/arm64/util/dwarf-regs.c      | 1 +
 tools/perf/arch/powerpc/util/kvm-stat.c      | 1 +
 tools/perf/arch/powerpc/util/perf_regs.c     | 1 +
 tools/perf/arch/s390/util/kvm-stat.c         | 1 +
 tools/perf/arch/x86/tests/intel-cqm.c        | 1 +
 tools/perf/arch/x86/tests/perf-time-to-tsc.c | 1 +
 tools/perf/arch/x86/util/auxtrace.c          | 1 +
 tools/perf/arch/x86/util/intel-bts.c         | 1 +
 tools/perf/arch/x86/util/intel-pt.c          | 1 +
 tools/perf/arch/x86/util/kvm-stat.c          | 1 +
 tools/perf/arch/x86/util/perf_regs.c         | 1 +
 tools/perf/builtin-annotate.c                | 1 +
 tools/perf/builtin-buildid-cache.c           | 1 +
 tools/perf/builtin-buildid-list.c            | 1 +
 tools/perf/builtin-c2c.c                     | 1 +
 tools/perf/builtin-diff.c                    | 1 +
 tools/perf/builtin-ftrace.c                  | 1 +
 tools/perf/builtin-help.c                    | 1 +
 tools/perf/builtin-inject.c                  | 1 +
 tools/perf/builtin-kmem.c                    | 1 +
 tools/perf/builtin-kvm.c                     | 1 +
 tools/perf/builtin-lock.c                    | 1 +
 tools/perf/builtin-record.c                  | 1 +
 tools/perf/builtin-report.c                  | 1 +
 tools/perf/builtin-sched.c                   | 1 +
 tools/perf/builtin-script.c                  | 1 +
 tools/perf/builtin-stat.c                    | 1 +
 tools/perf/builtin-timechart.c               | 1 +
 tools/perf/builtin-trace.c                   | 1 +
 tools/perf/perf.c                            | 1 +
 tools/perf/tests/attr.c                      | 1 +
 tools/perf/tests/backward-ring-buffer.c      | 1 +
 tools/perf/tests/bpf.c                       | 1 +
 tools/perf/tests/builtin-test.c              | 1 +
 tools/perf/tests/code-reading.c              | 1 +
 tools/perf/tests/event-times.c               | 1 +
 tools/perf/tests/evsel-roundtrip-name.c      | 1 +
 tools/perf/tests/hists_link.c                | 1 +
 tools/perf/tests/mmap-basic.c                | 1 +
 tools/perf/tests/openat-syscall-all-cpus.c   | 1 +
 tools/perf/tests/openat-syscall-tp-fields.c  | 1 +
 tools/perf/tests/openat-syscall.c            | 1 +
 tools/perf/tests/parse-events.c              | 1 +
 tools/perf/tests/perf-record.c               | 1 +
 tools/perf/tests/pmu.c                       | 1 +
 tools/perf/tests/sdt.c                       | 1 +
 tools/perf/tests/sw-clock.c                  | 1 +
 tools/perf/tests/switch-tracking.c           | 1 +
 tools/perf/tests/task-exit.c                 | 1 +
 tools/perf/ui/browsers/hists.c               | 1 +
 tools/perf/util/annotate.c                   | 1 +
 tools/perf/util/auxtrace.h                   | 1 +
 tools/perf/util/bpf-loader.c                 | 1 +
 tools/perf/util/bpf-loader.h                 | 2 ++
 tools/perf/util/bpf-prologue.c               | 1 +
 tools/perf/util/bpf-prologue.h               | 2 ++
 tools/perf/util/build-id.c                   | 1 +
 tools/perf/util/c++/clang-c.h                | 1 +
 tools/perf/util/cloexec.c                    | 1 +
 tools/perf/util/comm.c                       | 1 +
 tools/perf/util/config.c                     | 1 +
 tools/perf/util/counts.c                     | 1 +
 tools/perf/util/data-convert-bt.c            | 1 +
 tools/perf/util/data.c                       | 1 +
 tools/perf/util/drv_configs.c                | 1 +
 tools/perf/util/dso.c                        | 1 +
 tools/perf/util/dwarf-aux.c                  | 1 +
 tools/perf/util/env.c                        | 1 +
 tools/perf/util/event.c                      | 1 +
 tools/perf/util/evlist.c                     | 1 +
 tools/perf/util/evsel.c                      | 1 +
 tools/perf/util/header.c                     | 1 +
 tools/perf/util/hist.c                       | 1 +
 tools/perf/util/intel-bts.c                  | 1 +
 tools/perf/util/jitdump.c                    | 1 +
 tools/perf/util/lzma.c                       | 1 +
 tools/perf/util/machine.c                    | 1 +
 tools/perf/util/ordered-events.c             | 1 +
 tools/perf/util/parse-events.c               | 1 +
 tools/perf/util/pmu.c                        | 1 +
 tools/perf/util/probe-file.c                 | 1 +
 tools/perf/util/quote.c                      | 1 +
 tools/perf/util/record.c                     | 1 +
 tools/perf/util/session.c                    | 1 +
 tools/perf/util/sort.c                       | 1 +
 tools/perf/util/stat.c                       | 1 +
 tools/perf/util/strbuf.c                     | 1 +
 tools/perf/util/strfilter.c                  | 1 +
 tools/perf/util/symbol-minimal.c             | 1 +
 tools/perf/util/thread-stack.c               | 1 +
 tools/perf/util/thread.c                     | 1 +
 tools/perf/util/thread_map.c                 | 1 +
 tools/perf/util/unwind-libunwind-local.c     | 1 +
 tools/perf/util/util.h                       | 1 -
 tools/perf/util/vdso.c                       | 2 +-
 95 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/arm64/util/dwarf-regs.c b/tools/perf/arch/arm64/util/dwarf-regs.c
index aea610c..f268720 100644
--- a/tools/perf/arch/arm64/util/dwarf-regs.c
+++ b/tools/perf/arch/arm64/util/dwarf-regs.c
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <errno.h>
 #include <stddef.h>
 #include <dwarf-regs.h>
 #include <linux/ptrace.h> /* for struct user_pt_regs */
diff --git a/tools/perf/arch/powerpc/util/kvm-stat.c b/tools/perf/arch/powerpc/util/kvm-stat.c
index 74eee30..249723f 100644
--- a/tools/perf/arch/powerpc/util/kvm-stat.c
+++ b/tools/perf/arch/powerpc/util/kvm-stat.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include "util/kvm-stat.h"
 #include "util/parse-events.h"
 #include "util/debug.h"
diff --git a/tools/perf/arch/powerpc/util/perf_regs.c b/tools/perf/arch/powerpc/util/perf_regs.c
index 4268f77..f860dc41 100644
--- a/tools/perf/arch/powerpc/util/perf_regs.c
+++ b/tools/perf/arch/powerpc/util/perf_regs.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <string.h>
 #include <regex.h>
 
diff --git a/tools/perf/arch/s390/util/kvm-stat.c b/tools/perf/arch/s390/util/kvm-stat.c
index ed57df2..d233e2eb 100644
--- a/tools/perf/arch/s390/util/kvm-stat.c
+++ b/tools/perf/arch/s390/util/kvm-stat.c
@@ -9,6 +9,7 @@
  * as published by the Free Software Foundation.
  */
 
+#include <errno.h>
 #include "../../util/kvm-stat.h"
 #include <asm/sie.h>
 
diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c
index 7f064eb..03c62eb 100644
--- a/tools/perf/arch/x86/tests/intel-cqm.c
+++ b/tools/perf/arch/x86/tests/intel-cqm.c
@@ -7,6 +7,7 @@
 #include "arch-tests.h"
 
 #include <sys/mman.h>
+#include <errno.h>
 #include <string.h>
 
 static pid_t spawn(void)
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
index a8e37f3..e3ae9cf 100644
--- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c
+++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <unistd.h>
diff --git a/tools/perf/arch/x86/util/auxtrace.c b/tools/perf/arch/x86/util/auxtrace.c
index cc1d865..6aa3f2a 100644
--- a/tools/perf/arch/x86/util/auxtrace.c
+++ b/tools/perf/arch/x86/util/auxtrace.c
@@ -13,6 +13,7 @@
  *
  */
 
+#include <errno.h>
 #include <stdbool.h>
 
 #include "../../util/header.h"
diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c
index 5132775..af2bce7 100644
--- a/tools/perf/arch/x86/util/intel-bts.c
+++ b/tools/perf/arch/x86/util/intel-bts.c
@@ -13,6 +13,7 @@
  *
  */
 
+#include <errno.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/bitops.h>
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index 90fa228..f630de0 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -13,6 +13,7 @@
  *
  */
 
+#include <errno.h>
 #include <stdbool.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
diff --git a/tools/perf/arch/x86/util/kvm-stat.c b/tools/perf/arch/x86/util/kvm-stat.c
index b63d4be..bf817be 100644
--- a/tools/perf/arch/x86/util/kvm-stat.c
+++ b/tools/perf/arch/x86/util/kvm-stat.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include "../../util/kvm-stat.h"
 #include <asm/svm.h>
 #include <asm/vmx.h>
diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index 3bf3548..f95edeb 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <string.h>
 #include <regex.h>
 
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index b2b2722..7a5dc7e 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -33,6 +33,7 @@
 #include "util/block-range.h"
 
 #include <dlfcn.h>
+#include <errno.h>
 #include <linux/bitmap.h>
 
 struct perf_annotate {
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index 94b55ee..034c3d4 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -10,6 +10,7 @@
 #include <sys/time.h>
 #include <time.h>
 #include <dirent.h>
+#include <errno.h>
 #include <unistd.h>
 #include "builtin.h"
 #include "perf.h"
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 26f4e60..fdaca16 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -16,6 +16,7 @@
 #include "util/session.h"
 #include "util/symbol.h"
 #include "util/data.h"
+#include <errno.h>
 
 static int sysfs__fprintf_build_id(FILE *fp)
 {
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index cc8156a..a90c126 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -9,6 +9,7 @@
  *   Dick Fowles <fowles@xxxxxxxxxxx>
  *   Joe Mario <jmario@xxxxxxxxxx>
  */
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 09be77b..eec5df8 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -19,6 +19,7 @@
 #include "util/data.h"
 #include "util/config.h"
 
+#include <errno.h>
 #include <inttypes.h>
 #include <stdlib.h>
 #include <math.h>
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index f80fb60..67d1403 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -9,6 +9,7 @@
 #include "builtin.h"
 #include "perf.h"
 
+#include <errno.h>
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 1f18385..7bde2f5 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -13,6 +13,7 @@
 #include <subcmd/help.h>
 #include "util/debug.h"
 #include <linux/kernel.h>
+#include <errno.h>
 
 static struct man_viewer_list {
 	struct man_viewer_list *next;
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 65e1c02..b102ee7 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -22,6 +22,7 @@
 #include <subcmd/parse-options.h>
 
 #include <linux/list.h>
+#include <errno.h>
 
 struct perf_inject {
 	struct perf_tool	tool;
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 15754a4..9409c94 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/rbtree.h>
 #include <linux/string.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <locale.h>
 #include <regex.h>
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index e82a697..4066042 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -26,6 +26,7 @@
 
 #include <linux/kernel.h>
 #include <linux/time64.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <termios.h>
 #include <semaphore.h>
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 6f93a6f..ff98652 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include "builtin.h"
 #include "perf.h"
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 65429d1..70340ff 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -40,6 +40,7 @@
 #include "util/perf-hooks.h"
 #include "asm/bug.h"
 
+#include <errno.h>
 #include <inttypes.h>
 #include <unistd.h>
 #include <sched.h>
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 66a2f44..2941d8d 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -40,6 +40,7 @@
 #include "util/auxtrace.h"
 
 #include <dlfcn.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/bitmap.h>
 #include <linux/stringify.h>
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index aefab93..39996c5 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -28,6 +28,7 @@
 #include <sys/resource.h>
 #include <inttypes.h>
 
+#include <errno.h>
 #include <semaphore.h>
 #include <pthread.h>
 #include <math.h>
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index a710f68..853651a 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -32,6 +32,7 @@
 #include "asm/bug.h"
 #include "util/mem-events.h"
 #include "util/dump-insn.h"
+#include <errno.h>
 #include <inttypes.h>
 
 #include "sane_ctype.h"
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1da86e6..be2cd53 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -69,6 +69,7 @@
 
 #include <linux/time64.h>
 #include <api/fs/fs.h>
+#include <errno.h>
 #include <stdlib.h>
 #include <sys/prctl.h>
 #include <inttypes.h>
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index a24b229..e2576c8 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -12,6 +12,7 @@
  * of the License.
  */
 
+#include <errno.h>
 #include <inttypes.h>
 #include <traceevent/event-parse.h>
 
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 4160d94..e065c4a 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -41,6 +41,7 @@
 #include "syscalltbl.h"
 #include "rb_resort.h"
 
+#include <errno.h>
 #include <inttypes.h>
 #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */
 #include <stdlib.h>
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 94e9418..9ccccb0 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -19,6 +19,7 @@
 #include "util/debug.h"
 #include <api/fs/fs.h>
 #include <api/fs/tracing_path.h>
+#include <errno.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index bb2bc48..ba87cd5 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -18,6 +18,7 @@
  * permissions. All the event text files are stored there.
  */
 
+#include <errno.h>
 #include <inttypes.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index 42e892b..50f6d7a 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -8,6 +8,7 @@
 #include <sys/prctl.h>
 #include "tests.h"
 #include "debug.h"
+#include <errno.h>
 
 #define NR_ITERS 111
 
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 67fe5ee..b78fbd6 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdio.h>
 #include <sys/epoll.h>
 #include <util/util.h>
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index f029737..552fd9a 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -3,6 +3,7 @@
  *
  * Builtin regression testing command: ever growing number of sanity tests
  */
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 #include "builtin.h"
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index fe6aac8..3a8bf15 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <inttypes.h>
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c
index 8d376e1..4683514 100644
--- a/tools/perf/tests/event-times.c
+++ b/tools/perf/tests/event-times.c
@@ -1,4 +1,5 @@
 #include <linux/compiler.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <string.h>
 #include "tests.h"
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index 9221d27..d2bea6f 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -3,6 +3,7 @@
 #include "parse-events.h"
 #include "tests.h"
 #include "debug.h"
+#include <errno.h>
 #include <linux/kernel.h>
 
 static int perf_evsel__roundtrip_cache_name_test(void)
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 1bd26d2..a26cbb7 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -9,6 +9,7 @@
 #include "thread.h"
 #include "parse-events.h"
 #include "hists_common.h"
+#include <errno.h>
 #include <linux/kernel.h>
 
 struct sample {
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index aba40eb..15c7708 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 /* For the CLR_() macros */
 #include <pthread.h>
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index eb7b1a6..b7dece0 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 /* For the CPU_* macros */
 #include <pthread.h>
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index f52239f..9788fac 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -5,6 +5,7 @@
 #include "thread_map.h"
 #include "tests.h"
 #include "debug.h"
+#include <errno.h>
 
 #ifndef O_DIRECTORY
 #define O_DIRECTORY    00200000
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 5964938..5f0c700 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <api/fs/tracing_path.h>
 #include <linux/err.h>
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 05621748..66ecc3f 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -5,6 +5,7 @@
 #include "tests.h"
 #include "debug.h"
 #include "util.h"
+#include <errno.h>
 #include <linux/kernel.h>
 #include <linux/hw_breakpoint.h>
 #include <api/fs/fs.h>
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index a8b6fda..d37cd95 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 /* For the CLR_() macros */
 #include <pthread.h>
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index de6498d..a6d7aef 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -2,6 +2,7 @@
 #include "pmu.h"
 #include "util.h"
 #include "tests.h"
+#include <errno.h>
 #include <linux/kernel.h>
 
 /* Simulated format definitions. */
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index 26e5b7a..f73b3c5 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdio.h>
 #include <sys/epoll.h>
 #include <util/util.h>
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index 29f11c4..828494d 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 7ddbe26..65474fd 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -1,5 +1,6 @@
 #include <sys/time.h>
 #include <sys/prctl.h>
+#include <errno.h>
 #include <time.h>
 #include <stdlib.h>
 
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 01a5ba2..32873ec 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -4,6 +4,7 @@
 #include "cpumap.h"
 #include "tests.h"
 
+#include <errno.h>
 #include <signal.h>
 
 static int exited;
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index bc397bb..0916575 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 297bf5c..683f834 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -7,6 +7,7 @@
  * Released under the GPL v2. (and only v2, not any later version)
  */
 
+#include <errno.h>
 #include <inttypes.h>
 #include "util.h"
 #include "ui/ui.h"
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 26fb1ee..9f0de72 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -17,6 +17,7 @@
 #define __PERF_AUXTRACE_H
 
 #include <sys/types.h>
+#include <errno.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <linux/list.h>
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 27af9d6..bf21c1c 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -11,6 +11,7 @@
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <errno.h>
 #include "perf.h"
 #include "debug.h"
 #include "bpf-loader.h"
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index f2b737b..4886386 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -85,6 +85,8 @@ int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err,
 			       char *buf, size_t size);
 
 #else
+#include <errno.h>
+
 static inline struct bpf_object *
 bpf__prepare_load(const char *filename __maybe_unused,
 		  bool source __maybe_unused)
diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c
index 6cdbee1..1356220 100644
--- a/tools/perf/util/bpf-prologue.c
+++ b/tools/perf/util/bpf-prologue.c
@@ -12,6 +12,7 @@
 #include "bpf-loader.h"
 #include "bpf-prologue.h"
 #include "probe-finder.h"
+#include <errno.h>
 #include <dwarf-regs.h>
 #include <linux/filter.h>
 
diff --git a/tools/perf/util/bpf-prologue.h b/tools/perf/util/bpf-prologue.h
index d94cbea..ba56483 100644
--- a/tools/perf/util/bpf-prologue.h
+++ b/tools/perf/util/bpf-prologue.h
@@ -18,6 +18,8 @@ int bpf__gen_prologue(struct probe_trace_arg *args, int nargs,
 		      struct bpf_insn *new_prog, size_t *new_cnt,
 		      size_t cnt_space);
 #else
+#include <errno.h>
+
 static inline int
 bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused,
 		  int nargs __maybe_unused,
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 3c07555..8d8ef1d 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -7,6 +7,7 @@
  * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
  */
 #include "util.h"
+#include <errno.h>
 #include <stdio.h>
 #include "build-id.h"
 #include "event.h"
diff --git a/tools/perf/util/c++/clang-c.h b/tools/perf/util/c++/clang-c.h
index 0eadd79..ccafcf7 100644
--- a/tools/perf/util/c++/clang-c.h
+++ b/tools/perf/util/c++/clang-c.h
@@ -20,6 +20,7 @@ extern int perf_clang__compile_bpf(const char *filename,
 				   size_t *p_obj_buf_sz);
 #else
 
+#include <errno.h>
 
 static inline void perf_clang__init(void) { }
 static inline void perf_clang__cleanup(void) { }
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index f0dcd0e..4b4f00d 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <sched.h>
 #include "util.h"
 #include "../perf.h"
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c
index 32837b6..530a62a 100644
--- a/tools/perf/util/comm.c
+++ b/tools/perf/util/comm.c
@@ -1,5 +1,6 @@
 #include "comm.h"
 #include "util.h"
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <linux/refcount.h>
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 88783aa..f560403 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -8,6 +8,7 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
+#include <errno.h>
 #include "util.h"
 #include "cache.h"
 #include <subcmd/exec-cmd.h>
diff --git a/tools/perf/util/counts.c b/tools/perf/util/counts.c
index e3fde31..83fedd0 100644
--- a/tools/perf/util/counts.c
+++ b/tools/perf/util/counts.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdlib.h>
 #include "evsel.h"
 #include "counts.h"
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index c3277b3..89d5031 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -7,6 +7,7 @@
  * Released under the GPL v2. (and only v2, not any later version)
  */
 
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/compiler.h>
 #include <linux/kernel.h>
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 60bfc9c..e84bbc8 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -2,6 +2,7 @@
 #include <linux/kernel.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 
diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c
index 1647f28..eec7542 100644
--- a/tools/perf/util/drv_configs.c
+++ b/tools/perf/util/drv_configs.c
@@ -17,6 +17,7 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "pmu.h"
+#include <errno.h>
 
 static int
 perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 6ad5773..cd061dc 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -2,6 +2,7 @@
 #include <linux/kernel.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <errno.h>
 #include "symbol.h"
 #include "dso.h"
 #include "machine.h"
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index 780ee46..f5acda1 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -17,6 +17,7 @@
  *
  */
 
+#include <errno.h>
 #include <inttypes.h>
 #include <stdbool.h>
 #include "util.h"
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 075fc77..9e21538 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -1,6 +1,7 @@
 #include "cpumap.h"
 #include "env.h"
 #include "util.h"
+#include <errno.h>
 
 struct perf_env perf_env;
 
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 53b81b2..1fc1217 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index cf27039..f74ea2e 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -8,6 +8,7 @@
  */
 #include "util.h"
 #include <api/fs/fs.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <poll.h>
 #include "cpumap.h"
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 757f73c..44a7aef 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -8,6 +8,7 @@
  */
 
 #include <byteswap.h>
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/bitops.h>
 #include <api/fs/tracing_path.h>
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 51865b8..28a3acb 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include "util.h"
 #include "string2.h"
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index af3bd5d..65d4275 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -10,6 +10,7 @@
 #include "annotate.h"
 #include "srcline.h"
 #include "ui/progress.h"
+#include <errno.h>
 #include <math.h>
 
 static bool hists__filter_entry_by_dso(struct hists *hists,
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index 471ed8b..b2834ac 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -14,6 +14,7 @@
  */
 
 #include <endian.h>
+#include <errno.h>
 #include <byteswap.h>
 #include <inttypes.h>
 #include <linux/kernel.h>
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index d6d2532..388078d 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -1,5 +1,6 @@
 #include <sys/sysmacros.h>
 #include <sys/types.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 9ddea5c..5b73b26 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <lzma.h>
 #include <stdio.h>
 #include <linux/compiler.h>
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f13f46a..cdbfe3e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include "callchain.h"
 #include "debug.h"
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index df05be6..4de398c 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/list.h>
 #include <linux/compiler.h>
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 535c7cb..d4877c8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1,5 +1,6 @@
 #include <linux/hw_breakpoint.h>
 #include <linux/err.h>
+#include <errno.h>
 #include "util.h"
 #include "../perf.h"
 #include "evlist.h"
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 7503fa1..bca1844 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1,6 +1,7 @@
 #include <linux/list.h>
 #include <linux/compiler.h>
 #include <sys/types.h>
+#include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdbool.h>
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 7942ea5..1ccaefd 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -14,6 +14,7 @@
  * GNU General Public License for more details.
  *
  */
+#include <errno.h>
 #include <sys/uio.h>
 #include "util.h"
 #include "event.h"
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c
index 293534c..1ba8920 100644
--- a/tools/perf/util/quote.c
+++ b/tools/perf/util/quote.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <stdlib.h>
 #include "strbuf.h"
 #include "quote.h"
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index 98bf584..d91bdf5 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -2,6 +2,7 @@
 #include "evsel.h"
 #include "cpumap.h"
 #include "parse-events.h"
+#include <errno.h>
 #include <api/fs/fs.h>
 #include "util.h"
 #include "cloexec.h"
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 0695e08..19d993f 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <linux/kernel.h>
 #include <traceevent/event-parse.h>
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 63ad537..9aa058e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <sys/mman.h>
 #include "sort.h"
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index bbf30b2..c581744 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -1,3 +1,4 @@
+#include <errno.h>
 #include <inttypes.h>
 #include <math.h>
 #include "stat.h"
diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 81759390..e91b5e8 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -1,6 +1,7 @@
 #include "debug.h"
 #include "util.h"
 #include <linux/kernel.h>
+#include <errno.h>
 
 int prefixcmp(const char *str, const char *prefix)
 {
diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c
index 3b068e0..4dc0af6 100644
--- a/tools/perf/util/strfilter.c
+++ b/tools/perf/util/strfilter.c
@@ -2,6 +2,7 @@
 #include "string2.h"
 #include "strfilter.h"
 
+#include <errno.h>
 #include "sane_ctype.h"
 
 /* Operators */
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index 870ef0f..40bf5d4 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -1,6 +1,7 @@
 #include "symbol.h"
 #include "util.h"
 
+#include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <string.h>
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index d330152..dd17d6a 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -15,6 +15,7 @@
 
 #include <linux/rbtree.h>
 #include <linux/list.h>
+#include <errno.h>
 #include "thread.h"
 #include "event.h"
 #include "machine.h"
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index e8ce6ab..378c418 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -1,4 +1,5 @@
 #include "../perf.h"
+#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
index ef86bf5..63ead7b 100644
--- a/tools/perf/util/thread_map.c
+++ b/tools/perf/util/thread_map.c
@@ -1,4 +1,5 @@
 #include <dirent.h>
+#include <errno.h>
 #include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 788f4d3..f8455be 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -16,6 +16,7 @@
  */
 
 #include <elf.h>
+#include <errno.h>
 #include <gelf.h>
 #include <fcntl.h>
 #include <inttypes.h>
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 850ca54..6fd9963 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -18,7 +18,6 @@
 #include <stdarg.h>
 #include <string.h>
 #include <term.h>
-#include <errno.h>
 #include <limits.h>
 #include <sys/param.h>
 #include <sys/types.h>
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c
index 7bdcad4..d3c39ee 100644
--- a/tools/perf/util/vdso.c
+++ b/tools/perf/util/vdso.c
@@ -1,4 +1,4 @@
-
+#include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>