[PATCH 17/32] conf: consistently check for error when calling virSysinfoFormat()

Laine Stump laine at redhat.com
Mon Jul 6 03:41:12 UTC 2020


Every other caller of this function checks for an error return and
ends their formatting early if there is an error. This function
happily continues on its way.

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/conf/domain_conf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c02d1c8bd2..33bf0a1727 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29649,8 +29649,10 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
     if (def->resource)
         virDomainResourceDefFormat(buf, def->resource);
 
-    for (i = 0; i < def->nsysinfo; i++)
-        virSysinfoFormat(buf, def->sysinfo[i]);
+    for (i = 0; i < def->nsysinfo; i++) {
+        if (virSysinfoFormat(buf, def->sysinfo[i]) < 0)
+            goto error;
+    }
 
     if (def->os.bootloader) {
         virBufferEscapeString(buf, "<bootloader>%s</bootloader>\n",
-- 
2.25.4




More information about the libvir-list mailing list