[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] domain_conf.c: avoid a leak and the need for "cleanup:" block



On Wed, Jan 20, 2010 at 09:46:14PM +0100, Jim Meyering wrote:
> Daniel Veillard wrote:
> 
> > On Wed, Jan 20, 2010 at 07:30:47PM +0100, Jim Meyering wrote:
> >> This avoids a leak and the need for a "cleanup:" block,
> >> along with its three goto statements.
> >>
> >> While often I prefer to write functions with a single return point,
> >> this one no longer has the need, now that "addr" is freed immediately
> >> after allocation.
> >>
> >> Adding the semicolon in the "case..." stmt may look odd.
> >> It's there because the first stmt is the declaration of "port".
> >> If you'd prefer, an alternative is to put the contents of that
> >> case inside a {...} block.
> >
> >   yeah, I really think a {} block is nicer in that case,
> >
> > ACK,
> 
> Ok.  I've added braces and indented.
> Here's the output of git diff -B -w showing
> what I'm amending into that commit:
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 7815805..27f6f84 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -4929,7 +4929,7 @@ virDomainChrDefFormat(virConnectPtr conn,
> 
>      switch (def->targetType) {
>      case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
> -        ; /* dummy stmt, for following declaration */
> +        {
>          int port = virSocketGetPort(def->target.addr);
>          if (port < 0) {
>              virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
> @@ -4947,6 +4947,7 @@ virDomainChrDefFormat(virConnectPtr conn,
>                            addr, port);
>          VIR_FREE(addr);
>          break;
> +        }
> 
>      case VIR_DOMAIN_CHR_TARGET_TYPE_PARALLEL:
>      case VIR_DOMAIN_CHR_TARGET_TYPE_SERIAL:

  Yes, thanks !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]