All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
	wei.liu2@citrix.com, ian.jackson@eu.citrix.com
Subject: [PATCH v3 1/4] xenstore: let write_node() and some callers return errno
Date: Tue, 28 Mar 2017 18:26:12 +0200	[thread overview]
Message-ID: <20170328162615.16857-2-jgross@suse.com> (raw)
In-Reply-To: <20170328162615.16857-1-jgross@suse.com>

Instead of setting errno and returning true or false return the error
value directly.

In order to ensure all call sites have been changed according to the
modification rename the functions to xs_*.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/xenstore/xenstored_core.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 739e8b2..4bcaac0 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -433,7 +433,7 @@ static struct node *read_node(struct connection *conn, const void *ctx,
 	return node;
 }
 
-static bool write_node(struct connection *conn, struct node *node)
+static int xs_write_node(struct connection *conn, struct node *node)
 {
 	/*
 	 * conn will be null when this is called from manual_node.
@@ -475,10 +475,10 @@ static bool write_node(struct connection *conn, struct node *node)
 		corrupt(conn, "Write of %s failed", key.dptr);
 		goto error;
 	}
-	return true;
+	return 0;
  error:
 	errno = ENOSPC;
-	return false;
+	return errno;
 }
 
 static enum xs_perm_type perm_for_conn(struct connection *conn,
@@ -1022,7 +1022,7 @@ static struct node *create_node(struct connection *conn, const void *ctx,
 	/* We write out the nodes down, setting destructor in case
 	 * something goes wrong. */
 	for (i = node; i; i = i->parent) {
-		if (!write_node(conn, i)) {
+		if (xs_write_node(conn, i)) {
 			domain_entry_dec(conn, i);
 			return NULL;
 		}
@@ -1062,7 +1062,7 @@ static int do_write(struct connection *conn, struct buffered_data *in)
 	} else {
 		node->data = in->buffer + offset;
 		node->datalen = datalen;
-		if (!write_node(conn, node))
+		if (xs_write_node(conn, node))
 			return errno;
 	}
 
@@ -1133,28 +1133,28 @@ static void memdel(void *mem, unsigned off, unsigned len, unsigned total)
 }
 
 
-static bool remove_child_entry(struct connection *conn, struct node *node,
-			       size_t offset)
+static int xs_remove_child_entry(struct connection *conn, struct node *node,
+			      size_t offset)
 {
 	size_t childlen = strlen(node->children + offset);
 	memdel(node->children, offset, childlen + 1, node->childlen);
 	node->childlen -= childlen + 1;
-	return write_node(conn, node);
+	return xs_write_node(conn, node);
 }
 
 
-static bool delete_child(struct connection *conn,
-			 struct node *node, const char *childname)
+static int xs_delete_child(struct connection *conn,
+			struct node *node, const char *childname)
 {
 	unsigned int i;
 
 	for (i = 0; i < node->childlen; i += strlen(node->children+i) + 1) {
 		if (streq(node->children+i, childname)) {
-			return remove_child_entry(conn, node, i);
+			return xs_remove_child_entry(conn, node, i);
 		}
 	}
 	corrupt(conn, "Can't find child '%s' in %s", childname, node->name);
-	return false;
+	return ENOENT;
 }
 
 
@@ -1174,7 +1174,7 @@ static int _rm(struct connection *conn, const void *ctx, struct node *node,
 	if (!parent)
 		return (errno == ENOMEM) ? ENOMEM : EINVAL;
 
-	if (!delete_child(conn, parent, basename(name)))
+	if (xs_delete_child(conn, parent, basename(name)))
 		return EINVAL;
 
 	delete_node(conn, node, true);
@@ -1278,7 +1278,7 @@ static int do_set_perms(struct connection *conn, struct buffered_data *in)
 	node->num_perms = num;
 	domain_entry_inc(conn, node);
 
-	if (!write_node(conn, node))
+	if (xs_write_node(conn, node))
 		return errno;
 
 	fire_watches(conn, in, name, false);
@@ -1538,7 +1538,7 @@ static void manual_node(const char *name, const char *child)
 	if (child)
 		node->childlen = strlen(child) + 1;
 
-	if (!write_node(NULL, node))
+	if (xs_write_node(NULL, node))
 		barf_perror("Could not create initial node %s", name);
 	talloc_free(node);
 }
@@ -1677,7 +1677,7 @@ static int check_store_(const char *name, struct hashtable *reachable)
 					    childname);
 
 					if (recovery) {
-						remove_child_entry(NULL, node,
+						xs_remove_child_entry(NULL, node,
 								   i);
 						i -= childlen + 1;
 					}
@@ -1699,7 +1699,7 @@ static int check_store_(const char *name, struct hashtable *reachable)
 				    childname);
 
 				if (recovery) {
-					remove_child_entry(NULL, node, i);
+					xs_remove_child_entry(NULL, node, i);
 					i -= childlen + 1;
 				}
 			} else {
-- 
2.10.2


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-03-28 16:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 16:26 [PATCH v3 0/4] xenstore: rework of transaction handling Juergen Gross
2017-03-28 16:26 ` Juergen Gross [this message]
2017-03-28 16:26 ` [PATCH v3 2/4] xenstore: undo function rename Juergen Gross
2017-03-28 16:26 ` [PATCH v3 3/4] xenstore: rework of transaction handling Juergen Gross
2017-03-30 11:17   ` Wei Liu
2017-03-30 12:36     ` Juergen Gross
2017-03-30 13:00       ` Wei Liu
2017-03-28 16:26 ` [PATCH v3 4/4] xenstore: cleanup tdb.c Juergen Gross
2017-03-29 14:10 ` [PATCH v3 0/4] xenstore: rework of transaction handling Juergen Gross
2017-03-30 10:50   ` Julien Grall
2017-04-03 13:53 ` Ian Jackson

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=20170328162615.16857-2-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.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.