[PATCH] conf: rework code around 'append' attribute to make coverity happy

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

 



Signed-off-by: Dmitry Mishin <dim@xxxxxxxxxxxxx>
---
 src/conf/domain_conf.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f210c0b..8895e10 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1723,10 +1723,11 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
 
     switch (src->type) {
     case VIR_DOMAIN_CHR_TYPE_FILE:
-        dest->data.file.append = src->data.file.append;
     case VIR_DOMAIN_CHR_TYPE_PTY:
     case VIR_DOMAIN_CHR_TYPE_DEV:
     case VIR_DOMAIN_CHR_TYPE_PIPE:
+        if (src->type == VIR_DOMAIN_CHR_TYPE_FILE)
+            dest->data.file.append = src->data.file.append;
         if (VIR_STRDUP(dest->data.file.path, src->data.file.path) < 0)
             return -1;
         break;
@@ -9386,12 +9387,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
 
                 switch ((virDomainChrType) def->type) {
                 case VIR_DOMAIN_CHR_TYPE_FILE:
-                    if (!append)
-                        append = virXMLPropString(cur, "append");
                 case VIR_DOMAIN_CHR_TYPE_PTY:
                 case VIR_DOMAIN_CHR_TYPE_DEV:
                 case VIR_DOMAIN_CHR_TYPE_PIPE:
                 case VIR_DOMAIN_CHR_TYPE_UNIX:
+                    if (!append && def->type == VIR_DOMAIN_CHR_TYPE_FILE)
+                        append = virXMLPropString(cur, "append");
                     /* PTY path is only parsed from live xml.  */
                     if (!path  &&
                         (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
@@ -9476,15 +9477,15 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_FILE:
+    case VIR_DOMAIN_CHR_TYPE_PTY:
+    case VIR_DOMAIN_CHR_TYPE_DEV:
+    case VIR_DOMAIN_CHR_TYPE_PIPE:
         if (append &&
             (def->data.file.append = virTristateSwitchTypeFromString(append)) <= 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Invalid append attribute value '%s'"), append);
             goto error;
         }
-    case VIR_DOMAIN_CHR_TYPE_PTY:
-    case VIR_DOMAIN_CHR_TYPE_DEV:
-    case VIR_DOMAIN_CHR_TYPE_PIPE:
         if (!path &&
             def->type != VIR_DOMAIN_CHR_TYPE_PTY) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
1.8.3.1

--
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]