aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-sockets.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-02-13 15:51:56 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-02-26 14:51:53 +0100
commit62b3de693469508a58864bffefd3d54f897558b4 (patch)
treebd10f768c2950d07784b30b5bc2ac35fc0ee0e00 /util/qemu-sockets.c
parenta8b18f8fd2d9f0df33c3739e76fedfd9355dfa8b (diff)
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>
Diffstat (limited to 'util/qemu-sockets.c')
-rw-r--r--util/qemu-sockets.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index e9085237c6..87c9bc6c68 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -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);