]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tests/x86: replace snprint() by g_strdup_printf() in drive_del-test
authorMichael Labiuk <michael.labiuk@virtuozzo.com>
Thu, 29 Sep 2022 22:35:45 +0000 (01:35 +0300)
committerThomas Huth <thuth@redhat.com>
Tue, 11 Oct 2022 12:06:55 +0000 (14:06 +0200)
Using g_autofree char* and  g_strdup_printf(...) instead of ugly
snprintf on stack array.

Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
Message-Id: <20220929223547.1429580-8-michael.labiuk@virtuozzo.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/qtest/drive_del-test.c

index 44b9578801e3fac099b901ae8a02bdbf5d62ffd9..106c613f4f8af0fa4daa54db028a3f36909f11b9 100644 (file)
@@ -123,12 +123,10 @@ static const char *qvirtio_get_dev_type(void)
 
 static void device_add(QTestState *qts)
 {
-    QDict *response;
-    char driver[32];
-    snprintf(driver, sizeof(driver), "virtio-blk-%s",
-             qvirtio_get_dev_type());
-
-    response = qtest_qmp(qts, "{'execute': 'device_add',"
+    g_autofree char *driver = g_strdup_printf("virtio-blk-%s",
+                                              qvirtio_get_dev_type());
+    QDict *response =
+               qtest_qmp(qts, "{'execute': 'device_add',"
                               " 'arguments': {"
                               "   'driver': %s,"
                               "   'drive': 'drive0',"