]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Use virTristateXXX in virDomainChrSourceDef
authorTim Wiederhake <twiederh@redhat.com>
Wed, 7 Apr 2021 11:48:34 +0000 (13:48 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 16 Apr 2021 07:48:42 +0000 (09:48 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index ad3db9b94d530857a406605bf2cf1d6c7e8df57c..c8dee851ba0081b04f072929d32bf086faf7e3bd 100644 (file)
@@ -11913,12 +11913,14 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef *def,
     def->data.tcp.service = virXMLPropString(source, "service");
 
     if ((tmp = virXMLPropString(source, "tls"))) {
-        if ((def->data.tcp.haveTLS = virTristateBoolTypeFromString(tmp)) <= 0) {
+        int value;
+        if ((value = virTristateBoolTypeFromString(tmp)) <= 0) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("unknown chardev 'tls' setting '%s'"),
                            tmp);
             return -1;
         }
+        def->data.tcp.haveTLS = value;
         VIR_FREE(tmp);
     }
 
@@ -11997,12 +11999,15 @@ virDomainChrSourceDefParseFile(virDomainChrSourceDef *def,
 
     def->data.file.path = virXMLPropString(source, "path");
 
-    if ((append = virXMLPropString(source, "append")) &&
-        (def->data.file.append = virTristateSwitchTypeFromString(append)) <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid append attribute value '%s'"),
-                       append);
-        return -1;
+    if ((append = virXMLPropString(source, "append"))) {
+        int value;
+        if ((value = virTristateSwitchTypeFromString(append)) <= 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Invalid append attribute value '%s'"),
+                           append);
+            return -1;
+        }
+        def->data.file.append = value;
     }
 
     return 0;
@@ -12038,12 +12043,15 @@ virDomainChrSourceDefParseLog(virDomainChrSourceDef *def,
 
     def->logfile = virXMLPropString(log, "file");
 
-    if ((append = virXMLPropString(log, "append")) &&
-        (def->logappend = virTristateSwitchTypeFromString(append)) <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid append attribute value '%s'"),
-                       append);
-        return -1;
+    if ((append = virXMLPropString(log, "append"))) {
+        int value;
+        if ((value = virTristateSwitchTypeFromString(append)) <= 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Invalid append attribute value '%s'"),
+                           append);
+            return -1;
+        }
+        def->logappend = value;
     }
 
     return 0;
index 6b8e2fe37539afd85c4f22f11d17294afbd3d5f5..1967f8af71102cb365a8bc8f8ebe244e8538bb1a 100644 (file)
@@ -1233,7 +1233,7 @@ struct _virDomainChrSourceDef {
         /* no <source> for null, vc, stdio */
         struct {
             char *path;
-            int append; /* enum virTristateSwitch */
+            virTristateSwitch append;
         } file; /* pty, file, pipe, or device */
         struct {
             char *master;
@@ -1245,7 +1245,7 @@ struct _virDomainChrSourceDef {
             bool listen;
             int protocol;
             bool tlscreds;
-            int haveTLS; /* enum virTristateBool */
+            virTristateBool haveTLS;
             bool tlsFromConfig;
             virDomainChrSourceReconnectDef reconnect;
         } tcp;
@@ -1266,7 +1266,7 @@ struct _virDomainChrSourceDef {
         } spiceport;
     } data;
     char *logfile;
-    int logappend;
+    virTristateSwitch logappend;
 
     size_t nseclabels;
     virSecurityDeviceLabelDef **seclabels;