[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] error: Fix error_report_err(), warn_report_err(
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH] error: Fix error_report_err(), warn_report_err() hint printing |
Date: |
Wed, 17 Apr 2019 19:16:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Markus Armbruster <address@hidden> writes:
> Before the from qerror_report() to error_setg(), hints looked like
> this:
>
> qerror_report(QERR_MACRO, ... arguments ...);
> error_printf_unless_qmp(... hint ...);
>
> error_printf_unless_qmp() made perfect sense: it printed exactly when
> qerror_report() did.
>
> After the conversion to error_setg():
>
> error_setg(errp, QERR_MACRO, ... arguments ...);
> error_printf_unless_qmp(... hint ...);
>
> The "unless QMP part" still made some sense; in QMP context, the
> caller generally uses the error as QMP response instead of printing
> it.
>
> However, everything else is wrong. If the caller handles the error,
> the hint gets printed anyway (unless QMP). If the caller reports the
> error, the hint gets printed *before* the report (unless QMP) or not
> at all (if QMP).
>
> Commit 50b7b000c91 fixed this by making hints a member of Error. It
> kept printing hints with error_printf_unless_qmp():
>
> void error_report_err(Error *err)
> {
> error_report("%s", error_get_pretty(err));
> + if (err->hint) {
> + error_printf_unless_qmp("%s\n", err->hint->str);
> + }
> error_free(err);
> }
>
> This is wrong. We should (and now can) print the hint exactly when we
> print the error.
>
> The mistake has since been copied to warn_report_err().
>
> Fix both to use error_printf().
>
> Reported-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> Cc: Eric Blake <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>
Queued.