All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH for 4.5] xl: Return proper error codes for block-attach and block-detach
Date: Thu, 13 Nov 2014 08:16:54 +0000	[thread overview]
Message-ID: <1415866614.31613.24.camel@citrix.com> (raw)
In-Reply-To: <1415813493-25330-1-git-send-email-george.dunlap@eu.citrix.com>

On Wed, 2014-11-12 at 17:31 +0000, George Dunlap wrote:
> @@ -6444,6 +6445,7 @@ int main_blockdetach(int argc, char **argv)
>      rc = libxl_device_disk_remove(ctx, domid, &disk, 0);
>      if (rc) {
>          fprintf(stderr, "libxl_device_disk_remove failed.\n");
> +        return 1;
>      }
>      libxl_device_disk_dispose(&disk);
>      return rc;

This one seems odd to me, you have inadvertently arranged to skip the
disk dispose and the old code returned non-zero in the failure case
already, since it returns rc.

If it is important to return 0 or 1 then perhaps the last line should
just be:
        return rc ? 1 : 0;
        
Or maybe the ultimate caller (i.e. the xl command dispatcher) ought to
be translating libxl ERROR_FOO into suitable process exit codes (perhaps
as simplistically as suggested above).

Skipping the dispose is a memory leak, albeit in a process which is just
about to die, but we like to try and keep xl "valgrind clean" so far as
possible such that leaks in the underlying libxl stand out.

Ian.

  parent reply	other threads:[~2014-11-13  8:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 17:31 [PATCH for 4.5] xl: Return proper error codes for block-attach and block-detach George Dunlap
2014-11-12 17:35 ` Wei Liu
2014-11-13  8:16 ` Ian Campbell [this message]
2014-11-20 16:06 ` George Dunlap
2014-11-25 14:55   ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415866614.31613.24.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.