[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_regio
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region() |
Date: |
Wed, 15 Jul 2020 19:58:31 +0200 |
Use the safer g_strdup_printf() over snprintf() + abort().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/qdev-properties.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 098298c78e..d5f5aa150b 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -581,13 +581,10 @@ static void get_reserved_region(Object *obj, Visitor *v,
const char *name,
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
ReservedRegion *rr = qdev_get_prop_ptr(dev, prop);
- char buffer[64];
- char *p = buffer;
- int rc;
+ g_autofree char *p;
- rc = snprintf(buffer, sizeof(buffer), "0x%"PRIx64":0x%"PRIx64":%u",
- rr->low, rr->high, rr->type);
- assert(rc < sizeof(buffer));
+ p = g_strdup_printf("0x%"PRIx64":0x%"PRIx64":%u",
+ rr->low, rr->high, rr->type);
visit_type_str(v, name, &p, errp);
}
--
2.21.3
- [RFC PATCH-for-5.2 0/5] qom: Let ObjectPropertyGet functions return a boolean value, Philippe Mathieu-Daudé, 2020/07/15
- [PATCH-for-5.2 1/5] hw/core/qdev-properties: Simplify get_reserved_region(),
Philippe Mathieu-Daudé <=
- [RFC PATCH-for-5.2 2/5] qom: Split ObjectPropertyAccessor as ObjectProperty[Get/Set], Philippe Mathieu-Daudé, 2020/07/15
- [PATCH-for-5.2 3/5] qom: Use g_autofree in ObjectPropertyGet functions, Philippe Mathieu-Daudé, 2020/07/15
- [RFC PATCH-for-5.2 5/5] hw/virtio: Simplify virtio_mem_set_requested_size(), Philippe Mathieu-Daudé, 2020/07/15
- [RFC PATCH-for-5.2 4/5] qom: Let ObjectPropertyGet functions return a boolean value, Philippe Mathieu-Daudé, 2020/07/15
- Re: [RFC PATCH-for-5.2 0/5] qom: Let ObjectPropertyGet functions return a boolean value, Markus Armbruster, 2020/07/16