From patchwork Mon Aug 14 07:46:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13352474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8850FC04A94 for ; Mon, 14 Aug 2023 07:47:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.583325.913506 (Exim 4.92) (envelope-from ) id 1qVSIj-0004XZ-VL; Mon, 14 Aug 2023 07:47:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 583325.913506; Mon, 14 Aug 2023 07:47:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qVSIj-0004XQ-SE; Mon, 14 Aug 2023 07:47:45 +0000 Received: by outflank-mailman (input) for mailman id 583325; Mon, 14 Aug 2023 07:47:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qVSIi-0002SK-PE for xen-devel@lists.xenproject.org; Mon, 14 Aug 2023 07:47:44 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id da82ddac-3a76-11ee-b288-6b7b168915f2; Mon, 14 Aug 2023 09:47:44 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 12F881FD60; Mon, 14 Aug 2023 07:47:44 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D4574138EE; Mon, 14 Aug 2023 07:47:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id T/+PMh/c2WTiQQAAMHmgww (envelope-from ); Mon, 14 Aug 2023 07:47:43 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: da82ddac-3a76-11ee-b288-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1691999264; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BG6qvkTJomUkTWnj+OlsG8s/EdIwcHngnOtZ7JpxP6M=; b=dToHoiLXuAix5YyO8lKnbdWE4Jd2JYRLWh79ZyMjzSTiUP12YZ3x//MMfL5c0lK2au+RdH 8Wz1CvYlgC8thJb7onpGoEmboATAIS6E56tPE4O8VwtfTEUDaTR4u4dZ8BKqqzD1m5PZm4 1N518dXE6J2m8YqR3qE2JXMDz6Az2IM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v4 06/19] tools/xenstore: let db_delete() return void Date: Mon, 14 Aug 2023 09:46:54 +0200 Message-Id: <20230814074707.27696-7-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230814074707.27696-1-jgross@suse.com> References: <20230814074707.27696-1-jgross@suse.com> MIME-Version: 1.0 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 Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- 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,