]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: domain: Don't use ternaries inside vshPrint/vshError functions
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Feb 2022 17:40:01 +0000 (18:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 3 Mar 2022 10:06:57 +0000 (11:06 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index 7b4f8638a92ef4f301bd3d48611a9a42dba56ce7..89ad45dbf040c949d70699992454eea4a2602623 100644 (file)
@@ -3929,11 +3929,13 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
     /* No way to emulate deletion of just snapshot metadata
      * without support for the newer flags.  Oh well.  */
     if (has_snapshots_metadata) {
-        vshError(ctl,
-                 snapshots_metadata ?
-                 _("Unable to remove metadata of %d snapshots") :
-                 _("Refusing to undefine while %d snapshots exist"),
-                 has_snapshots_metadata);
+        if (snapshots_metadata)
+            vshError(ctl, _("Unable to remove metadata of %d snapshots"),
+                     has_snapshots_metadata);
+        else
+            vshError(ctl, _("Refusing to undefine while %d snapshots exist"),
+                     has_snapshots_metadata);
+
         goto cleanup;
     }
 
@@ -8401,9 +8403,11 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
 
             /* Compare original XML with edited.  Has it changed at all? */
             if (STREQ(desc, desc_edited)) {
-                vshPrintExtra(ctl, "%s",
-                              title ? _("Domain title not changed\n") :
-                                      _("Domain description not changed\n"));
+                if (title)
+                    vshPrintExtra(ctl, "%s", _("Domain title not changed\n"));
+                else
+                    vshPrintExtra(ctl, "%s", _("Domain description not changed\n"));
+
                 return true;
             }
 
@@ -8412,26 +8416,32 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
         }
 
         if (virDomainSetMetadata(dom, type, desc, NULL, NULL, flags) < 0) {
-            vshError(ctl, "%s",
-                     title ? _("Failed to set new domain title") :
-                             _("Failed to set new domain description"));
+            if (title)
+                vshError(ctl, "%s", _("Failed to set new domain title"));
+            else
+                vshError(ctl, "%s", _("Failed to set new domain description"));
+
             return false;
         }
-        vshPrintExtra(ctl, "%s",
-                      title ? _("Domain title updated successfully") :
-                              _("Domain description updated successfully"));
+
+        if (title)
+            vshPrintExtra(ctl, "%s", _("Domain title updated successfully"));
+        else
+            vshPrintExtra(ctl, "%s", _("Domain description updated successfully"));
+
     } else {
         desc = virshGetDomainDescription(ctl, dom, title, queryflags);
         if (!desc)
             return false;
 
-        if (strlen(desc) > 0)
+        if (strlen(desc) > 0) {
             vshPrint(ctl, "%s", desc);
-        else
-            vshPrintExtra(ctl,
-                          title ? _("No title for domain: %s") :
-                                  _("No description for domain: %s"),
-                          virDomainGetName(dom));
+        } else {
+            if (title)
+                vshPrintExtra(ctl, _("No title for domain: %s"), virDomainGetName(dom));
+            else
+                vshPrintExtra(ctl, _("No description for domain: %s"), virDomainGetName(dom));
+        }
     }
 
     return true;