qpm: Minor error value corrections
cover qpm: Minor error value corrections
Markus Armbruster (2):
qom: Clean up object_property_get_enum()'s error value
qom: Correct error values in two contracts
include/qom/object.h | 10 +++++----- qom/object.c | 6 +++--- tests/check-qom-proplist.c | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 qom: Clean up object_property_get_enum()'s error value
object_property_get_enum() is the only object_property_FOO() that is documented to return an undefined value on error. It does no such thing, actually: it returns 0 on some errors, and -1 on others.
Needlessly complicated. Always return -1 on error, and adjust the contract.
--- include/qom/object.h | 6 +++--- qom/object.c | 6 +++--- tests/check-qom-proplist.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-)
include/qom/object.h +3 -3
@@ -1687,9 +1687,9 @@ uint64_t object_property_get_uint(Object *obj, const char *name,* @typename: the name of the enum data type * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to an integer, or -* undefined if an error occurs (including when the property value is not -* an enum). +* Returns: the value of the property, converted to an integer (which +* can't be negative), or -1 on error (including when the property +* value is not an enum). */ int object_property_get_enum (Object *obj,const char *name,const char *typename,Error **errp);
qom/object.c +3 -3
@@ -1564,21 +1564,21 @@ int object_property_get_enum(Object *obj, const char *name,EnumProperty *enumprop;if (prop ==NULL ) { -return 0 ; +return -1 ; }if (!g_str_equal (prop->type, typename)) {error_setg (errp,"Property %s on %s is not '%s' enum type" , name,object_class_get_name (object_get_class (obj)), typename); -return 0 ; +return -1 ; } enumprop = prop->opaque; str =object_property_get_str (obj, name, errp);if (!str) { -return 0 ; +return -1 ; } ret =qapi_enum_parse (enumprop->lookup, str,-1 , errp);
tests/check-qom-proplist.c +2 -0
@@ -491,6 +491,7 @@ static void test_dummy_getenum(void)"av" ,"BadAnimal" , &err); +g_assert (val ==-1 );error_free_or_abort (&err);/* A non-enum property name */
@@ -498,6 +499,7 @@ static void test_dummy_getenum(void)"iv" ,"DummyAnimal" , &err); +g_assert (val ==-1 );error_free_or_abort (&err);object_unparent (OBJECT (dobj));
Signature · 1 line
2.26.2
Re: [PATCH 1/2] qom: Clean up object_property_get_enum()'s error value
Quoted 7 lines · Markus Armbruster
object_property_get_enum()is the onlyobject_property_FOO()that is documented to return an undefined value on error. It does no such thing, actually: it returns 0 on some errors, and -1 on others.Needlessly complicated. Always return -1 on error, and adjust the contract.
Quoted 6 lines
Signed-off-by Markus Armbruster <[email protected]>--- include/qom/object.h | 6 +++--- qom/object.c | 6 +++--- tests/check-qom-proplist.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] qom: Clean up object_property_get_enum()'s error value
In reply to Markus ArmbrusterQuoted 9 lines · On Thu, 17 Sep 2020 14:55:39 +0200 Markus Armbruster <[email protected]> wrote:
object_property_get_enum()is the onlyobject_property_FOO()that is documented to return an undefined value on error. It does no such thing, actually: it returns 0 on some errors, and -1 on others.Needlessly complicated. Always return -1 on error, and adjust the contract.
Signed-off-by Markus Armbruster <[email protected]>---
Quoted 71 lines
include/qom/object.h | 6 +++--- qom/object.c | 6 +++--- tests/check-qom-proplist.c | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-)include/qom/object.h +3
-3@@ -1687,9 +1687,9 @@ uint64_t object_property_get_uint(Object *obj, const char *name,* @typename: the name of the enum data type * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to an integer, or -* undefined if an error occurs (including when the property value is not -* an enum). +* Returns: the value of the property, converted to an integer (which +* can't be negative), or -1 on error (including when the property +* value is not an enum). */ int object_property_get_enum (Object *obj,const char *name,const char *typename,Error **errp);qom/object.c +3
-3@@ -1564,21 +1564,21 @@ int object_property_get_enum(Object *obj, const char *name,EnumProperty *enumprop;if (prop ==NULL ) { -return 0 ; +return -1 ; }if (!g_str_equal (prop->type, typename)) {error_setg (errp,"Property %s on %s is not '%s' enum type" , name,object_class_get_name (object_get_class (obj)), typename); -return 0 ; +return -1 ; } enumprop = prop->opaque; str =object_property_get_str (obj, name, errp);if (!str) { -return 0 ; +return -1 ; } ret =qapi_enum_parse (enumprop->lookup, str,-1 , errp);tests/check-qom-proplist.c +2
-0@@ -491,6 +491,7 @@ static void test_dummy_getenum(void)"av" ,"BadAnimal" , &err); +g_assert (val ==-1 );error_free_or_abort (&err);/* A non-enum property name */ @@ -498,6 +499,7 @@ static void test_dummy_getenum(void)"iv" ,"DummyAnimal" , &err); +g_assert (val ==-1 );error_free_or_abort (&err);object_unparent (OBJECT (dobj));
PATCH 2/2 qom: Correct error values in two contracts
In reply to Markus Armbrusterobject_property_get_bool()'s contract claims it returns NULL on error. Pasto; it returns false.
object_property_get_int()'s contract claims it returns "negative". It actually returns -1. All the other object_property_get_FOO() contracts specify the exact error value, so do the same here.
--- include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/qom/object.h +2 -2
@@ -1624,7 +1624,7 @@ bool object_property_set_bool(Object *obj, const char *name,* @name: the name of the property * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to a boolean, or NULL if +* Returns: the value of the property, converted to a boolean, or false if * an error occurs (including when the property value is not a bool). */ bool object_property_get_bool(Object *obj, const char *name,
@@ -1649,7 +1649,7 @@ bool object_property_set_int(Object *obj, const char *name,* @name: the name of the property * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to an integer, or negative if +* Returns: the value of the property, converted to an integer, or -1 if * an error occurs (including when the property value is not an integer). */ int64_t object_property_get_int(Object *obj, const char *name,
Signature · 1 line
2.26.2
Re: [PATCH 2/2] qom: Correct error values in two contracts
Quoted 11 lines · Markus Armbruster
object_property_get_bool()'s contract claims it returns NULL on error. Pasto; it returns false.
object_property_get_int()'s contract claims it returns "negative". It actually returns -1. All the other
object_property_get_FOO()contracts specify the exact error value, so do the same here.Signed-off-by Markus Armbruster <[email protected]>--- include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 2/2] qom: Correct error values in two contracts
In reply to Markus ArmbrusterQuoted 9 lines · On Thu, 17 Sep 2020 14:55:40 +0200 Markus Armbruster <[email protected]> wrote:
object_property_get_bool()'s contract claims it returns NULL on error. Pasto; it returns false.
object_property_get_int()'s contract claims it returns "negative". It actually returns -1. All the other
object_property_get_FOO()contracts specify the exact error value, so do the same here.Signed-off-by Markus Armbruster <[email protected]>---
Quoted 25 lines
include/qom/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/qom/object.h +2
-2@@ -1624,7 +1624,7 @@ bool object_property_set_bool(Object *obj, const char *name,* @name: the name of the property * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to a boolean, or NULL if +* Returns: the value of the property, converted to a boolean, or false if * an error occurs (including when the property value is not a bool). */ bool object_property_get_bool(Object *obj, const char *name,@@ -1649,7 +1649,7 @@ bool object_property_set_int(Object *obj, const char *name,* @name: the name of the property * @errp: returns an error if this function fails * -* Returns: the value of the property, converted to an integer, or negative if +* Returns: the value of the property, converted to an integer, or -1 if * an error occurs (including when the property value is not an integer). */ int64_t object_property_get_int(Object *obj, const char *name,
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed build test on FreeBSD host. Please find the details below.
The full log is available at
http://patchew.org/logs/[email protected]/testing.FreeBSD/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
N/A. Internal error while reading log file
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Eduardo Habkost
AppliedQuoted 3 lines · Markus Armbruster
Markus Armbruster (2):
qom: Clean up object_property_get_enum()'s error value
qom: Correct error values in two contracts
Queued, thanks!
Signature · 1 line
Eduardo