Since there is a check on buf through virBufferError(),
it is not necessary to check desc again.
---
tools/virsh-domain.c | 62 +++++++++++++++++++++----------------------------
1 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e47877b..a8a0105 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6724,45 +6724,37 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
desc = virBufferContentAndReset(&buf);
- if (edit || desc) {
- if (!desc) {
- desc = vshGetDomainDescription(ctl, dom, title,
- config?VIR_DOMAIN_XML_INACTIVE:0);
- if (!desc)
- goto cleanup;
- }
-
- if (edit) {
- /* Create and open the temporary file. */
- if (!(tmp = vshEditWriteToTempFile(ctl, desc)))
- goto cleanup;
+ if (edit) {
+ /* Create and open the temporary file. */
+ if (!(tmp = vshEditWriteToTempFile(ctl, desc)))
+ goto cleanup;
- /* Start the editor. */
- if (vshEditFile(ctl, tmp) == -1)
- goto cleanup;
+ /* Start the editor. */
+ if (vshEditFile(ctl, tmp) == -1)
+ goto cleanup;
- /* Read back the edited file. */
- if (!(desc_edited = vshEditReadBackFile(ctl, tmp)))
- goto cleanup;
+ /* Read back the edited file. */
+ if (!(desc_edited = vshEditReadBackFile(ctl, tmp)))
+ goto cleanup;
- /* 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')) &&
- *(tmpstr+1) == '\0')
- *tmpstr = '\0';
-
- /* Compare original XML with edited. Has it changed at all? */
- if (STREQ(desc, desc_edited)) {
- vshPrint(ctl, _("Domain description not changed.\n"));
- ret = true;
- goto cleanup;
- }
+ /* 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')) &&
+ *(tmpstr+1) == '\0')
+ *tmpstr = '\0';
+
+ /* Compare original XML with edited. Has it changed at all? */
+ if (STREQ(desc, desc_edited)) {
+ vshPrint(ctl, _("Domain description not changed.\n"));
+ ret = true;
+ goto cleanup;
+ }
- VIR_FREE(desc);
- desc = desc_edited;
- desc_edited = NULL;
+ VIR_FREE(desc);
+ desc = desc_edited;
+ desc_edited = NULL;
}
if (virDomainSetMetadata(dom, type, desc, NULL, NULL, flags) < 0) {
--
1.7.1
Show replies by date
On 09/17/2013 11:16 AM, Hongwei Bi wrote:
Since there is a check on buf through virBufferError(),
it is not necessary to check desc again.
The buffer is used for the description provided on the virsh command line:
$ virsh desc <domain> Description
If you don't provide the description:
$ virsh desc --edit <domain>
then 'desc' is NULL and we need to fetch the existing domain description and
let the user edit it. Your patch removes this functionality.
Jan
I understand. Thanks for your reminding.
2013/9/17 Ján Tomko <jtomko(a)redhat.com>
On 09/17/2013 11:16 AM, Hongwei Bi wrote:
> Since there is a check on buf through virBufferError(),
> it is not necessary to check desc again.
The buffer is used for the description provided on the virsh command line:
$ virsh desc <domain> Description
If you don't provide the description:
$ virsh desc --edit <domain>
then 'desc' is NULL and we need to fetch the existing domain description
and
let the user edit it. Your patch removes this functionality.
Jan