[PATCH 4/4] conf: Make virDomainTPMDefFormat() return void

Michal Privoznik posted 4 patches 4 years, 1 month ago
There is a newer version of this series
[PATCH 4/4] conf: Make virDomainTPMDefFormat() return void
Posted by Michal Privoznik 4 years, 1 month ago
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.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b8fef8586c..509f74c092 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25476,9 +25476,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;
@@ -25529,8 +25529,6 @@ virDomainTPMDefFormat(virBuffer *buf,
     virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
 
     virXMLFormatElement(buf, "tpm", &attrBuf, &childBuf);
-
-    return 0;
 }
 
 
@@ -28517,8 +28515,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++) {
@@ -29748,7 +29745,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);
-- 
2.34.1

Re: [PATCH 4/4] conf: Make virDomainTPMDefFormat() return void
Posted by Peter Krempa 4 years, 1 month ago
On Tue, Jan 04, 2022 at 09:14:30 +0100, Michal Privoznik wrote:
> 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.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_conf.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b8fef8586c..509f74c092 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -25476,9 +25476,9 @@ virDomainSoundCodecDefFormat(virBuffer *buf,
>      return 0;
>  }
>  
> -static int
> +static void
>  virDomainTPMDefFormat(virBuffer *buf,
> -                      virDomainTPMDef *def,
> +                      const virDomainTPMDef *def,

This isn't accounted for in the commit message.

>                        unsigned int flags)
>  {
>      g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
> @@ -25529,8 +25529,6 @@ virDomainTPMDefFormat(virBuffer *buf,
>      virDomainDeviceInfoFormat(&childBuf, &def->info, flags);
>  
>      virXMLFormatElement(buf, "tpm", &attrBuf, &childBuf);
> -
> -    return 0;
>  }

Reviewed-by: Peter Krempa <pkrempa@redhat.com>