Don't cast free function passed to g_clear_pointer

The function is intentionally provided as macro to not require a
cast. Recently the macro was improved to check that the passed in
pointer matches the free function, so the cast to GDestroyNotify
is now even harmful.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/176
This commit is contained in:
Florian Müllner 2018-07-23 19:22:51 +02:00
parent c403785d36
commit 7fdaf7721c
8 changed files with 22 additions and 22 deletions

View File

@ -142,7 +142,7 @@ clutter_seat_evdev_release_touch_state (ClutterSeatEvdev *seat,
ClutterTouchState *touch_state) ClutterTouchState *touch_state)
{ {
g_clear_pointer (&seat->touch_states[touch_state->seat_slot], g_clear_pointer (&seat->touch_states[touch_state->seat_slot],
(GDestroyNotify) clutter_touch_state_free); clutter_touch_state_free);
} }
ClutterSeatEvdev * ClutterSeatEvdev *

View File

@ -578,9 +578,9 @@ meta_screen_cast_stream_src_finalize (GObject *object)
if (meta_screen_cast_stream_src_is_enabled (src)) if (meta_screen_cast_stream_src_is_enabled (src))
meta_screen_cast_stream_src_disable (src); meta_screen_cast_stream_src_disable (src);
g_clear_pointer (&priv->pipewire_stream, (GDestroyNotify) pw_stream_destroy); g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
g_clear_pointer (&priv->pipewire_remote, (GDestroyNotify) pw_remote_destroy); g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
g_clear_pointer (&priv->pipewire_core, (GDestroyNotify) pw_core_destroy); g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
g_source_destroy (&priv->pipewire_source->base); g_source_destroy (&priv->pipewire_source->base);
G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object); G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);

View File

@ -749,7 +749,7 @@ cursor_gpu_state_free (MetaCursorNativeGpuState *cursor_gpu_state)
int i; int i;
for (i = 0; i < HW_CURSOR_BUFFER_COUNT; i++) for (i = 0; i < HW_CURSOR_BUFFER_COUNT; i++)
g_clear_pointer (&cursor_gpu_state->bos[i], (GDestroyNotify) gbm_bo_destroy); g_clear_pointer (&cursor_gpu_state->bos[i], gbm_bo_destroy);
g_free (cursor_gpu_state); g_free (cursor_gpu_state);
} }
@ -789,7 +789,7 @@ on_cursor_sprite_texture_changed (MetaCursorSprite *cursor_sprite)
guint pending_bo; guint pending_bo;
pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state); pending_bo = get_pending_cursor_sprite_gbm_bo_index (cursor_gpu_state);
g_clear_pointer (&cursor_gpu_state->bos[pending_bo], g_clear_pointer (&cursor_gpu_state->bos[pending_bo],
(GDestroyNotify) gbm_bo_destroy); gbm_bo_destroy);
cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED; cursor_gpu_state->pending_bo_state = META_CURSOR_GBM_BO_STATE_INVALIDATED;
} }
} }

View File

@ -185,7 +185,7 @@ set_clip_region (MetaBackgroundActor *self,
{ {
MetaBackgroundActorPrivate *priv = self->priv; MetaBackgroundActorPrivate *priv = self->priv;
g_clear_pointer (&priv->clip_region, (GDestroyNotify) cairo_region_destroy); g_clear_pointer (&priv->clip_region, cairo_region_destroy);
if (clip_region) if (clip_region)
priv->clip_region = cairo_region_copy (clip_region); priv->clip_region = cairo_region_copy (clip_region);
} }

View File

@ -160,7 +160,7 @@ set_unobscured_region (MetaShapedTexture *self,
{ {
MetaShapedTexturePrivate *priv = self->priv; MetaShapedTexturePrivate *priv = self->priv;
g_clear_pointer (&priv->unobscured_region, (GDestroyNotify) cairo_region_destroy); g_clear_pointer (&priv->unobscured_region, cairo_region_destroy);
if (unobscured_region) if (unobscured_region)
{ {
guint width, height; guint width, height;
@ -188,7 +188,7 @@ set_clip_region (MetaShapedTexture *self,
{ {
MetaShapedTexturePrivate *priv = self->priv; MetaShapedTexturePrivate *priv = self->priv;
g_clear_pointer (&priv->clip_region, (GDestroyNotify) cairo_region_destroy); g_clear_pointer (&priv->clip_region, cairo_region_destroy);
if (clip_region) if (clip_region)
priv->clip_region = cairo_region_copy (clip_region); priv->clip_region = cairo_region_copy (clip_region);
} }

View File

@ -931,9 +931,9 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->gesture_tracker); g_clear_object (&display->gesture_tracker);
g_clear_pointer (&display->stack, (GDestroyNotify) meta_stack_free); g_clear_pointer (&display->stack, meta_stack_free);
g_clear_pointer (&display->stack_tracker, g_clear_pointer (&display->stack_tracker,
(GDestroyNotify) meta_stack_tracker_free); meta_stack_tracker_free);
if (display->focus_timeout_id) if (display->focus_timeout_id)
g_source_remove (display->focus_timeout_id); g_source_remove (display->focus_timeout_id);

View File

@ -549,8 +549,8 @@ meta_wayland_touch_disable (MetaWaylandTouch *touch)
meta_wayland_touch_cancel (touch); meta_wayland_touch_cancel (touch);
g_clear_pointer (&touch->touch_surfaces, (GDestroyNotify) g_hash_table_unref); g_clear_pointer (&touch->touch_surfaces, g_hash_table_unref);
g_clear_pointer (&touch->touches, (GDestroyNotify) g_hash_table_unref); g_clear_pointer (&touch->touches, g_hash_table_unref);
} }
void void

View File

@ -485,7 +485,7 @@ x11_selection_data_finish (MetaSelectionBridge *selection,
x11_selection_data_send_finished (selection, success); x11_selection_data_send_finished (selection, success);
g_clear_pointer (&selection->x11_selection, g_clear_pointer (&selection->x11_selection,
(GDestroyNotify) x11_selection_data_free); x11_selection_data_free);
} }
static void static void
@ -707,7 +707,7 @@ wayland_data_read_cb (GObject *object,
{ {
reply_selection_request (&data->request_event, FALSE); reply_selection_request (&data->request_event, FALSE);
g_clear_pointer (&selection->wayland_selection, g_clear_pointer (&selection->wayland_selection,
(GDestroyNotify) wayland_selection_data_free); wayland_selection_data_free);
} }
return; return;
@ -753,7 +753,7 @@ wayland_data_read_cb (GObject *object,
} }
g_clear_pointer (&selection->wayland_selection, g_clear_pointer (&selection->wayland_selection,
(GDestroyNotify) wayland_selection_data_free); wayland_selection_data_free);
} }
} }
@ -868,7 +868,7 @@ meta_x11_source_cancel (MetaWaylandDataSource *source)
x11_selection_data_send_finished (selection, FALSE); x11_selection_data_send_finished (selection, FALSE);
g_clear_pointer (&selection->x11_selection, g_clear_pointer (&selection->x11_selection,
(GDestroyNotify) x11_selection_data_free); x11_selection_data_free);
} }
static void static void
@ -1156,7 +1156,7 @@ meta_xwayland_selection_handle_selection_notify (MetaWaylandCompositor *composit
if (event->property == None) if (event->property == None)
{ {
g_clear_pointer (&selection->x11_selection, g_clear_pointer (&selection->x11_selection,
(GDestroyNotify) x11_selection_data_free); x11_selection_data_free);
return FALSE; return FALSE;
} }
@ -1294,7 +1294,7 @@ meta_xwayland_selection_handle_selection_request (MetaWaylandCompositor *composi
return FALSE; return FALSE;
g_clear_pointer (&selection->wayland_selection, g_clear_pointer (&selection->wayland_selection,
(GDestroyNotify) wayland_selection_data_free); wayland_selection_data_free);
if (event->target == gdk_x11_get_xatom_by_name ("TARGETS")) if (event->target == gdk_x11_get_xatom_by_name ("TARGETS"))
{ {
@ -1609,7 +1609,7 @@ meta_xwayland_selection_handle_xfixes_selection_notify (MetaWaylandCompositor *c
} }
g_clear_pointer (&selection->x11_selection, g_clear_pointer (&selection->x11_selection,
(GDestroyNotify) x11_selection_data_free); x11_selection_data_free);
XConvertSelection (xdisplay, XConvertSelection (xdisplay,
event->selection, event->selection,
@ -1748,9 +1748,9 @@ shutdown_selection_bridge (MetaSelectionBridge *selection)
XDestroyWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XDestroyWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
selection->window); selection->window);
g_clear_pointer (&selection->wayland_selection, g_clear_pointer (&selection->wayland_selection,
(GDestroyNotify) wayland_selection_data_free); wayland_selection_data_free);
g_clear_pointer (&selection->x11_selection, g_clear_pointer (&selection->x11_selection,
(GDestroyNotify) x11_selection_data_free); x11_selection_data_free);
} }
void void