On 18/10/22 08:28, Markus Armbruster wrote:
The has_FOO for pointer-valued FOO are redundant, except for arrays.
They are also a nuisance to work with.  Recent commit "qapi: Start to
elide redundant has_FOO in generated C" provided the means to elide
them step by step.  This is the step for qapi/run-state.json.

Said commit explains the transformation in more detail.  The invariant
violations mentioned there do not occur here.

The rationale here is qapi free() has always be able to deal with a NULL
argument (commit fb3182ce6e "qapi: add qapi-types.py code generator"
from Tue Jul 19 14:50:40 2011).

Cc: Paolo Bonzini <pbonz...@redhat.com>
Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
  softmmu/runstate.c     | 18 +++++-------------
  scripts/qapi/schema.py |  1 -
  2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index 1e68680b9d..682a810d3c 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c

@@ -517,13 +514,8 @@ void qemu_system_guest_panicked(GuestPanicInformation 
*info)
  void qemu_system_guest_crashloaded(GuestPanicInformation *info)
  {
      qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded");
-
-    qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN,
-                                   !!info, info);
-
-    if (info) {
-        qapi_free_GuestPanicInformation(info);
-    }
+    qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, info);
+    qapi_free_GuestPanicInformation(info);
  }

Preferably updating the commit description:
Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>

Reply via email to