aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCornelia Huck <cohuck@redhat.com>2018-08-30 16:59:01 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-09-24 17:13:07 +0200
commitc55510b72218a2d0b263eda006fd7aac1496b694 (patch)
treed62c582b3d29c693f68ec6f55accc828bb98b228 /include
parentd6f71af65410d3e003ba331c5e57eddcf716cbcf (diff)
downloadqemu-c55510b72218a2d0b263eda006fd7aac1496b694.zip
qemu-c55510b72218a2d0b263eda006fd7aac1496b694.tar.gz
qemu-c55510b72218a2d0b263eda006fd7aac1496b694.tar.bz2
qemu-error: add {error, warn}_report_once_cond
Add two functions to print an error/warning report once depending on a passed-in condition variable and flip it if printed. This is useful if you want to print a message not once-globally, but e.g. once-per-device. Inspired by warn_once() in hw/vfio/ccw.c, which has been replaced with warn_report_once_cond(). Signed-off-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20180830145902.27376-2-cohuck@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Function comments reworded] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/error-report.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 72fab2b..e415128 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -44,6 +44,11 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+bool error_report_once_cond(bool *printed, const char *fmt, ...)
+ GCC_FMT_ATTR(2, 3);
+bool warn_report_once_cond(bool *printed, const char *fmt, ...)
+ GCC_FMT_ATTR(2, 3);
+
/*
* Similar to error_report(), except it prints the message just once.
* Return true when it prints, false otherwise.