* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error.
[not found] <1398725186-8202-1-git-send-email-kroosec@gmail.com>
@ 2014-05-03 8:38 ` Michael Tokarev
2014-05-05 9:12 ` Michael Tokarev
2014-05-05 9:37 ` [Qemu-devel] " Andreas Färber
1 sibling, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2014-05-03 8:38 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel
Cc: qemu-trivial, Andreas Färber, lcapitulino
29.04.2014 02:46, Hani Benhabiles wrote:
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> Suggested-by: Andreas Färber <afaerber@suse.de>
> ---
> qmp.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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 *path, Error **errp)
> ObjectProperty *prop;
>
> obj = object_resolve_path(path, &ambiguous);
> - if (obj == NULL) {
> + if (ambiguous) {
> + error_setg(errp, "Path '%s' is ambiguous", path);
> + return NULL;
> + } else if (obj == 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 = object_resolve_path(path, &ambiguous);
if (obj == 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 NULL,
ie, only on error path. Please note that object_resolve_path() does not
initialize *ambiguous in all code paths.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error.
2014-05-03 8:38 ` [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error Michael Tokarev
@ 2014-05-05 9:12 ` Michael Tokarev
2014-05-05 9:26 ` Andreas Färber
0 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2014-05-05 9:12 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel
Cc: qemu-trivial, Andreas Färber, lcapitulino
03.05.2014 12:38, Michael Tokarev wrote:
[]
> --- a/qmp.c
> +++ b/qmp.c
> @@ -200,7 +200,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
>
> obj = object_resolve_path(path, &ambiguous);
> if (obj == NULL) {
> - error_set(errp, QERR_DEVICE_NOT_FOUND, path);
> + error_set(errp,
> + ambiguous ? "Path '%s' is ambiguous" : QERR_DEVICE_NOT_FOUND,
> + path);
> return NULL;
> }
I've applied this version.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error.
2014-05-05 9:12 ` Michael Tokarev
@ 2014-05-05 9:26 ` Andreas Färber
2014-05-05 9:31 ` Michael Tokarev
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2014-05-05 9:26 UTC (permalink / raw)
To: Michael Tokarev, Hani Benhabiles, qemu-devel; +Cc: qemu-trivial, lcapitulino
Am 05.05.2014 11:12, schrieb Michael Tokarev:
> 03.05.2014 12:38, Michael Tokarev wrote:
> []
>> --- a/qmp.c
>> +++ b/qmp.c
>> @@ -200,7 +200,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
>>
>> obj = object_resolve_path(path, &ambiguous);
>> if (obj == NULL) {
>> - error_set(errp, QERR_DEVICE_NOT_FOUND, path);
>> + error_set(errp,
>> + ambiguous ? "Path '%s' is ambiguous" : QERR_DEVICE_NOT_FOUND,
>> + path);
>> return NULL;
>> }
>
> I've applied this version.
Please undo. error_set() unlike error_setg() expects an ErrorClass
argument before the string. QERR_* macro contains *two* comma-separated
values, so it is on top filling in the device-not-found message as path
in the ambiguous case.
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error.
2014-05-05 9:26 ` Andreas Färber
@ 2014-05-05 9:31 ` Michael Tokarev
0 siblings, 0 replies; 5+ messages in thread
From: Michael Tokarev @ 2014-05-05 9:31 UTC (permalink / raw)
To: Andreas Färber, Hani Benhabiles, qemu-devel
Cc: qemu-trivial, lcapitulino
05.05.2014 13:26, Andreas Färber пишет:
>> 03.05.2014 12:38, Michael Tokarev wrote:
>>> + error_set(errp,
>>> + ambiguous ? "Path '%s' is ambiguous" : QERR_DEVICE_NOT_FOUND,
>>> + path);
>> I've applied this version.
>
> Please undo. error_set() unlike error_setg() expects an ErrorClass
> argument before the string. QERR_* macro contains *two* comma-separated
> values, so it is on top filling in the device-not-found message as path
> in the ambiguous case.
Heh, I havent tried to compile it yet ;) Ofcourse I'd find this out before
sending the pull request. Actually this is a classic ENOCOFFEE, twice.
I'll fix this for real. This makes way too many iterations.
/mjt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] qmp: Report path ambiguity error.
[not found] <1398725186-8202-1-git-send-email-kroosec@gmail.com>
2014-05-03 8:38 ` [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error Michael Tokarev
@ 2014-05-05 9:37 ` Andreas Färber
1 sibling, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2014-05-05 9:37 UTC (permalink / raw)
To: Hani Benhabiles, Michael Tokarev; +Cc: qemu-trivial, qemu-devel, lcapitulino
Am 29.04.2014 00:46, schrieb Hani Benhabiles:
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> Suggested-by: Andreas Färber <afaerber@suse.de>
> ---
> qmp.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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 *path, Error **errp)
> ObjectProperty *prop;
>
> obj = object_resolve_path(path, &ambiguous);
> - if (obj == NULL) {
> + if (ambiguous) {
> + error_setg(errp, "Path '%s' is ambiguous", path);
> + return NULL;
> + } else if (obj == NULL) {
> error_set(errp, QERR_DEVICE_NOT_FOUND, path);
> return NULL;
> }
This is not quite what I suggested, but assuming bool ambiguous gets
initialized to false, this variant should work too.
Hani, please note that your Signed-off-by should be the last line in the
commit message. No need to resend just for that. I'll try to dig out the
code for a proper Rb later.
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-05 9:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1398725186-8202-1-git-send-email-kroosec@gmail.com>
2014-05-03 8:38 ` [Qemu-devel] [Qemu-trivial] [PATCH] qmp: Report path ambiguity error Michael Tokarev
2014-05-05 9:12 ` Michael Tokarev
2014-05-05 9:26 ` Andreas Färber
2014-05-05 9:31 ` Michael Tokarev
2014-05-05 9:37 ` [Qemu-devel] " Andreas Färber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).