]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Make virDomainTPMDefFormat() return void
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 4 Jan 2022 07:57:47 +0000 (08:57 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 4 Jan 2022 09:23:17 +0000 (10:23 +0100)
The virDomainTPMDefFormat() function can't fail really. There's
no point in it returning an integer then. Make it return void and
fix both places which check for its retval.

And while at it, turn @def into a const pointer to make it
obvious the function does not modify passed struct.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/domain_conf.c

index 9e854d031eabdb7e589a3b8424ec96891d40760c..fe53a280d7fd91c5276cdbeb36d84ce371e2ac1a 100644 (file)
@@ -25490,9 +25490,9 @@ virDomainSoundCodecDefFormat(virBuffer *buf,
     return 0;
 }
 
-static int
+static void
 virDomainTPMDefFormat(virBuffer *buf,
-                      virDomainTPMDef *def,
+                      const virDomainTPMDef *def,
                       unsigned int flags)
 {
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
@@ -25543,8 +25543,6 @@ virDomainTPMDefFormat(virBuffer *buf,
     virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
 
     virXMLFormatElement(buf, "tpm", &attrBuf, &childBuf);
-
-    return 0;
 }
 
 
@@ -28531,8 +28529,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
     }
 
     for (n = 0; n < def->ntpms; n++) {
-        if (virDomainTPMDefFormat(buf, def->tpms[n], flags) < 0)
-            return -1;
+        virDomainTPMDefFormat(buf, def->tpms[n], flags);
     }
 
     for (n = 0; n < def->ngraphics; n++) {
@@ -29762,7 +29759,8 @@ virDomainDeviceDefCopy(virDomainDeviceDef *src,
         rc = virDomainChrDefFormat(&buf, src->data.chr, flags);
         break;
     case VIR_DOMAIN_DEVICE_TPM:
-        rc = virDomainTPMDefFormat(&buf, src->data.tpm, flags);
+        virDomainTPMDefFormat(&buf, src->data.tpm, flags);
+        rc = 0;
         break;
     case VIR_DOMAIN_DEVICE_PANIC:
         virDomainPanicDefFormat(&buf, src->data.panic);