[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/23] qemu-keymap: Release local allocation references
From: |
Michael Tokarev |
Subject: |
[PULL 02/23] qemu-keymap: Release local allocation references |
Date: |
Fri, 4 Oct 2024 19:03:10 +0300 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Commit 2523baf7fb4d ("qemu-keymap: Make references to allocations
static") made references to allocations static to ensure LeakSanitizer
can track them. This trick unfortunately did not work with gcc version
14.0.1; that compiler is clever enough to know that the value of the
"state" variable is only referred in the current execution of the
function and to put it on the stack.
Release references to allocations and suppress the error once for all.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
qemu-keymap.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/qemu-keymap.c b/qemu-keymap.c
index 701e4332af..6707067fea 100644
--- a/qemu-keymap.c
+++ b/qemu-keymap.c
@@ -154,9 +154,9 @@ static xkb_mod_mask_t get_mod(struct xkb_keymap *map, const
char *name)
int main(int argc, char *argv[])
{
- static struct xkb_context *ctx;
- static struct xkb_keymap *map;
- static struct xkb_state *state;
+ struct xkb_context *ctx;
+ struct xkb_keymap *map;
+ struct xkb_state *state;
xkb_mod_index_t mod, mods;
int rc;
@@ -213,6 +213,7 @@ int main(int argc, char *argv[])
ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
map = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ xkb_context_unref(ctx);
if (!map) {
/* libxkbcommon prints error */
exit(1);
@@ -234,6 +235,8 @@ int main(int argc, char *argv[])
state = xkb_state_new(map);
xkb_keymap_key_for_each(map, walk_map, state);
+ xkb_state_unref(state);
+ xkb_keymap_unref(map);
/* add quirks */
fprintf(outfile,
--
2.39.5
- [PULL 00/23] Trivial patches for 2024-10-04, Michael Tokarev, 2024/10/04
- [PULL 01/23] hw/audio/virtio-snd: Remove unnecessary "exec/tswap.h" header, Michael Tokarev, 2024/10/04
- [PULL 02/23] qemu-keymap: Release local allocation references,
Michael Tokarev <=
- [PULL 05/23] hw/xen: Remove deadcode, Michael Tokarev, 2024/10/04
- [PULL 07/23] net: Remove deadcode, Michael Tokarev, 2024/10/04
- [PULL 06/23] q35: Remove unused mch_mcfg_base, Michael Tokarev, 2024/10/04
- [PULL 08/23] hw/net/net_rx_pkt: Remove deadcode, Michael Tokarev, 2024/10/04
- [PULL 03/23] vnc: fix crash when no console attached, Michael Tokarev, 2024/10/04
- [PULL 10/23] linux-user: Remove unused handle_vm86_fault, Michael Tokarev, 2024/10/04
- [PULL 04/23] MAINTAINERS: remove gensyscalls.sh from the linux-user section, Michael Tokarev, 2024/10/04
- [PULL 09/23] hw/char: Remove unused serial_set_frequency, Michael Tokarev, 2024/10/04