summaryrefslogtreecommitdiffstats
path: root/hw/vfio/ccw.c
diff options
context:
space:
mode:
authorCornelia Huck2018-08-30 16:59:01 +0200
committerMarkus Armbruster2018-09-24 17:13:07 +0200
commitc55510b72218a2d0b263eda006fd7aac1496b694 (patch)
treed62c582b3d29c693f68ec6f55accc828bb98b228 /hw/vfio/ccw.c
parentMerge remote-tracking branch 'remotes/xanclic/tags/pull-block-2018-08-31-v2' ... (diff)
downloadqemu-c55510b72218a2d0b263eda006fd7aac1496b694.tar.gz
qemu-c55510b72218a2d0b263eda006fd7aac1496b694.tar.xz
qemu-c55510b72218a2d0b263eda006fd7aac1496b694.zip
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 'hw/vfio/ccw.c')
-rw-r--r--hw/vfio/ccw.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index e96bbdc78b..9246729a75 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -37,24 +37,12 @@ typedef struct VFIOCCWDevice {
bool warned_orb_pfch;
} VFIOCCWDevice;
-static inline void warn_once(bool *warned, const char *fmt, ...)
-{
- va_list ap;
-
- if (!warned || *warned) {
- return;
- }
- *warned = true;
- va_start(ap, fmt);
- warn_vreport(fmt, ap);
- va_end(ap);
-}
-
static inline void warn_once_pfch(VFIOCCWDevice *vcdev, SubchDev *sch,
const char *msg)
{
- warn_once(&vcdev->warned_orb_pfch, "vfio-ccw (devno %x.%x.%04x): %s",
- sch->cssid, sch->ssid, sch->devno, msg);
+ warn_report_once_cond(&vcdev->warned_orb_pfch,
+ "vfio-ccw (devno %x.%x.%04x): %s",
+ sch->cssid, sch->ssid, sch->devno, msg);
}
static void vfio_ccw_compute_needs_reset(VFIODevice *vdev)