From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQz6K-0007pn-SV for qemu-devel@nongnu.org; Thu, 26 Feb 2015 09:07:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQz6E-0007ZW-Fm for qemu-devel@nongnu.org; Thu, 26 Feb 2015 09:07:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQz6E-0007ZB-8C for qemu-devel@nongnu.org; Thu, 26 Feb 2015 09:07:34 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1QE7XPQ024024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 26 Feb 2015 09:07:33 -0500 Received: from blackfin.pond.sub.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1QE7VA6026730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 26 Feb 2015 09:07:33 -0500 From: Markus Armbruster Date: Thu, 26 Feb 2015 15:07:25 +0100 Message-Id: <1424959648-14721-11-git-send-email-armbru@redhat.com> In-Reply-To: <1424959648-14721-1-git-send-email-armbru@redhat.com> References: <1424959648-14721-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL 10/13] block: Simplify setting numeric options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Don't convert numbers to strings for use with qemu_opt_set(), simply use qemu_opt_set_number() instead. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- blockdev.c | 4 +--- vl.c | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5aa23b5..b9c1c0c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -180,7 +180,6 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr) { QemuOpts *opts; - char buf[32]; opts = drive_def(optstr); if (!opts) { @@ -190,8 +189,7 @@ QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, qemu_opt_set(opts, "if", if_name[type], &error_abort); } if (index >= 0) { - snprintf(buf, sizeof(buf), "%d", index); - qemu_opt_set(opts, "index", buf, &error_abort); + qemu_opt_set_number(opts, "index", index, &error_abort); } if (file) qemu_opt_set(opts, "file", file, &error_abort); diff --git a/vl.c b/vl.c index 66b0ad8..e2c1950 100644 --- a/vl.c +++ b/vl.c @@ -2971,13 +2971,12 @@ int main(int argc, char **argv, char **envp) exit(1); } if (hda_opts != NULL) { - char num[16]; - snprintf(num, sizeof(num), "%d", cyls); - qemu_opt_set(hda_opts, "cyls", num, &error_abort); - snprintf(num, sizeof(num), "%d", heads); - qemu_opt_set(hda_opts, "heads", num, &error_abort); - snprintf(num, sizeof(num), "%d", secs); - qemu_opt_set(hda_opts, "secs", num, &error_abort); + qemu_opt_set_number(hda_opts, "cyls", cyls, + &error_abort); + qemu_opt_set_number(hda_opts, "heads", heads, + &error_abort); + qemu_opt_set_number(hda_opts, "secs", secs, + &error_abort); if (translation == BIOS_ATA_TRANSLATION_LARGE) { qemu_opt_set(hda_opts, "trans", "large", &error_abort); -- 1.9.3