Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add WARN_ONCE equivalent for UI warnings

Currently WARN_ONCE prints to stderr and corrupts the TUI. Add
equivalent methods for UI warnings.

Signed-off-by: James Clark <james.clark@arm.com>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20210729155805.2830-2-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
1094795e ec02f2b1

+14
+14
tools/perf/util/debug.h
··· 22 22 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 23 23 #define pr_warning(fmt, ...) \ 24 24 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 25 + #define pr_warning_once(fmt, ...) ({ \ 26 + static int __warned; \ 27 + if (unlikely(!__warned)) { \ 28 + pr_warning(fmt, ##__VA_ARGS__); \ 29 + __warned = 1; \ 30 + } \ 31 + }) 25 32 #define pr_info(fmt, ...) \ 26 33 eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 27 34 #define pr_debug(fmt, ...) \ ··· 62 55 63 56 int ui__error(const char *format, ...) __printf(1, 2); 64 57 int ui__warning(const char *format, ...) __printf(1, 2); 58 + #define ui__warning_once(format, ...) ({ \ 59 + static int __warned; \ 60 + if (unlikely(!__warned)) { \ 61 + ui__warning(format, ##__VA_ARGS__); \ 62 + __warned = 1; \ 63 + } \ 64 + }) 65 65 66 66 void pr_stat(const char *fmt, ...); 67 67