From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1WgVSm-0001w8-0i for mharc-qemu-trivial@gnu.org; Sat, 03 May 2014 04:38:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgVSg-0001pD-3s for qemu-trivial@nongnu.org; Sat, 03 May 2014 04:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgVSb-0004Gq-Ev for qemu-trivial@nongnu.org; Sat, 03 May 2014 04:38:22 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:41241) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgVSS-0004Dh-4W; Sat, 03 May 2014 04:38:08 -0400 Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id C26994027E; Sat, 3 May 2014 12:38:06 +0400 (MSK) Message-ID: <5364AAEE.7000500@msgid.tls.msk.ru> Date: Sat, 03 May 2014 12:38:06 +0400 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: Hani Benhabiles , qemu-devel@nongnu.org References: <1398725186-8202-1-git-send-email-kroosec@gmail.com> In-Reply-To: <1398725186-8202-1-git-send-email-kroosec@gmail.com> X-Enigmail-Version: 1.6 OpenPGP: id=804465C5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, =?UTF-8?B?QW5kcmVhcyA=?= =?UTF-8?B?RsOkcmJlcg==?= , lcapitulino@redhat.com Subject: Re: [Qemu-trivial] [PATCH] qmp: Report path ambiguity error. X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 May 2014 08:38:26 -0000 29.04.2014 02:46, Hani Benhabiles wrote: > Signed-off-by: Hani Benhabiles > Suggested-by: Andreas F=C3=A4rber > --- > qmp.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/qmp.c b/qmp.c > index 74107be..0d49abf 100644 > --- a/qmp.c > +++ b/qmp.c > @@ -199,7 +199,10 @@ ObjectPropertyInfoList *qmp_qom_list(const char *p= ath, Error **errp) > ObjectProperty *prop; > =20 > obj =3D object_resolve_path(path, &ambiguous); > - if (obj =3D=3D NULL) { > + if (ambiguous) { > + error_setg(errp, "Path '%s' is ambiguous", path); > + return NULL; > + } else if (obj =3D=3D NULL) { > error_set(errp, QERR_DEVICE_NOT_FOUND, path); > return NULL; > } How about this: --- a/qmp.c +++ b/qmp.c @@ -200,7 +200,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path= , Error **errp) obj =3D object_resolve_path(path, &ambiguous); if (obj =3D=3D NULL) { - error_set(errp, QERR_DEVICE_NOT_FOUND, path); + error_set(errp, + ambiguous ? "Path '%s' is ambiguous" : QERR_DEVICE_NOT= _FOUND, + path); return NULL; } The difference here is that we test "ambiguous" variable only if obj is N= ULL, ie, only on error path. Please note that object_resolve_path() does not initialize *ambiguous in all code paths. Thanks, /mjt From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgVSW-0001kc-Sp for qemu-devel@nongnu.org; Sat, 03 May 2014 04:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgVSS-0004EH-CN for qemu-devel@nongnu.org; Sat, 03 May 2014 04:38:12 -0400 Message-ID: <5364AAEE.7000500@msgid.tls.msk.ru> Date: Sat, 03 May 2014 12:38:06 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1398725186-8202-1-git-send-email-kroosec@gmail.com> In-Reply-To: <1398725186-8202-1-git-send-email-kroosec@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hani Benhabiles , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, =?UTF-8?B?QW5kcmVhcyA=?= =?UTF-8?B?RsOkcmJlcg==?= , lcapitulino@redhat.com 29.04.2014 02:46, Hani Benhabiles wrote: > Signed-off-by: Hani Benhabiles > Suggested-by: Andreas F=C3=A4rber > --- > qmp.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/qmp.c b/qmp.c > index 74107be..0d49abf 100644 > --- a/qmp.c > +++ b/qmp.c > @@ -199,7 +199,10 @@ ObjectPropertyInfoList *qmp_qom_list(const char *p= ath, Error **errp) > ObjectProperty *prop; > =20 > obj =3D object_resolve_path(path, &ambiguous); > - if (obj =3D=3D NULL) { > + if (ambiguous) { > + error_setg(errp, "Path '%s' is ambiguous", path); > + return NULL; > + } else if (obj =3D=3D NULL) { > error_set(errp, QERR_DEVICE_NOT_FOUND, path); > return NULL; > } How about this: --- a/qmp.c +++ b/qmp.c @@ -200,7 +200,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path= , Error **errp) obj =3D object_resolve_path(path, &ambiguous); if (obj =3D=3D NULL) { - error_set(errp, QERR_DEVICE_NOT_FOUND, path); + error_set(errp, + ambiguous ? "Path '%s' is ambiguous" : QERR_DEVICE_NOT= _FOUND, + path); return NULL; } The difference here is that we test "ambiguous" variable only if obj is N= ULL, ie, only on error path. Please note that object_resolve_path() does not initialize *ambiguous in all code paths. Thanks, /mjt