qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC v5 080/126] QAPI: introduce ERRP_AUTO_PROPAGATE


From: Eric Blake
Subject: Re: [RFC v5 080/126] QAPI: introduce ERRP_AUTO_PROPAGATE
Date: Fri, 11 Oct 2019 14:22:50 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0

On 10/11/19 11:05 AM, Vladimir Sementsov-Ogievskiy wrote:
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) {

Looks a bit funny with the empty if clause, but not worth changing.

          g_assert(!ret);
      } else if (!ret) {

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]