From 0b812f31925f2ed50eb54d2be6ac9291bf67b890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 21 Oct 2016 16:07:45 +0300 Subject: char: use a const CharDriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to allocate & copy fields, let's use static const struct instead. Add an alias field to the CharDriver structure to cover the cases where we previously registered a driver twice under two names. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- spice-qemu-char.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'spice-qemu-char.c') diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 276c4aef68..30db420e2f 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -389,10 +389,18 @@ static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend, static void register_types(void) { - register_char_driver("spicevmc", CHARDEV_BACKEND_KIND_SPICEVMC, - qemu_chr_parse_spice_vmc, qemu_chr_open_spice_vmc); - register_char_driver("spiceport", CHARDEV_BACKEND_KIND_SPICEPORT, - qemu_chr_parse_spice_port, qemu_chr_open_spice_port); + static const CharDriver vmc_driver = { + .kind = CHARDEV_BACKEND_KIND_SPICEVMC, + .parse = qemu_chr_parse_spice_vmc, + .create = qemu_chr_open_spice_vmc, + }; + static const CharDriver port_driver = { + .kind = CHARDEV_BACKEND_KIND_SPICEPORT, + .parse = qemu_chr_parse_spice_port, + .create = qemu_chr_open_spice_port, + }; + register_char_driver(&vmc_driver); + register_char_driver(&port_driver); } type_init(register_types); -- cgit v1.2.3