Skip to content

Commit

Permalink
qom: Make functions taking Error ** return bool, not void
Browse files Browse the repository at this point in the history
See recent commit "error: Document Error API usage rules" for
rationale.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
Markus Armbruster committed Jul 10, 2020
1 parent 5325cc3 commit 6fd5bef
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 62 deletions.
42 changes: 31 additions & 11 deletions include/qom/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ Object *object_new_with_propv(const char *typename,
Error **errp,
va_list vargs);

void object_apply_global_props(Object *obj, const GPtrArray *props,
bool object_apply_global_props(Object *obj, const GPtrArray *props,
Error **errp);
void object_set_machine_compat_props(GPtrArray *compat_props);
void object_set_accelerator_compat_props(GPtrArray *compat_props);
Expand Down Expand Up @@ -798,8 +798,10 @@ void object_initialize(void *obj, size_t size, const char *typename);
* strings. The propname of %NULL indicates the end of the property list.
* If the object implements the user creatable interface, the object will
* be marked complete once all the properties have been processed.
*
* Returns: %true on success, %false on failure.
*/
void object_initialize_child_with_props(Object *parentobj,
bool object_initialize_child_with_props(Object *parentobj,
const char *propname,
void *childobj, size_t size, const char *type,
Error **errp, ...) QEMU_SENTINEL;
Expand All @@ -815,8 +817,10 @@ void object_initialize_child_with_props(Object *parentobj,
* @vargs: list of property names and values
*
* See object_initialize_child() for documentation.
*
* Returns: %true on success, %false on failure.
*/
void object_initialize_child_with_propsv(Object *parentobj,
bool object_initialize_child_with_propsv(Object *parentobj,
const char *propname,
void *childobj, size_t size, const char *type,
Error **errp, va_list vargs);
Expand Down Expand Up @@ -1209,8 +1213,10 @@ void object_unparent(Object *obj);
* @errp: returns an error if this function fails
*
* Reads a property from a object.
*
* Returns: %true on success, %false on failure.
*/
void object_property_get(Object *obj, const char *name, Visitor *v,
bool object_property_get(Object *obj, const char *name, Visitor *v,
Error **errp);

/**
Expand All @@ -1220,8 +1226,10 @@ void object_property_get(Object *obj, const char *name, Visitor *v,
* @errp: returns an error if this function fails
*
* Writes a string value to a property.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_str(Object *obj, const char *name,
bool object_property_set_str(Object *obj, const char *name,
const char *value, Error **errp);

/**
Expand Down Expand Up @@ -1249,8 +1257,9 @@ char *object_property_get_str(Object *obj, const char *name,
* <code>OBJ_PROP_LINK_STRONG</code> bit, the old target object is
* unreferenced, and a reference is added to the new target object.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_link(Object *obj, const char *name,
bool object_property_set_link(Object *obj, const char *name,
Object *value, Error **errp);

/**
Expand All @@ -1273,8 +1282,10 @@ Object *object_property_get_link(Object *obj, const char *name,
* @errp: returns an error if this function fails
*
* Writes a bool value to a property.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_bool(Object *obj, const char *name,
bool object_property_set_bool(Object *obj, const char *name,
bool value, Error **errp);

/**
Expand All @@ -1296,8 +1307,10 @@ bool object_property_get_bool(Object *obj, const char *name,
* @errp: returns an error if this function fails
*
* Writes an integer value to a property.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_int(Object *obj, const char *name,
bool object_property_set_int(Object *obj, const char *name,
int64_t value, Error **errp);

/**
Expand All @@ -1319,8 +1332,10 @@ int64_t object_property_get_int(Object *obj, const char *name,
* @errp: returns an error if this function fails
*
* Writes an unsigned integer value to a property.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_uint(Object *obj, const char *name,
bool object_property_set_uint(Object *obj, const char *name,
uint64_t value, Error **errp);

/**
Expand Down Expand Up @@ -1359,8 +1374,10 @@ int object_property_get_enum(Object *obj, const char *name,
* @errp: returns an error if this function fails
*
* Writes a property to a object.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set(Object *obj, const char *name, Visitor *v,
bool object_property_set(Object *obj, const char *name, Visitor *v,
Error **errp);

/**
Expand All @@ -1371,8 +1388,10 @@ void object_property_set(Object *obj, const char *name, Visitor *v,
* @errp: returns an error if this function fails
*
* Parses a string and writes the result into a property of an object.
*
* Returns: %true on success, %false on failure.
*/
void object_property_parse(Object *obj, const char *name,
bool object_property_parse(Object *obj, const char *name,
const char *string, Error **errp);

/**
Expand Down Expand Up @@ -1815,6 +1834,7 @@ ObjectProperty *object_property_add_const_link(Object *obj, const char *name,
*
* Set an object property's description.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_description(Object *obj, const char *name,
const char *description);
Expand Down
12 changes: 9 additions & 3 deletions include/qom/object_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ typedef struct UserCreatableClass {
* Wrapper to call complete() method if one of types it's inherited
* from implements USER_CREATABLE interface, otherwise the call does
* nothing.
*
* Returns: %true on success, %false on failure.
*/
void user_creatable_complete(UserCreatable *uc, Error **errp);
bool user_creatable_complete(UserCreatable *uc, Error **errp);

/**
* user_creatable_can_be_deleted:
Expand Down Expand Up @@ -100,8 +102,10 @@ Object *user_creatable_add_type(const char *type, const char *id,
* @qdict. The object type is taken from the QDict key 'qom-type', its
* ID from the key 'id'. The remaining entries in @qdict are used to
* initialize the object properties.
*
* Returns: %true on success, %false on failure.
*/
void user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp);
bool user_creatable_add_dict(QDict *qdict, bool keyval, Error **errp);

/**
* user_creatable_add_opts:
Expand Down Expand Up @@ -167,8 +171,10 @@ bool user_creatable_print_help(const char *type, QemuOpts *opts);
*
* Delete an instance of the user creatable object identified
* by @id.
*
* Returns: %true on success, %false on failure.
*/
void user_creatable_del(const char *id, Error **errp);
bool user_creatable_del(const char *id, Error **errp);

/**
* user_creatable_cleanup:
Expand Down
4 changes: 3 additions & 1 deletion include/qom/qom-qobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ struct QObject *object_property_get_qobject(Object *obj, const char *name,
* @errp: returns an error if this function fails
*
* Writes a property to a object.
*
* Returns: %true on success, %false on failure.
*/
void object_property_set_qobject(Object *obj,
bool object_property_set_qobject(Object *obj,
const char *name, struct QObject *value,
struct Error **errp);

Expand Down
Loading

0 comments on commit 6fd5bef

Please sign in to comment.