Blame SOURCES/0014-storage-domain-use-explicit-initialization-of-struct.patch

3e596a
From 6356eb05c5a534dde93b882539a14bddf123a6ab Mon Sep 17 00:00:00 2001
3e596a
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3e596a
Date: Wed, 10 May 2017 16:12:01 -0300
3e596a
Subject: [PATCH] storage-domain: use explicit initialization of struct
3e596a
 OvirtXmlElement members
3e596a
3e596a
Also, members have been reordered and the xml_node field has been
3e596a
renamed to more proper xml_path.
3e596a
3e596a
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
3e596a
---
3e596a
 govirt/ovirt-storage-domain.c | 46 ++++++++++++++++++++++++++++++++-----------
3e596a
 1 file changed, 34 insertions(+), 12 deletions(-)
3e596a
3e596a
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
3e596a
index 4087d75..07c0ef0 100644
3e596a
--- a/govirt/ovirt-storage-domain.c
3e596a
+++ b/govirt/ovirt-storage-domain.c
3e596a
@@ -323,9 +323,9 @@ end:
3e596a
 }
3e596a
 
3e596a
 typedef struct {
3e596a
-    const char *xml_node;
3e596a
-    GType type;
3e596a
     const char *prop_name;
3e596a
+    GType type;
3e596a
+    const char *xml_path;
3e596a
 } OvirtXmlElement;
3e596a
 
3e596a
 static gboolean
3e596a
@@ -336,11 +336,12 @@ ovirt_resource_parse_xml(OvirtResource *resource,
3e596a
     g_return_val_if_fail(OVIRT_IS_RESOURCE(resource), FALSE);
3e596a
     g_return_val_if_fail(elements != NULL, FALSE);
3e596a
 
3e596a
-    for (;elements->xml_node != NULL; elements++) {
3e596a
+    for (;elements->xml_path != NULL; elements++) {
3e596a
         const char *value_str;
3e596a
         GValue value = { 0, };
3e596a
 
3e596a
-        value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_node);
3e596a
+        value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
3e596a
+
3e596a
         g_value_init(&value, elements->type);
3e596a
         if (_set_property_value_from_type(&value, elements->type, value_str, node))
3e596a
             g_object_set_property(G_OBJECT(resource), elements->prop_name, &value);
3e596a
@@ -355,14 +356,35 @@ ovirt_storage_domain_refresh_from_xml(OvirtStorageDomain *domain,
3e596a
                                       RestXmlNode *node)
3e596a
 {
3e596a
     OvirtXmlElement storage_domain_elements[] = {
3e596a
-        { "type",           OVIRT_TYPE_STORAGE_DOMAIN_TYPE,           "type" },
3e596a
-        { "master",         G_TYPE_BOOLEAN,                           "master" },
3e596a
-        { "available",      G_TYPE_UINT64,                            "available" },
3e596a
-        { "used",           G_TYPE_UINT64,                            "used" },
3e596a
-        { "committed",      G_TYPE_UINT64,                            "committed" },
3e596a
-        { "storage_format", OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION, "version" },
3e596a
-        { "status/state",   OVIRT_TYPE_STORAGE_DOMAIN_STATE,          "state" },
3e596a
-        { NULL,             G_TYPE_INVALID,                           NULL }
3e596a
+        { .prop_name = "type",
3e596a
+          .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
3e596a
+          .xml_path = "type",
3e596a
+        },
3e596a
+        { .prop_name = "master",
3e596a
+          .type = G_TYPE_BOOLEAN,
3e596a
+          .xml_path = "master",
3e596a
+        },
3e596a
+        { .prop_name = "available",
3e596a
+          .type = G_TYPE_UINT64,
3e596a
+          .xml_path = "available",
3e596a
+        },
3e596a
+        { .prop_name = "used",
3e596a
+          .type = G_TYPE_UINT64,
3e596a
+          .xml_path = "used",
3e596a
+        },
3e596a
+        { .prop_name = "committed",
3e596a
+          .type = G_TYPE_UINT64,
3e596a
+          .xml_path = "committed",
3e596a
+        },
3e596a
+        { .prop_name = "version",
3e596a
+          .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
3e596a
+          .xml_path = "storage_format",
3e596a
+        },
3e596a
+        { .prop_name = "state",
3e596a
+          .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
3e596a
+          .xml_path = "status/state",
3e596a
+        },
3e596a
+        { NULL , }
3e596a
     };
3e596a
 
3e596a
     return ovirt_resource_parse_xml(OVIRT_RESOURCE(domain), node, storage_domain_elements);
3e596a
-- 
3e596a
2.13.6
3e596a