[PATCH weston 17/68] compositor-drm: Refactor destroy drm_fb function

Daniel Stone daniel at fooishbar.org
Mon Feb 27 22:48:27 UTC 2017


Hi,

On 21 February 2017 at 13:58, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> On Fri,  9 Dec 2016 19:57:32 +0000 Daniel Stone <daniels at collabora.com> wrote:
>> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
>> index af43a15..7dbfc6b 100644
>> --- a/libweston/compositor-drm.c
>> +++ b/libweston/compositor-drm.c
>> @@ -251,16 +251,39 @@ drm_sprite_crtc_supported(struct drm_output *output, struct drm_sprite *sprite)
>>  }
>>
>>  static void
>> -drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
>> +drm_fb_destroy(struct drm_fb *fb)
>>  {
>> -     struct drm_fb *fb = data;
>> +     drmModeRmFB(fb->fd, fb->fb_id);
>
> fb_id cannot be zero, even thought earlier there was a check. Ok.
>
>> +     weston_buffer_reference(&fb->buffer_ref, NULL);
>> +     free(fb);
>> +}
>> +
>> +static void
>> +drm_fb_destroy_dumb(struct drm_fb *fb)
>> +{
>> +     struct drm_mode_destroy_dumb destroy_arg;
>>
>> -     if (fb->fb_id)
>> -             drmModeRmFB(fb->fd, fb->fb_id);
>> +     if (!fb)
>> +             return;
>
> Silent acceptance of NULL argument, really?

I think this was just misreading the callsites, thinking that some
called it with possibly-NULL. Inspection shows that to be incorrect,
so, fixed.

>> -     weston_buffer_reference(&fb->buffer_ref, NULL);
>> +     assert(fb->type == BUFFER_PIXMAN_DUMB);
>
> fb->map cannot be NULL, even thought earlier there was a check. Ok.

Both that and fb_id fixed; the error would've been swallowed either
way, but better not to generate errors in the first.

Cheers,
Daniel


More information about the wayland-devel mailing list