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 Liu <wl@xen.org>,
	Julien Grall <julien@xen.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Julien Grall <jgrall@amazon.com>
Subject: [PATCH v4 06/19] tools/xenstore: let db_delete() return void
Date: Mon, 14 Aug 2023 09:46:54 +0200	[thread overview]
Message-ID: <20230814074707.27696-7-jgross@suse.com> (raw)
In-Reply-To: <20230814074707.27696-1-jgross@suse.com>

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@xen.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
---
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 2b94392fd4..a08962c3ea 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -677,8 +677,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;
@@ -698,8 +698,6 @@ int db_delete(struct connection *conn, const char *name,
 		domain_memory_add_nochk(conn, domid,
 					-acc->memory - strlen(name));
 	}
-
-	return 0;
 }
 
 /*
@@ -1670,9 +1668,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 ce40c61f44..e1aeb4aecd 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -366,8 +366,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 378fe79763..fbcea3663e 100644
--- a/tools/xenstore/xenstored_transaction.c
+++ b/tools/xenstore/xenstored_transaction.c
@@ -377,10 +377,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);
 		}
@@ -397,8 +395,7 @@ static int finalize_transaction(struct connection *conn,
 				       ? NODE_CREATE : NODE_MODIFY;
 				*is_corrupt |= db_write(conn, i->node, hdr,
 							size, NULL, mode, true);
-				if (db_delete(conn, i->trans_name, NULL))
-					*is_corrupt = true;
+				db_delete(conn, i->trans_name, NULL);
 			} else {
 				*is_corrupt = true;
 			}
@@ -408,9 +405,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



  parent reply	other threads:[~2023-08-14  7:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14  7:46 [PATCH v4 00/19] tools/xenstore: drop TDB Juergen Gross
2023-08-14  7:46 ` [PATCH v4 01/19] tools/xenstore: make hashtable key parameter const Juergen Gross
2023-08-14 17:51   ` Julien Grall
2023-08-14  7:46 ` [PATCH v4 02/19] tools/xenstore: let hashtable_add() fail in case of existing entry Juergen Gross
2023-08-14  7:46 ` [PATCH v4 03/19] tools/xenstore: add hashtable_replace() function Juergen Gross
2023-08-14  7:46 ` [PATCH v4 04/19] tools/xenstore: drop use of tdb Juergen Gross
2023-08-14  7:46 ` [PATCH v4 05/19] tools/xenstore: remove tdb code Juergen Gross
2023-08-14  7:46 ` Juergen Gross [this message]
2023-08-14  7:46 ` [PATCH v4 07/19] tools/xenstore: change talloc_free() to take a const pointer Juergen Gross
2023-08-14 17:53   ` Julien Grall
2023-08-14  7:46 ` [PATCH v4 08/19] tools/xenstore: move copying of node data out of db_fetch() Juergen Gross
2023-08-14 17:55   ` Julien Grall
2023-08-14  7:46 ` [PATCH v4 09/19] tools/xenstore: rework struct xs_tdb_record_hdr Juergen Gross
2023-08-14 18:04   ` Julien Grall
2023-08-14  7:46 ` [PATCH v4 10/19] tools/xenstore: don't use struct node_perms in struct node Juergen Gross
2023-08-14 18:09   ` Julien Grall
2023-08-14  7:46 ` [PATCH v4 11/19] tools/xenstore: use struct node_hdr " Juergen Gross
2023-08-18 10:57   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 12/19] tools/xenstore: alloc new memory in domain_adjust_node_perms() Juergen Gross
2023-08-18 10:59   ` [PATCH v4 12/19]tools/xenstore: " Julien Grall
2023-08-14  7:47 ` [PATCH v4 13/19] tools/xenstore: introduce read_node_const() Juergen Gross
2023-08-18 11:06   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 14/19] tools/xenstore: merge get_spec_node() into get_node_canonicalized() Juergen Gross
2023-08-18 11:07   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 15/19] tools/xenstore: merge is_valid_nodename() into canonicalize() Juergen Gross
2023-08-18 11:12   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 16/19] tools/xenstore: rework get_node() Juergen Gross
2023-08-18 11:14   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 17/19] tools/xenstore: introduce get_node_const() Juergen Gross
2023-08-18 11:16   ` Julien Grall
2023-08-14  7:47 ` [PATCH v4 18/19] tools/config: add XEN_RUN_STORED to config.h Juergen Gross
2023-08-14 10:34   ` Anthony PERARD
2023-08-14 11:07     ` Juergen Gross
2023-08-14 11:30   ` [PATCH v4.1 " Juergen Gross
2023-08-14  7:47 ` [PATCH v4 19/19] tools/xenstore: move xenstored sources into dedicated directory Juergen Gross
2023-08-18 11:22   ` Julien Grall
2023-08-18 12:14     ` Juergen Gross
2023-08-18 12:42       ` Julien Grall
2023-08-18 12:46         ` Juergen Gross
2023-08-18 12:54 ` [PATCH v4 00/19] tools/xenstore: drop TDB Julien Grall

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=20230814074707.27696-7-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=anthony.perard@citrix.com \
    --cc=jgrall@amazon.com \
    --cc=julien@xen.org \
    --cc=wl@xen.org \
    --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.