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

[PATCH v2 13/18] tools/xenstore: let db_delete() return void



db_delete() only ever is returning 0. Switch it to return void and
remove all the error handling dealing wit a non-zero return value.

Suggested-by: Julien Grall <julien@xxxxxxx>
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
V2:
- new patch
---
 tools/xenstore/xenstored_core.c        | 11 ++++-------
 tools/xenstore/xenstored_core.h        |  4 ++--
 tools/xenstore/xenstored_transaction.c | 14 +++++---------
 3 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index ff10659e65..11da470b20 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -679,8 +679,8 @@ int db_write(struct connection *conn, const char *db_name, 
void *data,
        return 0;
 }
 
-int db_delete(struct connection *conn, const char *name,
-             struct node_account_data *acc)
+void db_delete(struct connection *conn, const char *name,
+              struct node_account_data *acc)
 {
        struct node_account_data tmp_acc;
        unsigned int domid;
@@ -700,8 +700,6 @@ int db_delete(struct connection *conn, const char *name,
                domain_memory_add_nochk(conn, domid,
                                        -acc->memory - strlen(name));
        }
-
-       return 0;
 }
 
 /*
@@ -1668,9 +1666,8 @@ static int delnode_sub(const void *ctx, struct connection 
*conn,
        if (domain_nbentry_dec(conn, get_node_owner(node)))
                return WALK_TREE_ERROR_STOP;
 
-       /* In case of error stop the walk. */
-       if (!ret && db_delete(conn, db_name, &node->acc))
-               return WALK_TREE_ERROR_STOP;
+       if (!ret)
+               db_delete(conn, db_name, &node->acc);
 
        /*
         * Fire the watches now, when we can still see the node permissions.
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index 5d96799c60..3c0dd40dfb 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -365,8 +365,8 @@ struct xs_tdb_record_hdr *db_fetch(const char *db_name, 
size_t *size);
 int db_write(struct connection *conn, const char *db_name, void *data,
             size_t size, struct node_account_data *acc,
             enum write_node_mode mode, bool no_quota_check);
-int db_delete(struct connection *conn, const char *name,
-             struct node_account_data *acc);
+void db_delete(struct connection *conn, const char *name,
+              struct node_account_data *acc);
 
 void conn_free_buffered_data(struct connection *conn);
 
diff --git a/tools/xenstore/xenstored_transaction.c 
b/tools/xenstore/xenstored_transaction.c
index 420645e55d..5d7da82aad 100644
--- a/tools/xenstore/xenstored_transaction.c
+++ b/tools/xenstore/xenstored_transaction.c
@@ -378,10 +378,8 @@ static int finalize_transaction(struct connection *conn,
 
                /* Entries for unmodified nodes can be removed early. */
                if (!i->modified) {
-                       if (i->ta_node) {
-                               if (db_delete(conn, i->trans_name, NULL))
-                                       return EIO;
-                       }
+                       if (i->ta_node)
+                               db_delete(conn, i->trans_name, NULL);
                        list_del(&i->list);
                        talloc_free(i);
                }
@@ -396,8 +394,7 @@ static int finalize_transaction(struct connection *conn,
                                       ? NODE_CREATE : NODE_MODIFY;
                                *is_corrupt |= db_write(conn, i->node, hdr,
                                                        size, NULL, flag, true);
-                               if (db_delete(conn, i->trans_name, NULL))
-                                       *is_corrupt = true;
+                               db_delete(conn, i->trans_name, NULL);
                        } else {
                                *is_corrupt = true;
                        }
@@ -407,9 +404,8 @@ static int finalize_transaction(struct connection *conn,
                         * in this transaction will have no generation
                         * information stored.
                         */
-                       *is_corrupt |= (i->generation == NO_GENERATION)
-                                      ? false
-                                      : db_delete(conn, i->node, NULL);
+                       if (i->generation != NO_GENERATION)
+                               db_delete(conn, i->node, NULL);
                }
                if (i->fire_watch)
                        fire_watches(conn, trans, i->node, NULL, i->watch_exact,
-- 
2.35.3




 


Rackspace

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