qmp: Report path ambiguity error.
PATCH 1/1 qmp: Report path ambiguity error.
--- qmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
qmp.c +4 -1
@@ -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 ; }
Signature · 1 line
1.8.3.2
Quoted 12 lines · Hani Benhabiles
Signed-off-by Hani Benhabiles <[email protected]>Suggested-by Andreas Färber <[email protected]>--- qmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)qmp.c +0
-0@@ -199,7 +199,10 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)ObjectProperty *prop;
qmp.c ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) · line 208
Quoted 10 lines
qmp.c +4
-1obj =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:
qmp.c +3 -1
@@ -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
03.05.2014 12:38, Michael Tokarev wrote:
[]
qmp.c ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) · line 207
Quoted 12 lines
qmp.c +3
-1@@ -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
Am 05.05.2014 11:12, schrieb Michael Tokarev:
Quoted 6 lines
03.05.2014 12:38, Michael Tokarev wrote:
[]Quoted 4 lines
qmp.c +0
-0@@ -200,7 +200,9 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
Quoted 10 lines
qmp.c ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) · line 207
Quoted 8 lines
qmp.c +3
-1obj =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
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
05.05.2014 13:26, Andreas Färber пишет:
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines · Michael Tokarev
qmp.c +3
-0+error_set (errp, + ambiguous ?"Path '%s' is ambiguous" :QERR_DEVICE_NOT_FOUND , + path);
Quoted 6 lines
Quoted 1 line
I've applied this version.
Please undo.
error_set()unlikeerror_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
Am 29.04.2014 00:46, schrieb Hani Benhabiles:
Quoted 12 lines
Signed-off-by Hani Benhabiles <[email protected]>Suggested-by Andreas Färber <[email protected]>--- qmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)qmp.c +0
-0@@ -199,7 +199,10 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)ObjectProperty *prop;
qmp.c ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) · line 208
Quoted 10 lines
qmp.c +4
-1obj =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
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg