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

[Xen-changelog] [xen master] xenstore: let write_node() and some callers return errno



commit 6f237ac0aedadd699a9bd7d6b9f0b844767c3494
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Mar 28 18:26:12 2017 +0200
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon Apr 3 14:04:10 2017 +0100

    xenstore: let write_node() and some callers return errno
    
    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@xxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 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 {
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.