Hi Louis,

On Mon Dec 29, 2025 at 4:29 PM CET, Louis Chauvet wrote:
>>> --- a/drivers/gpu/drm/vkms/vkms_config.c
>>> +++ b/drivers/gpu/drm/vkms/vkms_config.c
>>
>>> +void vkms_config_plane_remove_all_formats(struct vkms_config_plane 
>>> *plane_cfg)
>>> +{
>>> +   plane_cfg->supported_formats_count = 0;
>>
>> Why not kfree(plane_cfg->supported_formats) too? You will be (re)allocating
>> anyway if adding one or all formats later on, so the buffer you're not
>> freeing won't be reused anyway.
>
> IIRC realloc reuse the existing allocated buffer if it is big enough to fit 
> the new
> size. But I think this is probably an oversight here and I will add the free 
> to clarify the situation :-)

Thanks. My point is that keeping the buffer allocated for future use is not
great because if it is not reused it will take memory for all the remaining
uptime.

>>> +}
>>> +
>>> +void vkms_config_plane_remove_format(struct vkms_config_plane *plane_cfg, 
>>> u32 drm_format)
>>> +{
>>> +   for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
>>> +           if (plane_cfg->supported_formats[i] == drm_format) {
>>> +                   plane_cfg->supported_formats[i] = 
>>> plane_cfg->supported_formats[plane_cfg->supported_formats_count - 1];
>>
>> I doubt these are less than 100 chars. ;-)
>
> yes, 127, but I don't know how to format it so it is readable.
>
> I tried
>
> plane_cfg->supported_formats[i] =
>       plane_cfg->supported_formats[plane_cfg->supported_formats_count - 1];
>
> But the second line is 101 chars...

I vote for this one. 101 is close enough to 100, and I see no reaonable way
to format better (and I agree the two below are ugly).

> Checkpatch don't complain if I do:
>
> plane_cfg->supported_formats[i] =
>       plane_cfg->supported_formats[
>               plane_cfg->supported_formats_count - 1];
>
> or
>
> plane_cfg->supported_formats[i] =
>       plane_cfg->supported_formats[plane_cfg->supported_formats_count-
>               1];
>
> But that very ugly and not readable...

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Reply via email to