From: Ján Tomko Date: Wed, 28 Feb 2024 12:33:12 +0000 (+0100) Subject: virsh: remove trailing whitespace even when editing the description X-Git-Tag: v10.2.0-rc1~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b31aeaae387d473effbf6e507b5c1e76aec1b0c;p=thirdparty%2Flibvirt.git virsh: remove trailing whitespace even when editing the description 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 Reviewed-by: Michal Privoznik --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d3e28f38f4..2e9510983c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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'; diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 68c7543863..c676fc603c 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -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';