[PATCHv2 11/13] snapshot: simplify indentation of disk encryption xml

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use auto-indent in more places.

* src/conf/storage_encryption_conf.h (virStorageEncryptionFormat):
Drop parameter.
* src/conf/storage_encryption_conf.c (virStorageEncryptionFormat)
(virStorageEncryptionSecretFormat): Simplify with auto-indent.
* src/conf/domain_conf.c (virDomainDiskDefFormat): Adjust caller.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Likewise.
---
 src/conf/domain_conf.c             |    9 ++++++---
 src/conf/storage_conf.c            |    9 ++++++---
 src/conf/storage_encryption_conf.c |   20 ++++++++------------
 src/conf/storage_encryption_conf.h |    5 ++---
 4 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index efdf914..6ab73ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9221,9 +9221,12 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->serial)
         virBufferEscapeString(buf, "      <serial>%s</serial>\n",
                               def->serial);
-    if (def->encryption != NULL &&
-        virStorageEncryptionFormat(buf, def->encryption, 6) < 0)
-        return -1;
+    if (def->encryption) {
+        virBufferAdjustIndent(buf, 6);
+        if (virStorageEncryptionFormat(buf, def->encryption) < 0)
+            return -1;
+        virBufferAdjustIndent(buf, -6);
+    }

     if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
         return -1;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index e893b2d..898db62 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1204,9 +1204,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,

     virBufferAddLit(buf,"    </permissions>\n");

-    if (def->encryption != NULL &&
-        virStorageEncryptionFormat(buf, def->encryption, 4) < 0)
-        return -1;
+    if (def->encryption) {
+        virBufferAdjustIndent(buf, 4);
+        if (virStorageEncryptionFormat(buf, def->encryption) < 0)
+            return -1;
+        virBufferAdjustIndent(buf, -4);
+    }

     virBufferAsprintf(buf, "  </%s>\n", type);

diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index 73e16ed..3208333 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -1,7 +1,7 @@
 /*
  * storage_encryption_conf.c: volume encryption information
  *
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -211,8 +211,7 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)

 static int
 virStorageEncryptionSecretFormat(virBufferPtr buf,
-                                 virStorageEncryptionSecretPtr secret,
-                                 int indent)
+                                 virStorageEncryptionSecretPtr secret)
 {
     const char *type;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -225,15 +224,14 @@ virStorageEncryptionSecretFormat(virBufferPtr buf,
     }

     virUUIDFormat(secret->uuid, uuidstr);
-    virBufferAsprintf(buf, "%*s<secret type='%s' uuid='%s'/>\n",
-                      indent, "", type, uuidstr);
+    virBufferAsprintf(buf, "  <secret type='%s' uuid='%s'/>\n",
+                      type, uuidstr);
     return 0;
 }

 int
 virStorageEncryptionFormat(virBufferPtr buf,
-                           virStorageEncryptionPtr enc,
-                           int indent)
+                           virStorageEncryptionPtr enc)
 {
     const char *format;
     size_t i;
@@ -244,16 +242,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
                               "%s", _("unexpected encryption format"));
         return -1;
     }
-    virBufferAsprintf(buf, "%*s<encryption format='%s'>\n",
-                      indent, "", format);
+    virBufferAsprintf(buf, "<encryption format='%s'>\n", format);

     for (i = 0; i < enc->nsecrets; i++) {
-        if (virStorageEncryptionSecretFormat(buf, enc->secrets[i],
-                                             indent + 2) < 0)
+        if (virStorageEncryptionSecretFormat(buf, enc->secrets[i]) < 0)
             return -1;
     }

-    virBufferAsprintf(buf, "%*s</encryption>\n", indent, "");
+    virBufferAddLit(buf, "</encryption>\n");

     return 0;
 }
diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h
index fa5f3cb..cfb088c 100644
--- a/src/conf/storage_encryption_conf.h
+++ b/src/conf/storage_encryption_conf.h
@@ -1,7 +1,7 @@
 /*
  * storage_encryption_conf.h: volume encryption information
  *
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -66,8 +66,7 @@ void virStorageEncryptionFree(virStorageEncryptionPtr enc);
 virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
                                                       xmlNodePtr root);
 int virStorageEncryptionFormat(virBufferPtr buf,
-                               virStorageEncryptionPtr enc,
-                               int indent);
+                               virStorageEncryptionPtr enc);

 /* A helper for VIR_STORAGE_ENCRYPTION_FORMAT_QCOW */
 enum {
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]