[libvirt] [PATCH 5/5] virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand

Peter Krempa posted 5 patches 6 years, 4 months ago
[libvirt] [PATCH 5/5] virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand
Posted by Peter Krempa 6 years, 4 months ago
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tools/virsh-domain.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 8c24935938..fbfdc09c0d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9512,7 +9512,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = 0;
     const vshCmdOpt *opt = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    VIR_AUTOPTR(virJSONValue) pretty = NULL;

     VSH_EXCLUSIVE_OPTIONS("hmp", "pretty");

@@ -9538,8 +9537,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)

     if (vshCommandOptBool(cmd, "pretty")) {
         char *tmp;
-        pretty = virJSONValueFromString(result);
-        if (pretty && (tmp = virJSONValueToString(pretty, true))) {
+        if ((tmp = virJSONStringReformat(result, true))) {
             VIR_FREE(result);
             result = tmp;
             virTrimSpaces(result, NULL);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand
Posted by Daniel Henrique Barboza 6 years, 4 months ago

On 9/16/19 9:45 AM, Peter Krempa wrote:
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

>   tools/virsh-domain.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 8c24935938..fbfdc09c0d 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -9512,7 +9512,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
>       unsigned int flags = 0;
>       const vshCmdOpt *opt = NULL;
>       virBuffer buf = VIR_BUFFER_INITIALIZER;
> -    VIR_AUTOPTR(virJSONValue) pretty = NULL;
>
>       VSH_EXCLUSIVE_OPTIONS("hmp", "pretty");
>
> @@ -9538,8 +9537,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
>
>       if (vshCommandOptBool(cmd, "pretty")) {
>           char *tmp;
> -        pretty = virJSONValueFromString(result);
> -        if (pretty && (tmp = virJSONValueToString(pretty, true))) {
> +        if ((tmp = virJSONStringReformat(result, true))) {
>               VIR_FREE(result);
>               result = tmp;
>               virTrimSpaces(result, NULL);

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list