On 9/4/25 14:10, Stefan Kober wrote:
> On-behalf-of: SAP stefan.ko...@sap.com
> Signed-off-by: Stefan Kober <stefan.ko...@cyberus-technology.de>
> ---
>  src/ch/ch_monitor.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
> index 710ba06d2d..6ed78c09c7 100644
> --- a/src/ch/ch_monitor.c
> +++ b/src/ch/ch_monitor.c
> @@ -584,15 +584,25 @@ virCHMonitorBuildVMJson(virCHDriver *driver, 
> virDomainDef *vmdef,
>      return 0;
>  }
>  
> +static virJSONValue*
> +virCHMonitorBuildKeyValueJson(const char *key,
> +                              const char *value)
> +{
> +    g_autoptr(virJSONValue) content = virJSONValueNewObject();
> +
> +    if (virJSONValueObjectAppendString(content, key, value) < 0)
> +        return NULL;
> +
> +    return g_steal_pointer(&content);
> +}
> +
>  static int
>  virCHMonitorBuildKeyValueStringJson(char **jsonstr,
>                                      const char *key,
>                                      const char *value)
>  {
> -    g_autoptr(virJSONValue) content = virJSONValueNewObject();
> -
> -    if (virJSONValueObjectAppendString(content, key, value) < 0)
> -        return -1;
> +    g_autoptr(virJSONValue) content =
> +        virCHMonitorBuildKeyValueJson(key, value);

This fits onto one line perfectly.

>  
>      if (!(*jsonstr = virJSONValueToString(content, false)))
>          return -1;

Michal

Reply via email to