From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQLLO-0005ZM-GF for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:13:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQLLJ-0005VI-KC for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:13:21 -0400 Received: from [199.232.76.173] (port=48472 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQLLJ-0005VC-Eu for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:13:17 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53900) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQLLJ-0004i5-3g for qemu-devel@nongnu.org; Mon, 13 Jul 2009 09:13:17 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6DDDGrD006253 for ; Mon, 13 Jul 2009 09:13:16 -0400 From: Gerd Hoffmann Date: Mon, 13 Jul 2009 15:13:04 +0200 Message-Id: <1247490790-15783-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1247490790-15783-1-git-send-email-kraxel@redhat.com> References: <1247490790-15783-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/7] qdev/prop: make uint32 accept both hex and decimal. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- hw/qdev-properties.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index b4f4f21..cf1ad22 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -12,8 +12,11 @@ static void *prop_ptr(DeviceState *dev, Property *prop) static int parse_uint32(DeviceState *dev, Property *prop, const char *str) { uint32_t *ptr = prop_ptr(dev, prop); + const char *fmt; - if (sscanf(str, "%" PRIu32, ptr) != 1) + /* accept both hex and decimal */ + fmt = strncasecmp(str, "0x",2) == 0 ? "%" PRIx32 : "%" PRIu32; + if (sscanf(str, fmt, ptr) != 1) return -1; return 0; } -- 1.6.2.5