diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-02-08 11:01:52 +0100 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2014-02-14 21:12:03 +0100 |
commit | 515f23462b10174c953fd161a37e9093b2427cff (patch) | |
tree | e60a4981f73c96b113d48aa2ff38ce8581e4e198 /hw/core | |
parent | dae3bda422340901742e4db6b471d3084dfdc84d (diff) |
qdev: Remove most legacy printers
Their functionality is either aesthetic only (e.g. on/off vs. true/false)
or obtained by the "human mode" of StringOutputVisitor.
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/qdev-properties.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 22ddebf92a..a4f1f78e6c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -74,13 +74,6 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val) } } -static int prop_print_bit(DeviceState *dev, Property *prop, char *dest, - size_t len) -{ - uint32_t *p = qdev_get_prop_ptr(dev, prop); - return snprintf(dest, len, (*p & qdev_get_prop_mask(prop)) ? "on" : "off"); -} - static void prop_get_bit(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { @@ -116,7 +109,6 @@ static void prop_set_bit(Object *obj, Visitor *v, void *opaque, PropertyInfo qdev_prop_bit = { .name = "boolean", .legacy_name = "on/off", - .print = prop_print_bit, .get = prop_get_bit, .set = prop_set_bit, }; @@ -189,16 +181,9 @@ PropertyInfo qdev_prop_uint8 = { /* --- 8bit hex value --- */ -static int print_hex8(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - uint8_t *ptr = qdev_get_prop_ptr(dev, prop); - return snprintf(dest, len, "0x%" PRIx8, *ptr); -} - PropertyInfo qdev_prop_hex8 = { .name = "uint8", .legacy_name = "hex8", - .print = print_hex8, .get = get_uint8, .set = set_uint8, }; @@ -302,16 +287,9 @@ PropertyInfo qdev_prop_int32 = { /* --- 32bit hex value --- */ -static int print_hex32(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - uint32_t *ptr = qdev_get_prop_ptr(dev, prop); - return snprintf(dest, len, "0x%" PRIx32, *ptr); -} - PropertyInfo qdev_prop_hex32 = { .name = "uint32", .legacy_name = "hex32", - .print = print_hex32, .get = get_uint32, .set = set_uint32, }; @@ -351,16 +329,9 @@ PropertyInfo qdev_prop_uint64 = { /* --- 64bit hex value --- */ -static int print_hex64(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - uint64_t *ptr = qdev_get_prop_ptr(dev, prop); - return snprintf(dest, len, "0x%" PRIx64, *ptr); -} - PropertyInfo qdev_prop_hex64 = { .name = "uint64", .legacy_name = "hex64", - .print = print_hex64, .get = get_uint64, .set = set_uint64, }; @@ -373,16 +344,6 @@ static void release_string(Object *obj, const char *name, void *opaque) g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj), prop)); } -static int print_string(DeviceState *dev, Property *prop, char *dest, - size_t len) -{ - char **ptr = qdev_get_prop_ptr(dev, prop); - if (!*ptr) { - return snprintf(dest, len, "<null>"); - } - return snprintf(dest, len, "\"%s\"", *ptr); -} - static void get_string(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { @@ -425,7 +386,6 @@ static void set_string(Object *obj, Visitor *v, void *opaque, PropertyInfo qdev_prop_string = { .name = "string", - .print = print_string, .release = release_string, .get = get_string, .set = set_string, @@ -1072,28 +1032,8 @@ static void set_size(Object *obj, Visitor *v, void *opaque, visit_type_size(v, ptr, name, errp); } -static int print_size(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T' }; - uint64_t div, val = *(uint64_t *)qdev_get_prop_ptr(dev, prop); - int i; - - /* Compute floor(log2(val)). */ - i = 64 - clz64(val); - - /* Find the power of 1024 that we'll display as the units. */ - i /= 10; - if (i >= ARRAY_SIZE(suffixes)) { - i = ARRAY_SIZE(suffixes) - 1; - } - div = 1ULL << (i * 10); - - return snprintf(dest, len, "%0.03f%c", (double)val/div, suffixes[i]); -} - PropertyInfo qdev_prop_size = { .name = "size", - .print = print_size, .get = get_size, .set = set_size, }; |