[PULL 14/33] hmp: Simplify how qmp_human_monitor_command() gets output

Markus Armbruster posted 33 patches 5 years, 1 month ago
Maintainers: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Kevin Wolf <kwolf@redhat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Max Reitz <mreitz@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Cornelia Huck <cohuck@redhat.com>, Artyom Tarasenko <atar4qemu@gmail.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Laszlo Ersek <lersek@redhat.com>, Markus Armbruster <armbru@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Fam Zheng <fam@euphon.net>, Stefan Hajnoczi <stefanha@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Michael Roth <michael.roth@amd.com>, Jason Wang <jasowang@redhat.com>, Jason Dillaman <dillaman@redhat.com>, Sarah Harris <S.E.Harris@kent.ac.uk>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Halil Pasic <pasic@linux.ibm.com>, Juan Quintela <quintela@redhat.com>, Greg Kurz <groug@kaod.org>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Christian Borntraeger <borntraeger@de.ibm.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Aurelien Jarno <aurelien@aurel32.net>, Laurent Vivier <lvivier@redhat.com>, Stafford Horne <shorne@gmail.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Michael Rolnik <mrolnik@gmail.com>, Thomas Huth <thuth@redhat.com>, Jiri Pirko <jiri@resnulli.us>, David Hildenbrand <david@redhat.com>
[PULL 14/33] hmp: Simplify how qmp_human_monitor_command() gets output
Posted by Markus Armbruster 5 years, 1 month ago
Commit 48c043d0d1 "hmp: human-monitor-command: stop using the Memory
chardev driver" left us "if string is non-empty, duplicate it, else
duplicate the empty string".  Meh.  Duplicate it unconditionally.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20201211171152.146877-2-armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 monitor/misc.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/monitor/misc.c b/monitor/misc.c
index f2ee7cd77a..33d0dae2e8 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -136,11 +136,7 @@ char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
     handle_hmp_command(&hmp, command_line);
 
     WITH_QEMU_LOCK_GUARD(&hmp.common.mon_lock) {
-        if (qstring_get_length(hmp.common.outbuf) > 0) {
-            output = g_strdup(qstring_get_str(hmp.common.outbuf));
-        } else {
-            output = g_strdup("");
-        }
+        output = g_strdup(qstring_get_str(hmp.common.outbuf));
     }
 
 out:
-- 
2.26.2