From patchwork Mon Mar 18 03:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duan, Zhenzhong" X-Patchwork-Id: 13594966 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 23B7FC54E71 for ; Mon, 18 Mar 2024 03:35:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm3lp-0002xI-BW; Sun, 17 Mar 2024 23:34:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3ln-0002wg-Mi for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:39 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3ll-0002tD-Mx for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710732878; x=1742268878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pzEf35k2DAvA11DdvyXJyAX+HNKyy5imQlrRkrZgDHk=; b=bQ4mSpxG9XN0X2LgUkN+eTWDs0SAzVmfNtxdaA00sxTD6rFnvXvL3MLp o6ThAZJ4oOAS5Egdr28e+EB5KGejvv0eybu/lnaS0j5oybq3xiz/nFgqj PgBJ1+4rBqct/Iiwa48Ib7Zi4MdGErWgjapgM2h5QVyl2GM8pFPb9fr9f auShMPYX9co6iRXegrV+J/+vFaISsnKB0nHy14vKX+436O5n2VQh8Cr+6 yzEHHrxwTT3sW9IDipPpWxAew+YDjHrUiFCf9C9k9Y5yOjHeBNDvQSd63 R8OnEKhXs+SDezF1uRZ6Pbi5ywKb3ZaE8bqi56857CDWvdEt0/RtAoGYh Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5403674" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5403674" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="13275375" Received: from spr-s2600bt.bj.intel.com ([10.240.192.124]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:30 -0700 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, zhao1.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 1/3] qom/object_interfaces: Remove unnecessary local error check Date: Mon, 18 Mar 2024 11:32:08 +0800 Message-Id: <20240318033211.459006-2-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240318033211.459006-1-zhenzhong.duan@intel.com> References: <20240318033211.459006-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=198.175.65.20; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.316, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The original error handling code indicates "local_err is always set", and error_propagate() can handle the case that local_err is NULL. Use err label instead of out label for error path. Reviewed-by: Zhao Liu Signed-off-by: Zhenzhong Duan --- qom/object_interfaces.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e0833c8bfe..70179877f1 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -111,14 +111,14 @@ Object *user_creatable_add_type(const char *type, const char *id, obj = object_new(type); object_set_properties_from_qdict(obj, qdict, v, &local_err); if (local_err) { - goto out; + goto err; } if (id != NULL) { object_property_try_add_child(object_get_objects_root(), id, obj, &local_err); if (local_err) { - goto out; + goto err; } } @@ -126,15 +126,13 @@ Object *user_creatable_add_type(const char *type, const char *id, if (id != NULL) { object_property_del(object_get_objects_root(), id); } - goto out; - } -out: - if (local_err) { - error_propagate(errp, local_err); - object_unref(obj); - return NULL; + goto err; } return obj; +err: + error_propagate(errp, local_err); + object_unref(obj); + return NULL; } void user_creatable_add_qapi(ObjectOptions *options, Error **errp) From patchwork Mon Mar 18 03:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duan, Zhenzhong" X-Patchwork-Id: 13594968 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 C9FA7C54E5D for ; Mon, 18 Mar 2024 03:35:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm3lq-0002xs-RO; Sun, 17 Mar 2024 23:34:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3lp-0002xJ-71 for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:41 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3ln-0002te-Fe for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710732880; x=1742268880; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qsYUNXoD51/dRCV99mbi4hgUh/ExSr6pjAW6CX+U9z4=; b=Rvx8EXp+HU73pjgrL+nMmidM/C+oPE6jlP5xqW56OsPvFfoedr4bKJqs rmaVns7jLrf1RJQ1gbx4Sr2loPOKn9avpmSoH/n/GASVGNcUwxzbKIJUm M0eDSOo+cxiy1djflL08W4QYPiQoDlDSBU/lvq7F+iAieaaKocvBqdm9n ap8g/zv2SUFLRFvO22NkucnSlptx9KhgPQOcRXhEBkLQBGDwbH8uEerAJ BpVYwho9cPrVeUC8CdCKtLut2CzNxVfJgnG8ElGgLgV3w1HBWivX5dvQ1 wmkTG4BsuaVTorh9DKZDkpqyDfK0qAKqrP8sDs5PVaz6JFzio/MCh7+hh Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5403677" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5403677" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="13275390" Received: from spr-s2600bt.bj.intel.com ([10.240.192.124]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:33 -0700 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, zhao1.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 2/3] qom/object_interfaces: Make object_set_properties_from_qdict return bool Date: Mon, 18 Mar 2024 11:32:09 +0800 Message-Id: <20240318033211.459006-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240318033211.459006-1-zhenzhong.duan@intel.com> References: <20240318033211.459006-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=198.175.65.20; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.316, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Make object_set_properties_from_qdict() return bool, so that user_creatable_add_type() could check its return value instead of local_err pointer. Opportunistically, do the same change to check return value of object_property_try_add_child() instead of local_err pointer. Suggested-by: Zhao Liu Signed-off-by: Zhenzhong Duan Reviewed-by: Zhao Liu --- qom/object_interfaces.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 70179877f1..e17e2de46d 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -43,22 +43,25 @@ bool user_creatable_can_be_deleted(UserCreatable *uc) } } -static void object_set_properties_from_qdict(Object *obj, const QDict *qdict, +static bool object_set_properties_from_qdict(Object *obj, const QDict *qdict, Visitor *v, Error **errp) { const QDictEntry *e; + bool ret; if (!visit_start_struct(v, NULL, NULL, 0, errp)) { - return; + return false; } for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { - if (!object_property_set(obj, e->key, v, errp)) { + ret = object_property_set(obj, e->key, v, errp); + if (!ret) { goto out; } } - visit_check_struct(v, errp); + ret = visit_check_struct(v, errp); out: visit_end_struct(v, NULL); + return ret; } void object_set_properties_from_keyval(Object *obj, const QDict *qdict, @@ -109,17 +112,13 @@ Object *user_creatable_add_type(const char *type, const char *id, assert(qdict); obj = object_new(type); - object_set_properties_from_qdict(obj, qdict, v, &local_err); - if (local_err) { + if (!object_set_properties_from_qdict(obj, qdict, v, &local_err)) { goto err; } - if (id != NULL) { - object_property_try_add_child(object_get_objects_root(), - id, obj, &local_err); - if (local_err) { + if (id != NULL && !object_property_try_add_child(object_get_objects_root(), + id, obj, &local_err)) { goto err; - } } if (!user_creatable_complete(USER_CREATABLE(obj), &local_err)) { From patchwork Mon Mar 18 03:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duan, Zhenzhong" X-Patchwork-Id: 13594967 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 18CAAC54E68 for ; Mon, 18 Mar 2024 03:35:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm3lr-0002y9-Lq; Sun, 17 Mar 2024 23:34:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3lq-0002xj-8i for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:42 -0400 Received: from mgamail.intel.com ([198.175.65.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rm3lo-0002tD-0b for qemu-devel@nongnu.org; Sun, 17 Mar 2024 23:34:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710732880; x=1742268880; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qCfBZ1GyPomLTC4f3lRL18KLkS/jDfyHNLok+VS22dA=; b=GibwcUT2EzTDcfF5Z0f/YfszHz2MAM6MKjsHTvPEEUDq6TJGSWPv8ix4 bvstFNBCOUlZU20aedp4KtMZ7WypFaNPbDidDMFFgPL2h2mjOQSL0QoGM i9kopY650eRJXu/YlEb7Q7c5HlWGU3IP8dEgAPBheOz5kTiFGhKJ2pm6S 0c6vZqpnbmznSmjWGIh9C4rSn9ETQ//9Pb0T84UrWg1u2rykDBEoyJfAJ cETzPt5OPkfsgIUc9DA3ZESvCLr/bfNc+XFE5ZrQzgVUIMAXqVwkh29Nr 7wbJ/EnRZmFe2WQhIfVItV3tuA4+L5S60rCt3aYb/xPMpysvoMZ7gXBpW A==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5403681" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5403681" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="13275396" Received: from spr-s2600bt.bj.intel.com ([10.240.192.124]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2024 20:34:35 -0700 From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, zhao1.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v2 3/3] qom/object_interfaces: Remove local_err in user_creatable_add_type Date: Mon, 18 Mar 2024 11:32:10 +0800 Message-Id: <20240318033211.459006-4-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240318033211.459006-1-zhenzhong.duan@intel.com> References: <20240318033211.459006-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=198.175.65.20; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.316, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In user_creatable_add_type, there is mixed usage of ERRP_GUARD and local_err. This makes error_abort not taking effect in those callee functions with &local_err passed. Now that we already use ERRP_GUARD, remove local_err and pass errp. Signed-off-by: Zhenzhong Duan Reviewed-by: Zhao Liu --- qom/object_interfaces.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e17e2de46d..2067bf2230 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -84,7 +84,6 @@ Object *user_creatable_add_type(const char *type, const char *id, ERRP_GUARD(); Object *obj; ObjectClass *klass; - Error *local_err = NULL; if (id != NULL && !id_wellformed(id)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); @@ -112,16 +111,16 @@ Object *user_creatable_add_type(const char *type, const char *id, assert(qdict); obj = object_new(type); - if (!object_set_properties_from_qdict(obj, qdict, v, &local_err)) { + if (!object_set_properties_from_qdict(obj, qdict, v, errp)) { goto err; } if (id != NULL && !object_property_try_add_child(object_get_objects_root(), - id, obj, &local_err)) { + id, obj, errp)) { goto err; } - if (!user_creatable_complete(USER_CREATABLE(obj), &local_err)) { + if (!user_creatable_complete(USER_CREATABLE(obj), errp)) { if (id != NULL) { object_property_del(object_get_objects_root(), id); } @@ -129,7 +128,6 @@ Object *user_creatable_add_type(const char *type, const char *id, } return obj; err: - error_propagate(errp, local_err); object_unref(obj); return NULL; }