[libvirt] [PATCH v2 06/21] conf: Improve error handling in virDomainChrDefFormat()

Pavel Hrdina phrdina at redhat.com
Thu Nov 23 14:17:18 UTC 2017


On Tue, Nov 21, 2017 at 05:42:16PM +0100, Andrea Bolognani wrote:
> We don't need to store the return value since we never modify it; we
> should also report failure when virDomainChrSourceDefFormat() fails.
> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  src/conf/domain_conf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 224b88d9a..cb4ed6ef6 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -24025,8 +24025,6 @@ virDomainChrDefFormat(virBufferPtr buf,
>      const char *elementName = virDomainChrDeviceTypeToString(def->deviceType);
>      bool tty_compat;
>  
> -    int ret = 0;
> -
>      if (!elementName) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("unexpected char device type %d"),
> @@ -24044,7 +24042,9 @@ virDomainChrDefFormat(virBufferPtr buf,
>      if (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0)
>          return -1;
>      virBufferAddLit(buf, ">\n");
> -    virDomainChrSourceDefFormat(buf, def->source, flags);
> +
> +    if (virDomainChrSourceDefFormat(buf, def->source, flags) < 0)
> +       return -1;

This change could be separated and all other calls of that function
should be checked for error since none of them are checked.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171123/af6db191/attachment-0001.sig>


More information about the libvir-list mailing list