[mutter/wip/carlosg/coverity-fixes: 2/12] compositor: Remove dead code
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/coverity-fixes: 2/12] compositor: Remove dead code
- Date: Mon, 25 Oct 2021 13:45:57 +0000 (UTC)
commit 6fcc69062a9373f454beaa11e39eaa4d48aa7d09
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Oct 24 20:00:38 2021 +0200
compositor: Remove dead code
When grabbing the devices, there's no error paths that would quit
late enough that both pointer and keyboard would need ungrabbing,
so the keyboard checks were dead code.
Fix this by dropping the boolean variable checks, and adding goto
labels to unroll the operation properly at every stage.
CID: #1418254
src/compositor/compositor.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 9cdd39c15d..ee6be007b8 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -353,33 +353,24 @@ grab_devices (MetaModalOptions options,
guint32 timestamp)
{
MetaBackend *backend = META_BACKEND (meta_get_backend ());
- gboolean pointer_grabbed = FALSE;
- gboolean keyboard_grabbed = FALSE;
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
{
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp))
goto fail;
-
- pointer_grabbed = TRUE;
}
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
{
if (!meta_backend_grab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp))
- goto fail;
-
- keyboard_grabbed = TRUE;
+ goto ungrab_pointer;
}
return TRUE;
+ ungrab_pointer:
+ meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
fail:
- if (pointer_grabbed)
- meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp);
- if (keyboard_grabbed)
- meta_backend_ungrab_device (backend, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
-
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]