]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: remove trailing whitespace even when editing the description
authorJán Tomko <jtomko@redhat.com>
Wed, 28 Feb 2024 12:33:12 +0000 (13:33 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 11 Mar 2024 15:06:46 +0000 (16:06 +0100)
When editing the title of a domain or network via the `desc` or
`net-desc` commands, we strip the final newline that is added by some
editors.

Do the same when editing the description as well.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain.c
tools/virsh-network.c

index d3e28f38f413d867812fa6dc348a8e0634897024..2e9510983cd25fe099f4805ec887d55b09d1283f 100644 (file)
@@ -8525,10 +8525,9 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
                 return false;
 
             /* strip a possible newline at the end of file; some
-             * editors enforce a newline, this makes editing the title
+             * editors enforce a newline, this makes editing
              * more convenient */
-            if (title &&
-                (tmpstr = strrchr(desc_edited, '\n')) &&
+            if ((tmpstr = strrchr(desc_edited, '\n')) &&
                 *(tmpstr+1) == '\0')
                 *tmpstr = '\0';
 
index 68c75438635c15976a465cfbce553a57157f5a0b..c676fc603c9664900a4eafaa6392a8c9a610c6e0 100644 (file)
@@ -481,8 +481,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
             /* strip a possible newline at the end of file; some
              * editors enforce a newline, this makes editing the title
              * more convenient */
-            if (title &&
-                (tmpstr = strrchr(desc_edited, '\n')) &&
+            if ((tmpstr = strrchr(desc_edited, '\n')) &&
                 *(tmpstr+1) == '\0')
                 *tmpstr = '\0';