The hypervSetEmbeddedProperty() function is used to update a value for given property in a list of properties created by hypervCreateEmbeddedParam(). The list is nothing fancy - it's a virHashTable that has NULL as dataFree callback => the table does not own the value. This is not that obvious since hypervSetEmbeddedProperty() accepts a non-const pointer. This fact makes it unnecessary hard to consume, e.g. if we wanted to pass a stack allocated string. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/hyperv/hyperv_wmi.c | 20 ++++++++++++++++++-- src/hyperv/hyperv_wmi.h | 5 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 41579858de..742a46bc28 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -351,10 +351,26 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info) return NULL; } + +/** + * hypervSetEmbeddedProperty: + * @table: hash table allocated earlier by hypervCreateEmbeddedParam() + * @name: name of the property + * @value: value of the property + * + * For given table of properties, set property of @name to @value. + * Please note, that the hash table does NOT become owner of the @value and + * thus caller must ensure the pointer validity. + * + * Returns: 0 on success, + * -1 otherwise. + */ int -hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, char *value) +hypervSetEmbeddedProperty(virHashTablePtr table, + const char *name, + const char *value) { - return virHashUpdateEntry(table, name, value); + return virHashUpdateEntry(table, name, (void*) value); } /* diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index fb19a7f375..fa8e48a70e 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -146,8 +146,9 @@ int hypervAddEprParam(hypervInvokeParamsListPtr params, const char *name, virHashTablePtr hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info); -int hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, - char *value); +int hypervSetEmbeddedProperty(virHashTablePtr table, + const char *name, + const char *value); int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv, -- 2.26.2