From nobody Mon Apr 29 13:06:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154263605090477.49229215727951; Mon, 19 Nov 2018 06:00:50 -0800 (PST) Received: from localhost ([::1]:56423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gOk6F-00040A-OZ for importer@patchew.org; Mon, 19 Nov 2018 09:00:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gOk50-0003ZC-1O for qemu-devel@nongnu.org; Mon, 19 Nov 2018 08:59:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gOk4w-0006mk-PF for qemu-devel@nongnu.org; Mon, 19 Nov 2018 08:59:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gOk4w-0006mC-Jm for qemu-devel@nongnu.org; Mon, 19 Nov 2018 08:59:06 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B18C2D7F3; Mon, 19 Nov 2018 13:59:05 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2A8017545; Mon, 19 Nov 2018 13:59:04 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Mon, 19 Nov 2018 13:59:03 +0000 Message-Id: <20181119135903.11729-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 19 Nov 2018 13:59:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qom: avoid reporting errors for NULL error object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When debugging QEMU it is often useful to put a breakpoint on the error_setg_internal method impl. Unfortunately the object_property_add / object_class_property_add methods call object_property_find / object_class_property_find methods to check if a property exists already before adding the new property. As a result there are a huge number of calls to error_setg_internal on startup of most QEMU commands, making it very painful to set a breakpoint on this method. This puts a minor optimization on the code so that we avoid calling error_setg() when errp is NULL. Functionally there's no difference since error_setg() is a no-op when errp is NULL, but this lets us use breakpoints in GDB in a practical way. Signed-off-by: Daniel P. Berrang=C3=A9 --- qom/object.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index 547dcf97c3..ddd5e7a30e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1087,7 +1087,12 @@ ObjectProperty *object_property_find(Object *obj, co= nst char *name, return prop; } =20 - error_setg(errp, "Property '.%s' not found", name); + /* Optimized to avoid calling error_setg if errp =3D=3D NULL + * otherwise every property add call hits error_setg + * making it impratical to set breakpoints in GDB */ + if (errp) { + error_setg(errp, "Property '.%s' not found", name); + } return NULL; } =20 @@ -1133,7 +1138,10 @@ ObjectProperty *object_class_property_find(ObjectCla= ss *klass, const char *name, } =20 prop =3D g_hash_table_lookup(klass->properties, name); - if (!prop) { + /* Optimized to avoid calling error_setg if errp =3D=3D NULL + * otherwise every property add call hits error_setg + * making it impratical to set breakpoints in GDB */ + if (!prop && errp) { error_setg(errp, "Property '.%s' not found", name); } return prop; --=20 2.19.1