[libvirt] [PATCH 2/3] util: do not repeat the pm-is-supported string

Ján Tomko posted 3 patches 6 years, 5 months ago
[libvirt] [PATCH 2/3] util: do not repeat the pm-is-supported string
Posted by Ján Tomko 6 years, 5 months ago
Use a 'binary' variable to hold it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/virnodesuspend.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index af0ed615e1..62e62bb171 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -239,22 +239,23 @@ static int
 virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported)
 {
     VIR_AUTOPTR(virCommand) cmd = NULL;
+    const char *binary = "pm-is-supported";
     int status;
 
     *supported = false;
 
     switch (target) {
     case VIR_NODE_SUSPEND_TARGET_MEM:
-        cmd = virCommandNewArgList("pm-is-supported", "--suspend", NULL);
+        cmd = virCommandNewArgList(binary, "--suspend", NULL);
         break;
     case VIR_NODE_SUSPEND_TARGET_DISK:
-        cmd = virCommandNewArgList("pm-is-supported", "--hibernate", NULL);
+        cmd = virCommandNewArgList(binary, "--hibernate", NULL);
         break;
     case VIR_NODE_SUSPEND_TARGET_HYBRID:
-        cmd = virCommandNewArgList("pm-is-supported", "--suspend-hybrid", NULL);
+        cmd = virCommandNewArgList(binary, "--suspend-hybrid", NULL);
         break;
     default:
-        return ret;
+        return -1;
     }
 
     if (virCommandRun(cmd, &status) < 0)
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] util: do not repeat the pm-is-supported string
Posted by Andrea Bolognani 6 years, 5 months ago
On Tue, 2019-08-13 at 17:24 +0200, Ján Tomko wrote:
> +++ b/src/util/virnodesuspend.c
>      case VIR_NODE_SUSPEND_TARGET_HYBRID:
> -        cmd = virCommandNewArgList("pm-is-supported", "--suspend-hybrid", NULL);
> +        cmd = virCommandNewArgList(binary, "--suspend-hybrid", NULL);
>          break;
>      default:
> -        return ret;
> +        return -1;
>      }

Yeah, this last hunk should have been in the first patch O:-)

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] util: do not repeat the pm-is-supported string
Posted by Ján Tomko 6 years, 5 months ago
On Wed, Aug 14, 2019 at 11:05:39AM +0200, Andrea Bolognani wrote:
>On Tue, 2019-08-13 at 17:24 +0200, Ján Tomko wrote:
>> +++ b/src/util/virnodesuspend.c
>>      case VIR_NODE_SUSPEND_TARGET_HYBRID:
>> -        cmd = virCommandNewArgList("pm-is-supported", "--suspend-hybrid", NULL);
>> +        cmd = virCommandNewArgList(binary, "--suspend-hybrid", NULL);
>>          break;
>>      default:
>> -        return ret;
>> +        return -1;
>>      }
>
>Yeah, this last hunk should have been in the first patch O:-)
>

Oops, --amend vs. rebase --continue bit me again.

Jano

>  Reviewed-by: Andrea Bolognani <abologna@redhat.com>
>
>-- 
>Andrea Bolognani / Red Hat / Virtualization
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list