If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call). Fix such cases.
If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
&error_fatel, this means that we don't break error_abort
(we'll abort on error_set, not on error_propagate)
Reported-by: Kevin Wolf <address@hidden>
Reported-by: Greg Kurz <address@hidden>
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
qapi/qapi-visit-core.c | 56 ++++++++++++++++---------------------
qapi/qmp-dispatch.c | 7 ++---
qapi/string-input-visitor.c | 7 ++---
3 files changed, 30 insertions(+), 40 deletions(-)
+++ b/qapi/qmp-dispatch.c
@@ -78,7 +78,7 @@ static QDict *qmp_dispatch_check_obj(const QObject *request,
bool allow_oob,
static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
bool allow_oob, Error **errp)
{
- Error *local_err = NULL;
+ ERRP_AUTO_PROPAGATE();
bool oob;
const char *command;
QDict *args, *dict;
@@ -129,9 +129,8 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds,
QObject *request,
qobject_ref(args);
}
- cmd->fn(args, &ret, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ cmd->fn(args, &ret, errp);
+ if (*errp) {
} else if (cmd->options & QCO_NO_SUCCESS_RESP) {