Marc-André Lureau <[email protected]> writes:

> Hi
>
> On Wed, Oct 22, 2025 at 2:15 PM Markus Armbruster <[email protected]> wrote:
>>
>> Simpler (more so after the next commit), and no risk of truncation
>> because the caller's buffer is too small.  Performance doesn't matter;
>> the method is only used for "info qdev".
>>
>> Signed-off-by: Markus Armbruster <[email protected]>

[...]

>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index b7e8a89ba5..422a486969 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
>> @@ -1117,12 +1117,11 @@ static void qdev_get_legacy_property(Object *obj, 
>> Visitor *v,
>>                                       Error **errp)
>>  {
>>      const Property *prop = opaque;
>> +    char *s;
>
> Why not g_autofree ?

Old habits...  I think it's a wash here, because there's just one path
through the function.

>> -    char buffer[1024];
>> -    char *ptr = buffer;
>> -
>> -    prop->info->print(obj, prop, buffer, sizeof(buffer));
>> -    visit_type_str(v, name, &ptr, errp);
>> +    s = prop->info->print(obj, prop);
>> +    visit_type_str(v, name, &s, errp);
>> +    g_free(s);
>
> otherwise,
> Reviewed-by: Marc-André Lureau <[email protected]>

Thanks!


Reply via email to