diff options
author | Markus Armbruster <armbru@redhat.com> | 2019-04-16 17:38:50 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2019-04-17 19:15:39 +0200 |
commit | 4c8b7c8b255061ce264df21a55f69a1318d45654 (patch) | |
tree | 709e35fb99540ee965770892b2fc04ef993a6f9b /util | |
parent | f5852efa293e1dc240cdfde30b42cea1f780a1f2 (diff) |
error: Fix error_report_err(), warn_report_err() hint printing
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() in commit
e43ead1d0b9.
Fix both to use error_printf().
Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190416153850.5186-1-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
[Commit message tweaked]
Diffstat (limited to 'util')
-rw-r--r-- | util/error.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/util/error.c b/util/error.c index 934a78e1b1..712b4d4b5d 100644 --- a/util/error.c +++ b/util/error.c @@ -223,7 +223,7 @@ void error_report_err(Error *err) { error_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } @@ -232,7 +232,7 @@ void warn_report_err(Error *err) { warn_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } |