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

Laine Stump posted 32 patches 5 years, 7 months ago
[PATCH 17/32] conf: consistently check for error when calling virSysinfoFormat()
Posted by Laine Stump 5 years, 7 months ago
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@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

Re: [PATCH 17/32] conf: consistently check for error when calling virSysinfoFormat()
Posted by Ján Tomko 5 years, 7 months ago
On a Sunday in 2020, Laine Stump wrote:
>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@redhat.com>
>---
> src/conf/domain_conf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano