浏览代码

qemu-keymap: Make references to allocations static

LeakSanitizer complains about allocations whose references are held
only by automatic variables. It is possible to free them to suppress
the complaints, but it is a chore to make sure they are freed in all
exit paths so make them static instead.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240524-xkb-v4-1-2de564e5c859@daynix.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Akihiko Odaki 1 年之前
父节点
当前提交
2523baf7fb
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      qemu-keymap.c

+ 3 - 5
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[])
 int main(int argc, char *argv[])
 {
 {
-    struct xkb_context *ctx;
-    struct xkb_keymap *map;
-    struct xkb_state *state;
+    static struct xkb_context *ctx;
+    static struct xkb_keymap *map;
+    static struct xkb_state *state;
     xkb_mod_index_t mod, mods;
     xkb_mod_index_t mod, mods;
     int rc;
     int rc;
 
 
@@ -234,8 +234,6 @@ int main(int argc, char *argv[])
 
 
     state = xkb_state_new(map);
     state = xkb_state_new(map);
     xkb_keymap_key_for_each(map, walk_map, state);
     xkb_keymap_key_for_each(map, walk_map, state);
-    xkb_state_unref(state);
-    state = NULL;
 
 
     /* add quirks */
     /* add quirks */
     fprintf(outfile,
     fprintf(outfile,