mirror of
https://github.com/qemu/qemu.git
synced 2024-11-25 11:53:39 +08:00
qemu-sockets: Simplify setting numeric and boolean options
Don't convert numbers or bools to strings for use with qemu_opt_set(), simply use qemu_opt_set_number() or qemu_opt_set_bool() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
a8b18f8fd2
commit
62b3de6934
@ -199,13 +199,13 @@ listen:
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
}
|
||||
snprintf(uport, sizeof(uport), "%d", inet_getport(e) - port_offset);
|
||||
qemu_opt_set(opts, "host", uaddr, &error_abort);
|
||||
qemu_opt_set(opts, "port", uport, &error_abort);
|
||||
qemu_opt_set(opts, "ipv6", (e->ai_family == PF_INET6) ? "on" : "off",
|
||||
&error_abort);
|
||||
qemu_opt_set(opts, "ipv4", (e->ai_family != PF_INET6) ? "on" : "off",
|
||||
&error_abort);
|
||||
qemu_opt_set_number(opts, "port", inet_getport(e) - port_offset,
|
||||
&error_abort);
|
||||
qemu_opt_set_bool(opts, "ipv6", e->ai_family == PF_INET6,
|
||||
&error_abort);
|
||||
qemu_opt_set_bool(opts, "ipv4", e->ai_family != PF_INET6,
|
||||
&error_abort);
|
||||
freeaddrinfo(res);
|
||||
return slisten;
|
||||
}
|
||||
@ -586,9 +586,7 @@ static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr)
|
||||
qemu_opt_set_bool(opts, "ipv6", ipv6, &error_abort);
|
||||
}
|
||||
if (addr->has_to) {
|
||||
char to[20];
|
||||
snprintf(to, sizeof(to), "%d", addr->to);
|
||||
qemu_opt_set(opts, "to", to, &error_abort);
|
||||
qemu_opt_set_number(opts, "to", addr->to, &error_abort);
|
||||
}
|
||||
qemu_opt_set(opts, "host", addr->host, &error_abort);
|
||||
qemu_opt_set(opts, "port", addr->port, &error_abort);
|
||||
|
Loading…
Reference in New Issue
Block a user