From nobody Mon Feb 9 16:50:48 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500317735122820.6542778439322; Mon, 17 Jul 2017 11:55:35 -0700 (PDT) Received: from localhost ([::1]:52038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBB6-00078i-Q9 for importer@patchew.org; Mon, 17 Jul 2017 14:55:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6u-0003Li-8U for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6p-0003gm-4v for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6o-0003fv-Rt for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCEF32F86D1; Mon, 17 Jul 2017 18:51:05 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A0A5D6A2; Mon, 17 Jul 2017 18:51:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BCEF32F86D1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BCEF32F86D1 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:42 -0300 Message-Id: <20170717185051.18740-7-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 17 Jul 2017 18:51:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/15] qom: Fix ambiguous path detection when ambiguous=NULL 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: Mark Cave-Ayland , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" object_resolve_path*() ambiguous path detection breaks when ambiguous=3D=3DNULL and the object tree have 3 objects of the same type and only 2 of them are under the same parent. e.g.: /container/obj1 (TYPE_FOO) /container/obj2 (TYPE_FOO) /obj2 (TYPE_FOO) With the above tree, object_resolve_path_type("", TYPE_FOO, NULL) will incorrectly return /obj2, because the search inside "/container" will return NULL, and the match at "/obj2" won't be detected as ambiguous. Fix that by always calling object_resolve_partial_path() with a non-NULL ambiguous parameter. Test case included. Reported-by: Igor Mammedov Cc: Mark Cave-Ayland Signed-off-by: Eduardo Habkost Message-Id: <20170707213052.13087-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- qom/object.c | 17 ++++++++--------- tests/check-qom-proplist.c | 3 +++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/qom/object.c b/qom/object.c index dfdbd50..fe6e744 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1712,15 +1712,13 @@ static Object *object_resolve_partial_path(Object *= parent, typename, ambiguous); if (found) { if (obj) { - if (ambiguous) { - *ambiguous =3D true; - } + *ambiguous =3D true; return NULL; } obj =3D found; } =20 - if (ambiguous && *ambiguous) { + if (*ambiguous) { return NULL; } } @@ -1729,7 +1727,7 @@ static Object *object_resolve_partial_path(Object *pa= rent, } =20 Object *object_resolve_path_type(const char *path, const char *typename, - bool *ambiguous) + bool *ambiguousp) { Object *obj; gchar **parts; @@ -1738,11 +1736,12 @@ Object *object_resolve_path_type(const char *path, = const char *typename, assert(parts); =20 if (parts[0] =3D=3D NULL || strcmp(parts[0], "") !=3D 0) { - if (ambiguous) { - *ambiguous =3D false; - } + bool ambiguous =3D false; obj =3D object_resolve_partial_path(object_get_root(), parts, - typename, ambiguous); + typename, &ambiguous); + if (ambiguousp) { + *ambiguousp =3D ambiguous; + } } else { obj =3D object_resolve_abs_path(object_get_root(), parts, typename= , 1); } diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index f6e7823..432b665 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -593,14 +593,17 @@ static void test_qom_partial_path(void) ambiguous =3D false; g_assert(!object_resolve_path_type("", TYPE_DUMMY, &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path_type("", TYPE_DUMMY, NULL)); =20 ambiguous =3D false; g_assert(!object_resolve_path("obj2", &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path("obj2", NULL)); =20 ambiguous =3D false; g_assert(object_resolve_path("obj1", &ambiguous) =3D=3D obj1); g_assert(!ambiguous); + g_assert(object_resolve_path("obj1", NULL) =3D=3D obj1); =20 object_unparent(obj2b); object_unparent(cont1); --=20 2.9.4