[PATCH v1 3/3] perf header: Transition WARN macros to debug.h equivalents

From: Ian Rogers

Date: Thu Sep 10 2026 - 13:58:44 EST


Avoid a checkpatch.pl warning on the use of asm/bug.h by switching the
use of WARN macros to explicit tests and then using pr_warning from
debug.h.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/header.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 78b16a098148..a3e6c334a289 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -8,7 +8,6 @@
#include <stdlib.h>
#include <string.h>

-#include <asm/bug.h>
#include <byteswap.h>
#include <dirent.h>
#include <linux/bitops.h>
@@ -384,8 +383,10 @@ static int do_read_bitmap(struct feat_fd *ff, unsigned long **pset, u64 *psize)
static int write_tracing_data(struct feat_fd *ff,
struct evlist *evlist __maybe_unused)
{
- if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
+ if (ff->buf) {
+ pr_warning("Error: calling %s in pipe-mode.\n", __func__);
return -1;
+ }

#ifdef HAVE_LIBTRACEEVENT
return read_tracing_data(ff->fd, &evlist__core(evlist)->entries);
@@ -406,8 +407,10 @@ static int write_build_id(struct feat_fd *ff,
if (!perf_session__read_build_ids(session, true))
return -1;

- if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
+ if (ff->buf) {
+ pr_warning("Error: calling %s in pipe-mode.\n", __func__);
return -1;
+ }

err = perf_session__write_buildid_table(session, ff);
if (err < 0) {
@@ -1013,8 +1016,10 @@ static int write_auxtrace(struct feat_fd *ff,
struct perf_session *session;
int err;

- if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
+ if (ff->buf) {
+ pr_warning("Error: calling %s in pipe-mode.\n", __func__);
return -1;
+ }

session = container_of(ff->ph, struct perf_session, header);

@@ -1108,9 +1113,10 @@ static int write_dir_format(struct feat_fd *ff,
session = container_of(ff->ph, struct perf_session, header);
data = session->data;

- if (WARN_ON(!perf_data__is_dir(data)))
+ if (!perf_data__is_dir(data)) {
+ pr_warning("Expected data to be a directory");
return -1;
-
+ }
return do_write(ff, &data->dir.version, sizeof(data->dir.version));
}

@@ -3714,9 +3720,10 @@ static int process_dir_format(struct feat_fd *ff,
session = container_of(ff->ph, struct perf_session, header);
data = session->data;

- if (WARN_ON(!perf_data__is_dir(data)))
+ if (!perf_data__is_dir(data)) {
+ pr_warning("Expected data to be a directory");
return -1;
-
+ }
return do_read_u64(ff, &data->dir.version);
}

@@ -4394,8 +4401,10 @@ static int do_write_feat(struct feat_fd *ff, int type,
if (!feat_ops[type].write)
return -1;

- if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__))
+ if (ff->buf) {
+ pr_warning("Error: calling %s in pipe-mode.\n", __func__);
return -1;
+ }

(*p)->offset = lseek(ff->fd, 0, SEEK_CUR);

--
2.55.0.1007.g17ff1f9808-goog