qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/6] qdev/prop: make uint32 accept both hex and deci


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 1/6] qdev/prop: make uint32 accept both hex and decimal.
Date: Mon, 13 Jul 2009 11:36:00 +0200

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]