[libvirt PATCH v6 1/8] conf: explicitly set VIR_DOMAIN_VIDEO_TYPE_DEFAULT to 0

Jonathon Jongsma jjongsma at redhat.com
Wed Jan 25 20:16:00 UTC 2023


Ensure that new virDomainVideoDef objects have their 'type' set to
VIR_DOMAIN_VIDEO_TYPE_DEFAULT and remove places that this value is set
after construction. Since virDomainVideoDefNew() uses g_new0() allocate
the instance, all fields are initialized to 0.

Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 src/conf/domain_conf.c | 3 ---
 src/conf/domain_conf.h | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 89672deb38..42d2f2ed52 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12871,8 +12871,6 @@ virDomainVideoDefParseXML(virDomainXMLOption *xmlopt,
                            _("unknown video model '%s'"), type);
             return NULL;
         }
-    } else {
-        def->type = VIR_DOMAIN_VIDEO_TYPE_DEFAULT;
     }
 
     if ((ram = virXPathString("string(./model/@ram)", ctxt))) {
@@ -21708,7 +21706,6 @@ virDomainDefAddImplicitVideo(virDomainDef *def, virDomainXMLOption *xmlopt)
 
     if (!(video = virDomainVideoDefNew(xmlopt)))
         return -1;
-    video->type = VIR_DOMAIN_VIDEO_TYPE_DEFAULT;
     VIR_APPEND_ELEMENT(def->videos, def->nvideos, video);
 
     return 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d99bbbc3ff..e35923e3d7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1781,7 +1781,7 @@ typedef enum {
 
 
 typedef enum {
-    VIR_DOMAIN_VIDEO_TYPE_DEFAULT,
+    VIR_DOMAIN_VIDEO_TYPE_DEFAULT = 0,
     VIR_DOMAIN_VIDEO_TYPE_VGA,
     VIR_DOMAIN_VIDEO_TYPE_CIRRUS,
     VIR_DOMAIN_VIDEO_TYPE_VMVGA,
-- 
2.39.0



More information about the libvir-list mailing list