[libvirt] [PATCHv2 6/9] conf: make error returns from virDomainActualNetDefFormat consistent

Kyle Mestery (kmestery) kmestery at cisco.com
Tue Aug 14 13:28:53 UTC 2012


Nice cleanup here, this looks good to me.

Acked-by: Kyle Mestery <kmestery at cisco.com>

On Aug 14, 2012, at 2:04 AM, Laine Stump wrote:

> There was an error: label that simply did "return ret", but ret was
> defaulted to -1, and was never used other than setting it manually to
> 0 just before a non-error return. Aside from this, some of the error
> return paths used "goto error" and others used "return ret".
> 
> This patch removes ret and the error: label, and makes all error
> returns just consistently do "return -1".
> ---
> src/conf/domain_conf.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index e239909..5990634 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -11547,7 +11547,6 @@ virDomainActualNetDefFormat(virBufferPtr buf,
>                             virDomainActualNetDefPtr def,
>                             unsigned int flags)
> {
> -    int ret = -1;
>     const char *type;
>     const char *mode;
> 
> @@ -11558,7 +11557,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
>     if (!type) {
>         virReportError(VIR_ERR_INTERNAL_ERROR,
>                        _("unexpected net type %d"), def->type);
> -        return ret;
> +        return -1;
>     }
> 
>     virBufferAsprintf(buf, "      <actual type='%s'", type);
> @@ -11585,7 +11584,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
>             virReportError(VIR_ERR_INTERNAL_ERROR,
>                            _("unexpected source mode %d"),
>                            def->data.direct.mode);
> -            return ret;
> +            return -1;
>         }
>         virBufferAsprintf(buf, " mode='%s'/>\n", mode);
>         break;
> @@ -11604,21 +11603,18 @@ virDomainActualNetDefFormat(virBufferPtr buf,
>     default:
>         virReportError(VIR_ERR_INTERNAL_ERROR,
>                        _("unexpected net type %s"), type);
> -        goto error;
> +        return -1;
>     }
> 
>     virBufferAdjustIndent(buf, 8);
>     if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0)
>        return -1;
>     if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0)
> -        goto error;
> +        return -1;
>     virBufferAdjustIndent(buf, -8);
> 
>     virBufferAddLit(buf, "      </actual>\n");
> -
> -    ret = 0;
> -error:
> -    return ret;
> +    return 0;
> }
> 
> static int
> -- 
> 1.7.11.2
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list





More information about the libvir-list mailing list