* [Qemu-devel] [PATCH] error-report: Add info_report_once helper
@ 2019-09-13 15:43 Cyrill Gorcunov
2019-09-14 18:40 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Cyrill Gorcunov @ 2019-09-13 15:43 UTC (permalink / raw)
To: qemu-devel
We already have error_report_once and warn_report_once,
thus lets add info_report_once to complement. Actually
I use this helper a lot so might be usefull for others.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
include/qemu/error-report.h | 13 +++++++++++++
util/qemu-error.c | 20 ++++++++++++++++++++
2 files changed, 33 insertions(+)
Index: vanilla.git/include/qemu/error-report.h
===================================================================
--- vanilla.git.orig/include/qemu/error-report.h
+++ vanilla.git/include/qemu/error-report.h
@@ -47,6 +47,8 @@ bool error_report_once_cond(bool *printe
GCC_FMT_ATTR(2, 3);
bool warn_report_once_cond(bool *printed, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
+bool info_report_once_cond(bool *printed, const char *fmt, ...)
+ GCC_FMT_ATTR(2, 3);
void error_init(const char *argv0);
@@ -72,6 +74,17 @@ void error_init(const char *argv0);
fmt, ##__VA_ARGS__); \
})
+/*
+ * Similar to info_report(), except it prints the message just once.
+ * Return true when it prints, false otherwise.
+ */
+#define info_report_once(fmt, ...) \
+ ({ \
+ static bool print_once_; \
+ info_report_once_cond(&print_once_, \
+ fmt, ##__VA_ARGS__); \
+ })
+
const char *error_get_progname(void);
extern bool enable_timestamp_msg;
Index: vanilla.git/util/qemu-error.c
===================================================================
--- vanilla.git.orig/util/qemu-error.c
+++ vanilla.git/util/qemu-error.c
@@ -350,6 +350,26 @@ bool warn_report_once_cond(bool *printed
return true;
}
+/*
+ * Like info_report(), except print just once.
+ * If *printed is false, print the message, and flip *printed to true.
+ * Return whether the message was printed.
+ */
+bool info_report_once_cond(bool *printed, const char *fmt, ...)
+{
+ va_list ap;
+
+ assert(printed);
+ if (*printed) {
+ return false;
+ }
+ *printed = true;
+ va_start(ap, fmt);
+ vreport(REPORT_TYPE_INFO, fmt, ap);
+ va_end(ap);
+ return true;
+}
+
static char *qemu_glog_domains;
static void qemu_log_func(const gchar *log_domain,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] error-report: Add info_report_once helper
2019-09-13 15:43 [Qemu-devel] [PATCH] error-report: Add info_report_once helper Cyrill Gorcunov
@ 2019-09-14 18:40 ` Markus Armbruster
2019-09-14 18:57 ` Cyrill Gorcunov
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2019-09-14 18:40 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: qemu-devel
You neglected to cc: the maintainer (me). I spotted this anyway, more
or less by chance. Next time, please use scripts/get_maintainer.pl to
find people you might want to cc:.
Cyrill Gorcunov <gorcunov@gmail.com> writes:
> We already have error_report_once and warn_report_once,
> thus lets add info_report_once to complement. Actually
> I use this helper a lot so might be usefull for others.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Patch looks reasonable enough. However, the new info_report_once() and
info_report_once_cond() aren't used. Your commit message suggests you
have users in unpublished code. Is that correct?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] error-report: Add info_report_once helper
2019-09-14 18:40 ` Markus Armbruster
@ 2019-09-14 18:57 ` Cyrill Gorcunov
0 siblings, 0 replies; 3+ messages in thread
From: Cyrill Gorcunov @ 2019-09-14 18:57 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
On Sat, Sep 14, 2019 at 08:40:40PM +0200, Markus Armbruster wrote:
> You neglected to cc: the maintainer (me). I spotted this anyway, more
> or less by chance. Next time, please use scripts/get_maintainer.pl to
> find people you might want to cc:.
Ah, sorry for that. Will do next time, thanks!
> Cyrill Gorcunov <gorcunov@gmail.com> writes:
>
> > We already have error_report_once and warn_report_once,
> > thus lets add info_report_once to complement. Actually
> > I use this helper a lot so might be usefull for others.
> >
> > Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
>
> Patch looks reasonable enough. However, the new info_report_once() and
> info_report_once_cond() aren't used. Your commit message suggests you
> have users in unpublished code. Is that correct?
Exactly. I work on yet unpublished but open source code
(https://src.openvz.org/projects/UP/repos/qemu/browse) to be
precise. But work is still in progress and hasn't been pushed
out.
You know I posted the patch simply because it might be
useful for someone and it looks a bit incomplete that
we have "warn/error once" but no info_once. Up to you
to decide if we need it in vanilla tree.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-14 18:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 15:43 [Qemu-devel] [PATCH] error-report: Add info_report_once helper Cyrill Gorcunov
2019-09-14 18:40 ` Markus Armbruster
2019-09-14 18:57 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).