All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, ian.campbell@citrix.com,
	wei.liu2@citrix.com, Ian.Jackson@eu.citrix.com
Cc: Yang Hongyang <hongyang.yang@easystack.cn>,
	Wen Congyang <wency@cn.fujitsu.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 3/4] libxl/remus: Change the assert for info to an return
Date: Tue, 26 Jan 2016 16:30:59 -0500	[thread overview]
Message-ID: <1453843860-29591-4-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1453843860-29591-1-git-send-email-konrad.wilk@oracle.com>

The assert(info) is after quite a lot of manipulations
on 'info' - which makes the assert pointless because if
info was NULL it would have crashed earlier.

Remove it and make it an return. Also since most of the
error paths are for the same rc, unify them.

CC: Wen Congyang <wency@cn.fujitsu.com>
CC: Yang Hongyang <hongyang.yang@easystack.cn>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 tools/libxl/libxl.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 548e2e2..228b241 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -847,13 +847,14 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 {
     AO_CREATE(ctx, domid, ao_how);
     libxl__domain_suspend_state *dss;
-    int rc;
+    int rc = ERROR_FAIL;
 
     libxl_domain_type type = libxl__domain_type(gc, domid);
-    if (type == LIBXL_DOMAIN_TYPE_INVALID) {
-        rc = ERROR_FAIL;
+    if (type == LIBXL_DOMAIN_TYPE_INVALID)
+        goto out;
+
+    if (!info)
         goto out;
-    }
 
     libxl_defbool_setdefault(&info->allow_unsafe, false);
     libxl_defbool_setdefault(&info->blackhole, false);
@@ -867,7 +868,6 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
          !libxl_defbool_val(info->diskbuf))) {
         LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null,"
                    "disable network buffering and disk replication");
-        rc = ERROR_FAIL;
         goto out;
     }
 
@@ -883,8 +883,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     dss->debug = 0;
     dss->remus = info;
 
-    assert(info);
-
+    rc = 0;
     /* Point of no return */
     libxl__remus_setup(egc, dss);
     return AO_INPROGRESS;
-- 
2.1.0

  parent reply	other threads:[~2016-01-26 21:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26 21:30 [PATCH] various updates/fixes. (v2) Konrad Rzeszutek Wilk
2016-01-26 21:30 ` [PATCH 1/4] libxl: Use libxl_strdup instead of strdup on libxl_version_info Konrad Rzeszutek Wilk
2016-02-01 12:13   ` Wei Liu
2016-02-03 11:46     ` Ian Campbell
2016-01-26 21:30 ` [PATCH 2/4] libxc/xc_domain_resume: Update comment Konrad Rzeszutek Wilk
2016-02-01 12:14   ` Wei Liu
2016-02-03 11:47     ` Ian Campbell
2016-01-26 21:30 ` Konrad Rzeszutek Wilk [this message]
2016-02-01 12:13   ` [PATCH 3/4] libxl/remus: Change the assert for info to an return Wei Liu
2016-01-25 21:06     ` [PATCH] toolstack documentation/asserts cleanups. (v1) Konrad Rzeszutek Wilk
2016-01-25 21:06       ` [PATCH 1/3] libxc/xc_domain_resume: Update comment Konrad Rzeszutek Wilk
2016-01-26 16:19         ` Ian Campbell
2016-01-26 16:22           ` Ian Jackson
2016-01-26 16:36             ` Ian Campbell
2016-01-26 16:52               ` Ian Jackson
2016-01-26 19:37                 ` Konrad Rzeszutek Wilk
2016-01-26 19:47           ` Konrad Rzeszutek Wilk
2016-01-27  9:52             ` Ian Campbell
2016-01-25 21:06       ` [PATCH 2/3] libxl/remus: Move the assert before the info is used Konrad Rzeszutek Wilk
2016-01-26 16:21         ` Ian Campbell
2016-01-26 16:23           ` Ian Jackson
2016-02-01 14:14             ` [PATCH 2/3] libxl/remus: Move the assert before the info is used. [and 1 more messages] Ian Jackson
2016-01-25 21:06       ` [PATCH 3/3] tools/libxl: run_helper - add #define for arguments Konrad Rzeszutek Wilk
2016-01-26 16:23         ` Ian Campbell
2016-01-26 16:25           ` Ian Jackson
2016-02-03 11:48             ` Ian Campbell
2016-01-26 21:31 ` [PATCH 4/4] " Konrad Rzeszutek Wilk
2016-02-03 11:47   ` 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=1453843860-29591-4-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=hongyang.yang@easystack.cn \
    --cc=ian.campbell@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xen-devel@lists.xenproject.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.