@samitouri / QOSamiQemu / commits / 5237737439

error: Fix "to current monitor if we have one" comments

A number of print functions are documented to print to "current monitor if we have one, else stderr". Wrong, they print to the current monitor only when it's HMP. This is the case since commit 4ad417baa43 (error: Print error_report() to stderr if using qmp). Fix the comments to say "current HMP monitor if we have one". Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260114124713.3308719-2-armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> [Commit a582a5784e5f (monitor: move error_vprintf back to error-report.c) lost a comment this commit fixes, restore it]

Markus Armbruster committed Jan 14, 2026 at 13:47 UTC 523773743987bc7a16f485b5449732f6650f1003
3 files changed +23 -13
include/qapi/error.h
+2 -1
@@ -64,7 +64,8 @@
64 *
65 * = Reporting and destroying errors =
66 *
67 - * Report an error to the current monitor if we have one, else stderr:
67 + * Report an error to the current HMP monitor if we have one, else
68 + * stderr:
69 * error_report_err(err);
70 * This frees the error object.
71 *
util/error-report.c
+19 -10
@@ -62,6 +62,9 @@ error_printf_mon(Monitor *cur_mon, const char *fmt, ...)
62 return ret;
63 }
64
65 +/*
66 + * Print to the current HMP monitor if we have one, else to stderr.
67 + */
68 int error_vprintf(const char *fmt, va_list ap)
69 {
70 return error_vprintf_mon(monitor_cur(), fmt, ap);
@@ -174,7 +177,8 @@ void loc_set_file(const char *fname, int lno)
177 }
178
179 /*
177 - * Print current location to current monitor if we have one, else to stderr.
180 + * Print current location to current HMP monitor if we have one, else
181 + * to stderr.
182 */
183 static void print_loc(Monitor *cur)
184 {
@@ -214,7 +218,8 @@ char *real_time_iso8601(void)
218 }
219
220 /*
217 - * Print a message to current monitor if we have one, else to stderr.
221 + * Print a message to current HMP monitor if we have one, else to
222 + * stderr.
223 * @report_type is the type of message: error, warning or informational.
224 * Format arguments like vsprintf(). The resulting message should be
225 * a single phrase, with no newline or trailing punctuation.
@@ -270,7 +275,8 @@ static void vreport(report_type type, const char *fmt, va_list ap)
275 }
276
277 /*
273 - * Print an error message to current monitor if we have one, else to stderr.
278 + * Print an error message to current HMP monitor if we have one, else
279 + * to stderr.
280 * Format arguments like vsprintf(). The resulting message should be
281 * a single phrase, with no newline or trailing punctuation.
282 * Prepend the current location and append a newline.
@@ -282,7 +288,8 @@ void error_vreport(const char *fmt, va_list ap)
288 }
289
290 /*
285 - * Print a warning message to current monitor if we have one, else to stderr.
291 + * Print a warning message to current HMP monitor if we have one, else
292 + * to stderr.
293 * Format arguments like vsprintf(). The resulting message should be
294 * a single phrase, with no newline or trailing punctuation.
295 * Prepend the current location and append a newline.
@@ -293,8 +300,8 @@ void warn_vreport(const char *fmt, va_list ap)
300 }
301
302 /*
296 - * Print an information message to current monitor if we have one, else to
297 - * stderr.
303 + * Print an information message to current HMP monitor if we have one,
304 + * else to stderr.
305 * Format arguments like vsprintf(). The resulting message should be
306 * a single phrase, with no newline or trailing punctuation.
307 * Prepend the current location and append a newline.
@@ -305,7 +312,8 @@ void info_vreport(const char *fmt, va_list ap)
312 }
313
314 /*
308 - * Print an error message to current monitor if we have one, else to stderr.
315 + * Print an error message to current HMP monitor if we have one, else
316 + * to stderr.
317 * Format arguments like sprintf(). The resulting message should be
318 * a single phrase, with no newline or trailing punctuation.
319 * Prepend the current location and append a newline.
@@ -321,7 +329,8 @@ void error_report(const char *fmt, ...)
329 }
330
331 /*
324 - * Print a warning message to current monitor if we have one, else to stderr.
332 + * Print a warning message to current HMP monitor if we have one, else
333 + * to stderr.
334 * Format arguments like sprintf(). The resulting message should be a
335 * single phrase, with no newline or trailing punctuation.
336 * Prepend the current location and append a newline.
@@ -336,8 +345,8 @@ void warn_report(const char *fmt, ...)
345 }
346
347 /*
339 - * Print an information message to current monitor if we have one, else to
340 - * stderr.
348 + * Print an information message to current HMP monitor if we have one,
349 + * else to stderr.
350 * Format arguments like sprintf(). The resulting message should be a
351 * single phrase, with no newline or trailing punctuation.
352 * Prepend the current location and append a newline.
util/qemu-print.c
+2 -2
@@ -16,7 +16,7 @@
16
17 /*
18 * Print like vprintf().
19 - * Print to current monitor if we have one, else to stdout.
19 + * Print to current HMP monitor if we have one, else to stdout.
20 */
21 int qemu_vprintf(const char *fmt, va_list ap)
22 {
@@ -29,7 +29,7 @@ int qemu_vprintf(const char *fmt, va_list ap)
29
30 /*
31 * Print like printf().
32 - * Print to current monitor if we have one, else to stdout.
32 + * Print to current HMP monitor if we have one, else to stdout.
33 */
34 int qemu_printf(const char *fmt, ...)
35 {