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

[Xen-devel] [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF



The rune is

  sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl.c            | 170 ++++++++++++++++++++---------------------
 tools/libxl/libxl_blktap2.c    |   4 +-
 tools/libxl/libxl_bootloader.c |  10 +--
 tools/libxl/libxl_create.c     |  40 +++++-----
 tools/libxl/libxl_dm.c         |  80 +++++++++----------
 tools/libxl/libxl_internal.c   |   4 +-
 tools/libxl/libxl_pci.c        |  92 +++++++++++-----------
 tools/libxl/libxl_xshelp.c     |   4 +-
 8 files changed, 202 insertions(+), 202 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 854e957..9f52cc2 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -389,7 +389,7 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     dom_path = libxl__xs_get_dompath(gc, domid);
     if (!dom_path) goto x_nomem;
 
-    name_path= libxl__sprintf(gc, "%s/name", dom_path);
+    name_path= GCSPRINTF("%s/name", dom_path);
     if (!name_path) goto x_nomem;
 
     stub_dm_domid = libxl_get_stubdom_id(CTX, domid);
@@ -557,7 +557,7 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
 
     int rc;
 
-    preserved_name = libxl__sprintf(gc, "%s%s", info->name, name_suffix);
+    preserved_name = GCSPRINTF("%s%s", info->name, name_suffix);
     if (!preserved_name) {
         GC_FREE;
         return ERROR_NOMEM;
@@ -575,7 +575,7 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
         return ERROR_FAIL;
     }
 
-    vm_path = libxl__sprintf(gc, "/vm/%s", uuid_string);
+    vm_path = GCSPRINTF("/vm/%s", uuid_string);
     if (!vm_path) {
         GC_FREE;
         return ERROR_FAIL;
@@ -593,14 +593,14 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid,
     xs_mkdir(ctx->xsh, t, vm_path);
     xs_set_permissions(ctx->xsh, t, vm_path, roperm, ARRAY_SIZE(roperm));
 
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path), vm_path, 
strlen(vm_path));
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/vm", dom_path), vm_path, 
strlen(vm_path));
     rc = libxl__domain_rename(gc, domid, info->name, preserved_name, t);
     if (rc) {
         GC_FREE;
         return rc;
     }
 
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/uuid", vm_path), uuid_string, 
strlen(uuid_string));
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/uuid", vm_path), uuid_string, 
strlen(uuid_string));
 
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
@@ -1374,7 +1374,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, 
libxl__ev_xswatch *w,
     libxl_device_disk *disk = &ev->u.disk_eject.disk;
     
     backend = libxl__xs_read(gc, XBT_NULL,
-                             libxl__sprintf(gc, "%.*s/backend",
+                             GCSPRINTF("%.*s/backend",
                                             (int)strlen(wpath)-6, wpath));
 
     sscanf(backend,
@@ -1393,7 +1393,7 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, 
libxl__ev_xswatch *w,
     disk->format = LIBXL_DISK_FORMAT_EMPTY;
     /* this value is returned to the user: do not free right away */
     disk->vdev = xs_read(CTX->xsh, XBT_NULL,
-                         libxl__sprintf(gc, "%s/dev", backend), NULL);
+                         GCSPRINTF("%s/dev", backend), NULL);
     disk->removable = 1;
     disk->readwrite = 0;
     disk->is_cdrom = 1;
@@ -1424,7 +1424,7 @@ int libxl_evenable_disk_eject(libxl_ctx *ctx, uint32_t 
guest_domid,
     if (!domid)
         domid = guest_domid;
 
-    path = libxl__sprintf(gc, "%s/device/vbd/%d/eject",
+    path = GCSPRINTF("%s/device/vbd/%d/eject",
                  libxl__xs_get_dompath(gc, domid),
                  libxl__device_disk_dev_number(vdev, NULL, NULL));
     if (!path) { rc = ERROR_NOMEM; goto out; }
@@ -1622,7 +1622,7 @@ void libxl__destroy_domid(libxl__egc *egc, 
libxl__destroy_domid_state *dis)
             dm_present = 0;
         break;
     case LIBXL_DOMAIN_TYPE_PV:
-        pid = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, 
"/local/domain/%d/image/device-model-pid", domid));
+        pid = libxl__xs_read(gc, XBT_NULL, 
GCSPRINTF("/local/domain/%d/image/device-model-pid", domid));
         dm_present = (pid != NULL);
         break;
     case LIBXL_DOMAIN_TYPE_INVALID:
@@ -1684,7 +1684,7 @@ static void devices_destroy_cb(libxl__egc *egc,
     if (rc < 0)
         LOG(ERROR, "libxl__devices_destroy failed for %d", domid);
 
-    vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/vm", 
dom_path));
+    vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path));
     if (vm_path)
         if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
             LOGE(ERROR, "xs_rm failed for %s", vm_path);
@@ -1786,9 +1786,9 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, 
int cons_num,
                        libxl_console_type type)
 {
     GC_INIT(ctx);
-    char *p = libxl__sprintf(gc, "%s/xenconsole", 
libxl__private_bindir_path());
-    char *domid_s = libxl__sprintf(gc, "%d", domid);
-    char *cons_num_s = libxl__sprintf(gc, "%d", cons_num);
+    char *p = GCSPRINTF("%s/xenconsole", libxl__private_bindir_path());
+    char *domid_s = GCSPRINTF("%d", domid);
+    char *cons_num_s = GCSPRINTF("%d", cons_num);
     char *cons_type_s;
 
     switch (type) {
@@ -1954,7 +1954,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, 
int autopass)
     if ( (vnc_bin = getenv("VNCVIEWER")) )
         args[0] = vnc_bin;
 
-    args[1] = libxl__sprintf(gc, "%s:%d", vnc_listen, port);
+    args[1] = GCSPRINTF("%s:%d", vnc_listen, port);
 
     if ( vnc_pass ) {
         char tmpname[] = "/tmp/vncautopass.XXXXXX";
@@ -2214,7 +2214,7 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, 
uint32_t domid, int *n
 
     *num = 0;
 
-    fe_path = libxl__sprintf(gc, "%s/device/vtpm", libxl__xs_get_dompath(gc, 
domid));
+    fe_path = GCSPRINTF("%s/device/vtpm", libxl__xs_get_dompath(gc, domid));
     dir = libxl__xs_directory(gc, XBT_NULL, fe_path, &ndirs);
     if (dir && ndirs) {
        vtpms = malloc(sizeof(*vtpms) * ndirs);
@@ -2522,7 +2522,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
domid,
                     int major, minor;
                     if (!libxl__device_physdisk_major_minor(dev, &major, 
&minor))
                         flexarray_append_pair(back, "physical-device",
-                                              libxl__sprintf(gc, "%x:%x", 
major, minor));
+                                              GCSPRINTF("%x:%x", major, 
minor));
                 }
 
                 assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD);
@@ -2540,7 +2540,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
domid,
                     }
                 }
                 flexarray_append(back, "tapdisk-params");
-                flexarray_append(back, libxl__sprintf(gc, "%s:%s",
+                flexarray_append(back, GCSPRINTF("%s:%s",
                     libxl__device_disk_string_of_format(disk->format),
                     disk->pdev_path));
 
@@ -2552,7 +2552,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
domid,
                 goto do_backend_phy;
             case LIBXL_DISK_BACKEND_QDISK:
                 flexarray_append(back, "params");
-                flexarray_append(back, libxl__sprintf(gc, "%s:%s",
+                flexarray_append(back, GCSPRINTF("%s:%s",
                               
libxl__device_disk_string_of_format(disk->format), disk->pdev_path));
                 assert(device->backend_kind == LIBXL__DEVICE_KIND_QDISK);
                 break;
@@ -2564,13 +2564,13 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
domid,
         }
 
         flexarray_append(back, "frontend-id");
-        flexarray_append(back, libxl__sprintf(gc, "%d", domid));
+        flexarray_append(back, GCSPRINTF("%d", domid));
         flexarray_append(back, "online");
         flexarray_append(back, "1");
         flexarray_append(back, "removable");
-        flexarray_append(back, libxl__sprintf(gc, "%d", (disk->removable) ? 1 
: 0));
+        flexarray_append(back, GCSPRINTF("%d", (disk->removable) ? 1 : 0));
         flexarray_append(back, "bootable");
-        flexarray_append(back, libxl__sprintf(gc, "%d", 1));
+        flexarray_append(back, GCSPRINTF("%d", 1));
         flexarray_append(back, "state");
         flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising));
         flexarray_append(back, "dev");
@@ -2590,11 +2590,11 @@ static void device_disk_add(libxl__egc *egc, uint32_t 
domid,
                               "1" : "0");
 
         flexarray_append(front, "backend-id");
-        flexarray_append(front, libxl__sprintf(gc, "%d", disk->backend_domid));
+        flexarray_append(front, GCSPRINTF("%d", disk->backend_domid));
         flexarray_append(front, "state");
         flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
         flexarray_append(front, "virtual-device");
-        flexarray_append(front, libxl__sprintf(gc, "%d", device->devid));
+        flexarray_append(front, GCSPRINTF("%d", device->devid));
         flexarray_append(front, "device-type");
         flexarray_append(front, disk->is_cdrom ? "cdrom" : "disk");
 
@@ -2671,7 +2671,7 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
 
     /* "params" may not be present; but everything else must be. */
     tmp = xs_read(ctx->xsh, XBT_NULL,
-                  libxl__sprintf(gc, "%s/params", be_path), &len);
+                  GCSPRINTF("%s/params", be_path), &len);
     if (tmp && strchr(tmp, ':')) {
         disk->pdev_path = strdup(strchr(tmp, ':') + 1);
         free(tmp);
@@ -2681,7 +2681,7 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
 
 
     tmp = libxl__xs_read(gc, XBT_NULL,
-                         libxl__sprintf(gc, "%s/type", be_path));
+                         GCSPRINTF("%s/type", be_path));
     if (!tmp) {
         LOG(ERROR, "Missing xenstore node %s/type", be_path);
         goto cleanup;
@@ -2689,7 +2689,7 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
     libxl_string_to_backend(ctx, tmp, &(disk->backend));
 
     disk->vdev = xs_read(ctx->xsh, XBT_NULL,
-                         libxl__sprintf(gc, "%s/dev", be_path), &len);
+                         GCSPRINTF("%s/dev", be_path), &len);
     if (!disk->vdev) {
         LOG(ERROR, "Missing xenstore node %s/dev", be_path);
         goto cleanup;
@@ -2703,7 +2703,7 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
     }
     disk->removable = atoi(tmp);
 
-    tmp = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/mode", be_path));
+    tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/mode", be_path));
     if (!tmp) {
         LOG(ERROR, "Missing xenstore node %s/mode", be_path);
         goto cleanup;
@@ -2714,7 +2714,7 @@ static int libxl__device_disk_from_xs_be(libxl__gc *gc,
         disk->readwrite = 0;
 
     tmp = libxl__xs_read(gc, XBT_NULL,
-                         libxl__sprintf(gc, "%s/device-type", be_path));
+                         GCSPRINTF("%s/device-type", be_path));
     if (!tmp) {
         LOG(ERROR, "Missing xenstore node %s/device-type", be_path);
         goto cleanup;
@@ -2747,7 +2747,7 @@ int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t 
domid,
         goto out;
     }
     path = libxl__xs_read(gc, XBT_NULL,
-                          libxl__sprintf(gc, "%s/device/vbd/%d/backend",
+                          GCSPRINTF("%s/device/vbd/%d/backend",
                                          dompath, devid));
     if (!path)
         goto out;
@@ -2772,7 +2772,7 @@ static int libxl__append_disk_list_of_type(libxl__gc *gc,
     int rc=0;
     int initial_disks = *ndisks;
 
-    be_path = libxl__sprintf(gc, "%s/backend/%s/%d",
+    be_path = GCSPRINTF("%s/backend/%s/%d",
                              libxl__xs_get_dompath(gc, 0), type, domid);
     dir = libxl__xs_directory(gc, XBT_NULL, be_path, &n);
     if (dir && n) {
@@ -2785,7 +2785,7 @@ static int libxl__append_disk_list_of_type(libxl__gc *gc,
         pdisk_end = *disks + initial_disks + n;
         for (; pdisk < pdisk_end; pdisk++, dir++) {
             const char *p;
-            p = libxl__sprintf(gc, "%s/%s", be_path, *dir);
+            p = GCSPRINTF("%s/%s", be_path, *dir);
             if ((rc=libxl__device_disk_from_xs_be(gc, p, pdisk)))
                 goto out;
             pdisk->backend_domid = 0;
@@ -2837,24 +2837,24 @@ int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t 
domid,
     diskinfo->devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
 
     /* tap devices entries in xenstore are written as vbd devices. */
-    diskpath = libxl__sprintf(gc, "%s/device/vbd/%d", dompath, 
diskinfo->devid);
+    diskpath = GCSPRINTF("%s/device/vbd/%d", dompath, diskinfo->devid);
     diskinfo->backend = xs_read(ctx->xsh, XBT_NULL,
-                                libxl__sprintf(gc, "%s/backend", diskpath), 
NULL);
+                                GCSPRINTF("%s/backend", diskpath), NULL);
     if (!diskinfo->backend) {
         GC_FREE;
         return ERROR_FAIL;
     }
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend-id", 
diskpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/backend-id", diskpath));
     diskinfo->backend_id = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/state", 
diskpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", diskpath));
     diskinfo->state = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/event-channel", 
diskpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/event-channel", 
diskpath));
     diskinfo->evtch = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/ring-ref", 
diskpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/ring-ref", diskpath));
     diskinfo->rref = val ? strtoul(val, NULL, 10) : -1;
     diskinfo->frontend = xs_read(ctx->xsh, XBT_NULL,
-                                 libxl__sprintf(gc, "%s/frontend", 
diskinfo->backend), NULL);
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/frontend-id", 
diskinfo->backend));
+                                 GCSPRINTF("%s/frontend", diskinfo->backend), 
NULL);
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/frontend-id", 
diskinfo->backend));
     diskinfo->frontend_id = val ? strtoul(val, NULL, 10) : -1;
 
     GC_FREE;
@@ -2977,11 +2977,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
         rc = libxl__xs_transaction_start(gc, &t);
         if (rc) goto out;
         /* Sanity check: make sure the backend exists before writing here */
-        tmp = libxl__xs_read(gc, t, libxl__sprintf(gc, "%s/frontend", path));
+        tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/frontend", path));
         if (!tmp)
         {
             LOG(ERROR, "Internal error: %s does not exist",
-                libxl__sprintf(gc, "%s/frontend", path));
+                GCSPRINTF("%s/frontend", path));
             rc = ERROR_FAIL;
             goto out;
         }
@@ -3009,11 +3009,11 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
         rc = libxl__xs_transaction_start(gc, &t);
         if (rc) goto out;
         /* Sanity check: make sure the backend exists before writing here */
-        tmp = libxl__xs_read(gc, t, libxl__sprintf(gc, "%s/frontend", path));
+        tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/frontend", path));
         if (!tmp)
         {
             LOG(ERROR, "Internal error: %s does not exist",
-                libxl__sprintf(gc, "%s/frontend", path));
+                GCSPRINTF("%s/frontend", path));
             rc = ERROR_FAIL;
             goto out;
         }
@@ -3071,7 +3071,7 @@ static char * libxl__alloc_vdev(libxl__gc *gc, void 
*get_vdev_user,
         if (devid < 0)
             return NULL;
         if (libxl__xs_read(gc, t,
-                    libxl__sprintf(gc, "%s/device/vbd/%d/backend",
+                    GCSPRINTF("%s/device/vbd/%d/backend",
                         dompath, devid)) == NULL) {
             if (errno == ENOENT)
                 return libxl__devid_to_localdev(gc, devid);
@@ -3349,7 +3349,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t 
domid,
     if ( rc != 0 ) goto out;
 
     flexarray_append(back, "frontend-id");
-    flexarray_append(back, libxl__sprintf(gc, "%d", domid));
+    flexarray_append(back, GCSPRINTF("%d", domid));
     flexarray_append(back, "online");
     flexarray_append(back, "1");
     flexarray_append(back, "state");
@@ -3378,7 +3378,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t 
domid,
 
     if (nic->rate_interval_usecs > 0) {
         flexarray_append(back, "rate");
-        flexarray_append(back, libxl__sprintf(gc, "%"PRIu64",%"PRIu32"",
+        flexarray_append(back, GCSPRINTF("%"PRIu64",%"PRIu32"",
                             nic->rate_bytes_per_interval,
                             nic->rate_interval_usecs));
     }
@@ -3386,17 +3386,17 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t 
domid,
     flexarray_append(back, "bridge");
     flexarray_append(back, libxl__strdup(gc, nic->bridge));
     flexarray_append(back, "handle");
-    flexarray_append(back, libxl__sprintf(gc, "%d", nic->devid));
+    flexarray_append(back, GCSPRINTF("%d", nic->devid));
     flexarray_append(back, "type");
     flexarray_append(back, libxl__strdup(gc,
                                      libxl_nic_type_to_string(nic->nictype)));
 
     flexarray_append(front, "backend-id");
-    flexarray_append(front, libxl__sprintf(gc, "%d", nic->backend_domid));
+    flexarray_append(front, GCSPRINTF("%d", nic->backend_domid));
     flexarray_append(front, "state");
     flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
     flexarray_append(front, "handle");
-    flexarray_append(front, libxl__sprintf(gc, "%d", nic->devid));
+    flexarray_append(front, GCSPRINTF("%d", nic->devid));
     flexarray_append(front, "mac");
     flexarray_append(front, libxl__sprintf(gc,
                                     LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac)));
@@ -3517,7 +3517,7 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t 
domid,
         goto out;
 
     path = libxl__xs_read(gc, XBT_NULL,
-                          libxl__sprintf(gc, "%s/device/vif/%d/backend",
+                          GCSPRINTF("%s/device/vif/%d/backend",
                                          dompath, devid));
     if (!path)
         goto out;
@@ -3543,7 +3543,7 @@ static int libxl__append_nic_list_of_type(libxl__gc *gc,
     libxl_device_nic *pnic = NULL, *pnic_end = NULL;
     int rc;
 
-    be_path = libxl__sprintf(gc, "%s/backend/%s/%d",
+    be_path = GCSPRINTF("%s/backend/%s/%d",
                              libxl__xs_get_dompath(gc, 0), type, domid);
     dir = libxl__xs_directory(gc, XBT_NULL, be_path, &n);
     if (dir && n) {
@@ -3556,7 +3556,7 @@ static int libxl__append_nic_list_of_type(libxl__gc *gc,
         pnic_end = *nics + *nnics + n;
         for (; pnic < pnic_end; pnic++, dir++) {
             const char *p;
-            p = libxl__sprintf(gc, "%s/%s", be_path, *dir);
+            p = GCSPRINTF("%s/%s", be_path, *dir);
             rc = libxl__device_nic_from_xs_be(gc, p, pnic);
             if (rc) goto out;
             pnic->backend_domid = 0;
@@ -3603,26 +3603,26 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t 
domid,
     dompath = libxl__xs_get_dompath(gc, domid);
     nicinfo->devid = nic->devid;
 
-    nicpath = libxl__sprintf(gc, "%s/device/vif/%d", dompath, nicinfo->devid);
+    nicpath = GCSPRINTF("%s/device/vif/%d", dompath, nicinfo->devid);
     nicinfo->backend = xs_read(ctx->xsh, XBT_NULL,
-                                libxl__sprintf(gc, "%s/backend", nicpath), 
NULL);
+                                GCSPRINTF("%s/backend", nicpath), NULL);
     if (!nicinfo->backend) {
         GC_FREE;
         return ERROR_FAIL;
     }
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend-id", 
nicpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/backend-id", nicpath));
     nicinfo->backend_id = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/state", 
nicpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", nicpath));
     nicinfo->state = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/event-channel", 
nicpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/event-channel", nicpath));
     nicinfo->evtch = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/tx-ring-ref", 
nicpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/tx-ring-ref", nicpath));
     nicinfo->rref_tx = val ? strtoul(val, NULL, 10) : -1;
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/rx-ring-ref", 
nicpath));
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/rx-ring-ref", nicpath));
     nicinfo->rref_rx = val ? strtoul(val, NULL, 10) : -1;
     nicinfo->frontend = xs_read(ctx->xsh, XBT_NULL,
-                                 libxl__sprintf(gc, "%s/frontend", 
nicinfo->backend), NULL);
-    val = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/frontend-id", 
nicinfo->backend));
+                                 GCSPRINTF("%s/frontend", nicinfo->backend), 
NULL);
+    val = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/frontend-id", 
nicinfo->backend));
     nicinfo->frontend_id = val ? strtoul(val, NULL, 10) : -1;
 
     GC_FREE;
@@ -3676,7 +3676,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t 
domid,
     device->kind = LIBXL__DEVICE_KIND_CONSOLE;
 
     flexarray_append(back, "frontend-id");
-    flexarray_append(back, libxl__sprintf(gc, "%d", domid));
+    flexarray_append(back, GCSPRINTF("%d", domid));
     flexarray_append(back, "online");
     flexarray_append(back, "1");
     flexarray_append(back, "state");
@@ -3698,10 +3698,10 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t 
domid,
     }
 
     flexarray_append(front, "backend-id");
-    flexarray_append(front, libxl__sprintf(gc, "%d", console->backend_domid));
+    flexarray_append(front, GCSPRINTF("%d", console->backend_domid));
 
     flexarray_append(ro_front, "limit");
-    flexarray_append(ro_front, libxl__sprintf(gc, "%d", 
LIBXL_XENCONSOLE_LIMIT));
+    flexarray_append(ro_front, GCSPRINTF("%d", LIBXL_XENCONSOLE_LIMIT));
     flexarray_append(ro_front, "type");
     if (console->consback == LIBXL__CONSOLE_BACKEND_XENCONSOLED)
         flexarray_append(ro_front, "xenconsoled");
@@ -3716,7 +3716,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t 
domid,
         flexarray_append(ro_front, "port");
         flexarray_append(ro_front, libxl__sprintf(gc, "%"PRIu32, 
state->console_port));
         flexarray_append(ro_front, "ring-ref");
-        flexarray_append(ro_front, libxl__sprintf(gc, "%lu", 
state->console_mfn));
+        flexarray_append(ro_front, GCSPRINTF("%lu", state->console_mfn));
     } else {
         flexarray_append(front, "state");
         flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
@@ -3847,7 +3847,7 @@ static int libxl__append_channel_list_of_type(libxl__gc 
*gc,
         const char *p, *name;
         libxl_device_channel *tmp;
 
-        p = libxl__sprintf(gc, "%s/%s", fe_path, dir[i]);
+        p = GCSPRINTF("%s/%s", fe_path, dir[i]);
         name = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/name", p));
         /* 'channels' are consoles with names, so ignore all consoles
            without names */
@@ -3910,10 +3910,10 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, 
uint32_t domid,
     dompath = libxl__xs_get_dompath(gc, domid);
     channelinfo->devid = channel->devid;
 
-    fe_path = libxl__sprintf(gc, "%s/device/console/%d", dompath,
+    fe_path = GCSPRINTF("%s/device/console/%d", dompath,
                              channelinfo->devid + 1);
     channelinfo->backend = xs_read(ctx->xsh, XBT_NULL,
-                                   libxl__sprintf(gc, "%s/backend",
+                                   GCSPRINTF("%s/backend",
                                    fe_path), NULL);
     if (!channelinfo->backend) {
         GC_FREE;
@@ -4012,14 +4012,14 @@ int libxl__device_vkb_add(libxl__gc *gc, uint32_t domid,
     if (rc != 0) goto out;
 
     flexarray_append(back, "frontend-id");
-    flexarray_append(back, libxl__sprintf(gc, "%d", domid));
+    flexarray_append(back, GCSPRINTF("%d", domid));
     flexarray_append(back, "online");
     flexarray_append(back, "1");
     flexarray_append(back, "state");
     flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising));
 
     flexarray_append(front, "backend-id");
-    flexarray_append(front, libxl__sprintf(gc, "%d", vkb->backend_domid));
+    flexarray_append(front, GCSPRINTF("%d", vkb->backend_domid));
     flexarray_append(front, "state");
     flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
 
@@ -4110,7 +4110,7 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, 
libxl_device_vfb *vfb)
     rc = libxl__device_from_vfb(gc, domid, vfb, &device);
     if (rc != 0) goto out;
 
-    flexarray_append_pair(back, "frontend-id", libxl__sprintf(gc, "%d", 
domid));
+    flexarray_append_pair(back, "frontend-id", GCSPRINTF("%d", domid));
     flexarray_append_pair(back, "online", "1");
     flexarray_append_pair(back, "state", GCSPRINTF("%d", 
XenbusStateInitialising));
     flexarray_append_pair(back, "vnc",
@@ -4118,7 +4118,7 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, 
libxl_device_vfb *vfb)
     flexarray_append_pair(back, "vnclisten", vfb->vnc.listen);
     flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd);
     flexarray_append_pair(back, "vncdisplay",
-                          libxl__sprintf(gc, "%d", vfb->vnc.display));
+                          GCSPRINTF("%d", vfb->vnc.display));
     flexarray_append_pair(back, "vncunused",
                           libxl_defbool_val(vfb->vnc.findunused) ? "1" : "0");
     flexarray_append_pair(back, "sdl",
@@ -4133,7 +4133,7 @@ int libxl__device_vfb_add(libxl__gc *gc, uint32_t domid, 
libxl_device_vfb *vfb)
     }
 
     flexarray_append_pair(front, "backend-id",
-                          libxl__sprintf(gc, "%d", vfb->backend_domid));
+                          GCSPRINTF("%d", vfb->backend_domid));
     flexarray_append_pair(front, "state", GCSPRINTF("%d", 
XenbusStateInitialising));
 
     libxl__device_generic_add(gc, XBT_NULL, &device,
@@ -4614,7 +4614,7 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t 
domid, uint32_t max_memkb)
         goto out;
     }
 
-    mem = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/memory/target", 
dompath));
+    mem = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/memory/target", dompath));
     if (!mem) {
         LOGE(ERROR, "cannot get memory info from %s/memory/target", dompath);
         goto out;
@@ -4845,7 +4845,7 @@ retry_transaction:
         goto out;
     }
 
-    libxl__xs_write(gc, t, libxl__sprintf(gc, "%s/memory/target",
+    libxl__xs_write(gc, t, GCSPRINTF("%s/memory/target",
                 dompath), "%"PRIu32, new_target_memkb);
     rc = xc_domain_getinfolist(ctx->xch, domid, 1, &info);
     if (rc != 1 || info.domain != domid) {
@@ -4856,7 +4856,7 @@ retry_transaction:
     libxl_dominfo_init(&ptr);
     xcinfo2xlinfo(ctx, &info, &ptr);
     uuid = libxl__uuid2string(gc, ptr.uuid);
-    libxl__xs_write(gc, t, libxl__sprintf(gc, "/vm/%s/memory", uuid),
+    libxl__xs_write(gc, t, GCSPRINTF("/vm/%s/memory", uuid),
             "%"PRIu32, new_target_memkb / 1024);
     libxl_dominfo_dispose(&ptr);
 
@@ -5493,7 +5493,7 @@ retry_transaction:
     t = xs_transaction_start(CTX->xsh);
     for (i = 0; i <= info->vcpu_max_id; i++)
         libxl__xs_write(gc, t,
-                       libxl__sprintf(gc, "%s/cpu/%u/availability", dompath, 
i),
+                       GCSPRINTF("%s/cpu/%u/availability", dompath, i),
                        "%s", libxl_bitmap_test(cpumap, i) ? "online" : 
"offline");
     if (!xs_transaction_end(CTX->xsh, t, 0)) {
         if (errno == EAGAIN)
@@ -5990,7 +5990,7 @@ int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char 
sysrq)
     GC_INIT(ctx);
     char *dompath = libxl__xs_get_dompath(gc, domid);
 
-    libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/control/sysrq", 
dompath), "%c", sysrq);
+    libxl__xs_write(gc, XBT_NULL, GCSPRINTF("%s/control/sysrq", dompath), 
"%c", sysrq);
 
     GC_FREE;
     return 0;
@@ -6080,9 +6080,9 @@ uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t 
domid)
     uint32_t ret;
 
     vm_path = libxl__xs_read(
-        gc, XBT_NULL, libxl__sprintf(gc, "%s/vm", dompath));
+        gc, XBT_NULL, GCSPRINTF("%s/vm", dompath));
     start_time = libxl__xs_read(
-        gc, XBT_NULL, libxl__sprintf(gc, "%s/start_time", vm_path));
+        gc, XBT_NULL, GCSPRINTF("%s/start_time", vm_path));
     if (start_time == NULL) {
         LOGEV(ERROR, -1, "Can't get start time of domain '%d'", domid);
         ret = -1;
@@ -6267,12 +6267,12 @@ int libxl_cpupool_create(libxl_ctx *ctx, const char 
*name,
     for (;;) {
         t = xs_transaction_start(ctx->xsh);
 
-        xs_mkdir(ctx->xsh, t, libxl__sprintf(gc, "/local/pool/%d", *poolid));
+        xs_mkdir(ctx->xsh, t, GCSPRINTF("/local/pool/%d", *poolid));
         libxl__xs_write(gc, t,
-                        libxl__sprintf(gc, "/local/pool/%d/uuid", *poolid),
+                        GCSPRINTF("/local/pool/%d/uuid", *poolid),
                         "%s", uuid_string);
         libxl__xs_write(gc, t,
-                        libxl__sprintf(gc, "/local/pool/%d/name", *poolid),
+                        GCSPRINTF("/local/pool/%d/name", *poolid),
                         "%s", name);
 
         if (xs_transaction_end(ctx->xsh, t, 0) || (errno != EAGAIN)) {
@@ -6325,7 +6325,7 @@ int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid)
     for (;;) {
         t = xs_transaction_start(ctx->xsh);
 
-        xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/pool/%d", 
poolid));
+        xs_rm(ctx->xsh, XBT_NULL, GCSPRINTF("/local/pool/%d", poolid));
 
         if (xs_transaction_end(ctx->xsh, t, 0) || (errno != EAGAIN))
             break;
@@ -6365,7 +6365,7 @@ int libxl_cpupool_rename(libxl_ctx *ctx, const char 
*name, uint32_t poolid)
         t = xs_transaction_start(ctx->xsh);
 
         libxl__xs_write(gc, t,
-                        libxl__sprintf(gc, "/local/pool/%d/name", poolid),
+                        GCSPRINTF("/local/pool/%d/name", poolid),
                         "%s", name);
 
         if (xs_transaction_end(ctx->xsh, t, 0))
diff --git a/tools/libxl/libxl_blktap2.c b/tools/libxl/libxl_blktap2.c
index 2053403..4f5e522 100644
--- a/tools/libxl/libxl_blktap2.c
+++ b/tools/libxl/libxl_blktap2.c
@@ -35,12 +35,12 @@ char *libxl__blktap_devpath(libxl__gc *gc,
     type = libxl__device_disk_string_of_format(format);
     err = tap_ctl_find(type, disk, &tap);
     if (err == 0) {
-        devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor);
+        devname = GCSPRINTF("/dev/xen/blktap-2/tapdev%d", tap.minor);
         if (devname)
             return devname;
     }
 
-    params = libxl__sprintf(gc, "%s:%s", type, disk);
+    params = GCSPRINTF("%s:%s", type, disk);
     err = tap_ctl_create(params, &devname);
     if (!err) {
         libxl__ptr_add(gc, devname);
diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c
index 95dde98..231bba8 100644
--- a/tools/libxl/libxl_bootloader.c
+++ b/tools/libxl/libxl_bootloader.c
@@ -60,15 +60,15 @@ static void make_bootloader_args(libxl__gc *gc, 
libxl__bootloader_state *bl,
     ARG(bootloader_path);
 
     if (info->kernel)
-        ARG(libxl__sprintf(gc, "--kernel=%s", info->kernel));
+        ARG(GCSPRINTF("--kernel=%s", info->kernel));
     if (info->ramdisk)
-        ARG(libxl__sprintf(gc, "--ramdisk=%s", info->ramdisk));
+        ARG(GCSPRINTF("--ramdisk=%s", info->ramdisk));
     if (info->cmdline && *info->cmdline != '\0')
-        ARG(libxl__sprintf(gc, "--args=%s", info->cmdline));
+        ARG(GCSPRINTF("--args=%s", info->cmdline));
 
-    ARG(libxl__sprintf(gc, "--output=%s", bl->outputpath));
+    ARG(GCSPRINTF("--output=%s", bl->outputpath));
     ARG("--output-format=simple0");
-    ARG(libxl__sprintf(gc, "--output-directory=%s", bl->outputdir));
+    ARG(GCSPRINTF("--output-directory=%s", bl->outputdir));
 
     if (info->u.pv.bootloader_args) {
         char **p = info->u.pv.bootloader_args;
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f0fee00..69c0d59 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -421,7 +421,7 @@ int libxl__domain_build(libxl__gc *gc,
         vments[2] = "image/ostype";
         vments[3] = "hvm";
         vments[4] = "start_time";
-        vments[5] = libxl__sprintf(gc, "%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[5] = GCSPRINTF("%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
 
         localents = libxl__calloc(gc, 9, sizeof(char *));
         i = 0;
@@ -458,7 +458,7 @@ int libxl__domain_build(libxl__gc *gc,
         vments[i++] = "image/kernel";
         vments[i++] = (char *) state->pv_kernel.path;
         vments[i++] = "start_time";
-        vments[i++] = libxl__sprintf(gc, "%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[i++] = GCSPRINTF("%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (state->pv_ramdisk.path) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char *) state->pv_ramdisk.path;
@@ -555,7 +555,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config 
*d_config,
         goto out;
     }
 
-    vm_path = libxl__sprintf(gc, "/vm/%s", uuid_string);
+    vm_path = GCSPRINTF("/vm/%s", uuid_string);
     if (!vm_path) {
         LOG(ERROR, "cannot allocate create paths");
         rc = ERROR_FAIL;
@@ -591,36 +591,36 @@ retry_transaction:
     xs_rm(ctx->xsh, t, libxl_path);
     libxl__xs_mkdir(gc, t, libxl_path, noperm, ARRAY_SIZE(noperm));
 
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vm", dom_path), vm_path, 
strlen(vm_path));
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/vm", dom_path), vm_path, 
strlen(vm_path));
     rc = libxl__domain_rename(gc, *domid, 0, info->name, t);
     if (rc)
         goto out;
 
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/cpu", dom_path),
+                    GCSPRINTF("%s/cpu", dom_path),
                     roperm, ARRAY_SIZE(roperm));
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/memory", dom_path),
+                    GCSPRINTF("%s/memory", dom_path),
                     roperm, ARRAY_SIZE(roperm));
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/device", dom_path),
+                    GCSPRINTF("%s/device", dom_path),
                     roperm, ARRAY_SIZE(roperm));
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/control", dom_path),
+                    GCSPRINTF("%s/control", dom_path),
                     roperm, ARRAY_SIZE(roperm));
     if (info->type == LIBXL_DOMAIN_TYPE_HVM)
         libxl__xs_mkdir(gc, t,
-                        libxl__sprintf(gc, "%s/hvmloader", dom_path),
+                        GCSPRINTF("%s/hvmloader", dom_path),
                         roperm, ARRAY_SIZE(roperm));
 
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/control/shutdown", dom_path),
+                    GCSPRINTF("%s/control/shutdown", dom_path),
                     rwperm, ARRAY_SIZE(rwperm));
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/device/suspend/event-channel", 
dom_path),
+                    GCSPRINTF("%s/device/suspend/event-channel", dom_path),
                     rwperm, ARRAY_SIZE(rwperm));
     libxl__xs_mkdir(gc, t,
-                    libxl__sprintf(gc, "%s/data", dom_path),
+                    GCSPRINTF("%s/data", dom_path),
                     rwperm, ARRAY_SIZE(rwperm));
 
     if (libxl_defbool_val(info->driver_domain)) {
@@ -646,14 +646,14 @@ retry_transaction:
     }
     libxl_vminfo_list_free(vm_list, nb_vm);
 
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/uuid", vm_path), uuid_string, 
strlen(uuid_string));
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/name", vm_path), info->name, 
strlen(info->name));
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/uuid", vm_path), uuid_string, 
strlen(uuid_string));
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/name", vm_path), info->name, 
strlen(info->name));
 
     libxl__xs_writev(gc, t, dom_path, info->xsdata);
-    libxl__xs_writev(gc, t, libxl__sprintf(gc, "%s/platform", dom_path), 
info->platformdata);
+    libxl__xs_writev(gc, t, GCSPRINTF("%s/platform", dom_path), 
info->platformdata);
 
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, 
"%s/control/platform-feature-multiprocessor-suspend", dom_path), "1", 1);
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, 
"%s/control/platform-feature-xs_reset_watches", dom_path), "1", 1);
+    xs_write(ctx->xsh, t, 
GCSPRINTF("%s/control/platform-feature-multiprocessor-suspend", dom_path), "1", 
1);
+    xs_write(ctx->xsh, t, 
GCSPRINTF("%s/control/platform-feature-xs_reset_watches", dom_path), "1", 1);
     if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN) {
             t = 0;
@@ -677,7 +677,7 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid,
     char *path = NULL;
 
     path = libxl__xs_libxl_path(gc, domid);
-    path = libxl__sprintf(gc, "%s/dm-version", path);
+    path = GCSPRINTF("%s/dm-version", path);
     return libxl__xs_write(gc, XBT_NULL, path, "%s",
         libxl_device_model_version_to_string(b_info->device_model_version));
 }
@@ -1081,7 +1081,7 @@ static void domcreate_stream_done(libxl__egc *egc,
         vments[2] = "image/ostype";
         vments[3] = "hvm";
         vments[4] = "start_time";
-        vments[5] = libxl__sprintf(gc, "%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[5] = GCSPRINTF("%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         vments = libxl__calloc(gc, 11, sizeof(char *));
@@ -1091,7 +1091,7 @@ static void domcreate_stream_done(libxl__egc *egc,
         vments[i++] = "image/kernel";
         vments[i++] = (char *) state->pv_kernel.path;
         vments[i++] = "start_time";
-        vments[i++] = libxl__sprintf(gc, "%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[i++] = GCSPRINTF("%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (state->pv_ramdisk.path) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char *) state->pv_ramdisk.path;
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 175accd..dc32c73 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -29,7 +29,7 @@ static const char *libxl_tapif_script(libxl__gc *gc)
 #if defined(__linux__) || defined(__FreeBSD__)
     return libxl__strdup(gc, "no");
 #else
-    return libxl__sprintf(gc, "%s/qemu-ifup", libxl__xen_script_dir_path());
+    return GCSPRINTF("%s/qemu-ifup", libxl__xen_script_dir_path());
 #endif
 }
 
@@ -416,7 +416,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
     dm_envs = flexarray_make(gc, 16, 1);
 
     flexarray_vappend(dm_args, dm,
-                      "-d", libxl__sprintf(gc, "%d", domid), NULL);
+                      "-d", GCSPRINTF("%d", domid), NULL);
 
     if (c_info->name)
         flexarray_vappend(dm_args, "-domain-name", c_info->name, NULL);
@@ -442,14 +442,14 @@ static int libxl__build_device_model_args_old(libxl__gc 
*gc,
                 }
                 vncarg = vnc->listen;
             } else {
-                vncarg = libxl__sprintf(gc, "%s:%d", vnc->listen,
+                vncarg = GCSPRINTF("%s:%d", vnc->listen,
                                         vnc->display);
             }
         } else
-            vncarg = libxl__sprintf(gc, "127.0.0.1:%d", vnc->display);
+            vncarg = GCSPRINTF("127.0.0.1:%d", vnc->display);
 
         if (vnc->passwd && vnc->passwd[0]) {
-            vncarg = libxl__sprintf(gc, "%s,password", vncarg);
+            vncarg = GCSPRINTF("%s,password", vncarg);
         }
 
         flexarray_append(dm_args, vncarg);
@@ -517,7 +517,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
 
         if (b_info->video_memkb) {
             flexarray_vappend(dm_args, "-videoram",
-                    libxl__sprintf(gc, "%d",
+                    GCSPRINTF("%d",
                                    libxl__sizekb_to_mb(b_info->video_memkb)),
                     NULL);
         }
@@ -569,14 +569,14 @@ static int libxl__build_device_model_args_old(libxl__gc 
*gc,
         }
         if (b_info->max_vcpus > 1) {
             flexarray_vappend(dm_args, "-vcpus",
-                              libxl__sprintf(gc, "%d", b_info->max_vcpus),
+                              GCSPRINTF("%d", b_info->max_vcpus),
                               NULL);
         }
 
         nr_set_cpus = libxl_bitmap_count_set(&b_info->avail_vcpus);
         s = libxl_bitmap_to_hex_string(CTX, &b_info->avail_vcpus);
         flexarray_vappend(dm_args, "-vcpu_avail",
-                              libxl__sprintf(gc, "%s", s), NULL);
+                              GCSPRINTF("%s", s), NULL);
         free(s);
 
         for (i = 0; i < num_nics; i++) {
@@ -683,26 +683,26 @@ static char *dm_spice_options(libxl__gc *gc,
             return NULL;
         }
     }
-    opt = libxl__sprintf(gc, "port=%d,tls-port=%d",
+    opt = GCSPRINTF("port=%d,tls-port=%d",
                          spice->port, spice->tls_port);
     if (spice->host)
-        opt = libxl__sprintf(gc, "%s,addr=%s", opt, spice->host);
+        opt = GCSPRINTF("%s,addr=%s", opt, spice->host);
     if (libxl_defbool_val(spice->disable_ticketing))
-        opt = libxl__sprintf(gc, "%s,disable-ticketing", opt);
+        opt = GCSPRINTF("%s,disable-ticketing", opt);
     else
-        opt = libxl__sprintf(gc, "%s,password=%s", opt, spice->passwd);
-    opt = libxl__sprintf(gc, "%s,agent-mouse=%s", opt,
+        opt = GCSPRINTF("%s,password=%s", opt, spice->passwd);
+    opt = GCSPRINTF("%s,agent-mouse=%s", opt,
                          libxl_defbool_val(spice->agent_mouse) ? "on" : "off");
 
     if (!libxl_defbool_val(spice->clipboard_sharing))
-        opt = libxl__sprintf(gc, "%s,disable-copy-paste", opt);
+        opt = GCSPRINTF("%s,disable-copy-paste", opt);
 
     if (spice->image_compression)
-        opt = libxl__sprintf(gc, "%s,image-compression=%s", opt,
+        opt = GCSPRINTF("%s,image-compression=%s", opt,
                              spice->image_compression);
 
     if (spice->streaming_video)
-        opt = libxl__sprintf(gc, "%s,streaming-video=%s", opt,
+        opt = GCSPRINTF("%s,streaming-video=%s", opt,
                              spice->streaming_video);
 
     return opt;
@@ -782,7 +782,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
 
     flexarray_vappend(dm_args, dm,
                       "-xen-domid",
-                      libxl__sprintf(gc, "%d", guest_domid), NULL);
+                      GCSPRINTF("%d", guest_domid), NULL);
 
     flexarray_append(dm_args, "-chardev");
     flexarray_append(dm_args,
@@ -860,21 +860,21 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
                 }
                 vncarg = vnc->listen;
             } else {
-                vncarg = libxl__sprintf(gc, "%s:%d", vnc->listen,
+                vncarg = GCSPRINTF("%s:%d", vnc->listen,
                                         vnc->display);
             }
         } else
-            vncarg = libxl__sprintf(gc, "127.0.0.1:%d", vnc->display);
+            vncarg = GCSPRINTF("127.0.0.1:%d", vnc->display);
 
         if (vnc->passwd && vnc->passwd[0]) {
-            vncarg = libxl__sprintf(gc, "%s,password", vncarg);
+            vncarg = GCSPRINTF("%s,password", vncarg);
         }
 
         if (libxl_defbool_val(vnc->findunused)) {
             /* This option asks to QEMU to try this number of port before to
              * give up.  So QEMU will try ports between $display and $display +
              * 99.  This option needs to be the last one of the vnc options. */
-            vncarg = libxl__sprintf(gc, "%s,to=99", vncarg);
+            vncarg = GCSPRINTF("%s,to=99", vncarg);
         }
 
         flexarray_append(dm_args, vncarg);
@@ -978,7 +978,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
 
         if (b_info->u.hvm.boot) {
             flexarray_vappend(dm_args, "-boot",
-                    libxl__sprintf(gc, "order=%s", b_info->u.hvm.boot), NULL);
+                    GCSPRINTF("order=%s", b_info->u.hvm.boot), NULL);
         }
         if (libxl_defbool_val(b_info->u.hvm.usb)
             || b_info->u.hvm.usbdevice
@@ -1051,11 +1051,11 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
                 int nr_set_cpus = 0;
                 nr_set_cpus = libxl_bitmap_count_set(&b_info->avail_vcpus);
 
-                flexarray_append(dm_args, libxl__sprintf(gc, "%d,maxcpus=%d",
+                flexarray_append(dm_args, GCSPRINTF("%d,maxcpus=%d",
                                                          nr_set_cpus,
                                                          b_info->max_vcpus));
             } else
-                flexarray_append(dm_args, libxl__sprintf(gc, "%d",
+                flexarray_append(dm_args, GCSPRINTF("%d",
                                                          b_info->max_vcpus));
         }
         for (i = 0; i < num_nics; i++) {
@@ -1067,7 +1067,7 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
                                                 LIBXL_NIC_TYPE_VIF_IOEMU);
                 flexarray_append(dm_args, "-device");
                 flexarray_append(dm_args,
-                   libxl__sprintf(gc, "%s,id=nic%d,netdev=net%d,mac=%s",
+                   GCSPRINTF("%s,id=nic%d,netdev=net%d,mac=%s",
                                                 nics[i].model, nics[i].devid,
                                                 nics[i].devid, smac));
                 flexarray_append(dm_args, "-netdev");
@@ -1264,7 +1264,7 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
             goto end_search;
         }
 
-        user = libxl__sprintf(gc, "%s%d", LIBXL_QEMU_USER_BASE, guest_domid);
+        user = GCSPRINTF("%s%d", LIBXL_QEMU_USER_BASE, guest_domid);
         ret = libxl__dm_runas_helper(gc, user);
         if (ret < 0)
             return ret;
@@ -1388,7 +1388,7 @@ static int libxl__write_stub_dmargs(libxl__gc *gc,
     roperm[1].id = dm_domid;
     roperm[1].perms = XS_PERM_READ;
 
-    vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, 
"/local/domain/%d/vm", guest_domid));
+    vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("/local/domain/%d/vm", 
guest_domid));
 
     i = 0;
     dmargs_size = 0;
@@ -1407,13 +1407,13 @@ static int libxl__write_stub_dmargs(libxl__gc *gc,
         }
         i++;
     }
-    path = libxl__sprintf(gc, "%s/image/dmargs", vm_path);
+    path = GCSPRINTF("%s/image/dmargs", vm_path);
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
     xs_write(ctx->xsh, t, path, dmargs, strlen(dmargs));
     xs_set_permissions(ctx->xsh, t, path, roperm, ARRAY_SIZE(roperm));
-    xs_set_permissions(ctx->xsh, t, libxl__sprintf(gc, "%s/rtc/timeoffset", 
vm_path), roperm, ARRAY_SIZE(roperm));
+    xs_set_permissions(ctx->xsh, t, GCSPRINTF("%s/rtc/timeoffset", vm_path), 
roperm, ARRAY_SIZE(roperm));
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;
@@ -1436,7 +1436,7 @@ static void stubdom_xswait_cb(libxl__egc *egc, 
libxl__xswait_state *xswait,
 
 char *libxl__stub_dm_name(libxl__gc *gc, const char *guest_name)
 {
-    return libxl__sprintf(gc, "%s-dm", guest_name);
+    return GCSPRINTF("%s-dm", guest_name);
 }
 
 void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
@@ -1518,7 +1518,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, 
libxl__stub_dm_spawn_state *sdss)
 
     stubdom_state->pv_kernel.path
         = libxl__abs_path(gc, "ioemu-stubdom.gz", 
libxl__xenfirmwaredir_path());
-    stubdom_state->pv_cmdline = libxl__sprintf(gc, " -d %d", guest_domid);
+    stubdom_state->pv_cmdline = GCSPRINTF(" -d %d", guest_domid);
     stubdom_state->pv_ramdisk.path = "";
 
     /* fixme: this function can leak the stubdom if it fails */
@@ -1541,11 +1541,11 @@ void libxl__spawn_stub_dm(libxl__egc *egc, 
libxl__stub_dm_spawn_state *sdss)
 
     libxl__write_stub_dmargs(gc, dm_domid, guest_domid, args);
     libxl__xs_write(gc, XBT_NULL,
-                   libxl__sprintf(gc, "%s/image/device-model-domid",
+                   GCSPRINTF("%s/image/device-model-domid",
                                   libxl__xs_get_dompath(gc, guest_domid)),
                    "%d", dm_domid);
     libxl__xs_write(gc, XBT_NULL,
-                   libxl__sprintf(gc, "%s/target",
+                   GCSPRINTF("%s/target",
                                   libxl__xs_get_dompath(gc, dm_domid)),
                    "%d", guest_domid);
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
@@ -1639,21 +1639,21 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
             char *filename;
             char *name;
             case STUBDOM_CONSOLE_LOGGING:
-                name = libxl__sprintf(gc, "qemu-dm-%s",
+                name = GCSPRINTF("qemu-dm-%s",
                                       libxl_domid_to_name(ctx, guest_domid));
                 ret = libxl_create_logfile(ctx, name, &filename);
                 if (ret) goto out;
-                console[i].output = libxl__sprintf(gc, "file:%s", filename);
+                console[i].output = GCSPRINTF("file:%s", filename);
                 free(filename);
                 break;
             case STUBDOM_CONSOLE_SAVE:
-                console[i].output = libxl__sprintf(gc, "file:%s",
+                console[i].output = GCSPRINTF("file:%s",
                                 libxl__device_model_savefile(gc, guest_domid));
                 break;
             case STUBDOM_CONSOLE_RESTORE:
                 if (d_state->saved_state)
                     console[i].output =
-                        libxl__sprintf(gc, "pipe:%s", d_state->saved_state);
+                        GCSPRINTF("pipe:%s", d_state->saved_state);
                 break;
             default:
                 console[i].output = "pty";
@@ -1822,7 +1822,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, 
libxl__dm_spawn_state *dmss)
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         path = xs_get_domain_path(ctx->xsh, domid);
         libxl__xs_write(gc, XBT_NULL,
-                        libxl__sprintf(gc, "%s/hvmloader/bios", path),
+                        GCSPRINTF("%s/hvmloader/bios", path),
                         "%s", libxl_bios_type_to_string(b_info->u.hvm.bios));
         /* Disable relocating memory to make the MMIO hole larger
          * unless we're running qemu-traditional and vNUMA is not
@@ -1843,7 +1843,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, 
libxl__dm_spawn_state *dmss)
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
         b_info->device_model_version
         == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL)
-        libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/disable_pf", 
path),
+        libxl__xs_write(gc, XBT_NULL, GCSPRINTF("%s/disable_pf", path),
                     "%d", !libxl_defbool_val(b_info->u.hvm.xen_platform_pci));
 
     logfile_w = libxl__create_qemu_logfile(gc, GCSPRINTF("qemu-dm-%s",
@@ -1868,7 +1868,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, 
libxl__dm_spawn_state *dmss)
 retry_transaction:
         /* Find uuid and the write the vnc password to xenstore for qemu. */
         t = xs_transaction_start(ctx->xsh);
-        vm_path = libxl__xs_read(gc,t,libxl__sprintf(gc, "%s/vm", dom_path));
+        vm_path = libxl__xs_read(gc,t,GCSPRINTF("%s/vm", dom_path));
         if (vm_path) {
             /* Now write the vncpassword into it. */
             pass_stuff = libxl__calloc(gc, 3, sizeof(char *));
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index c69d6f9..328046b 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -242,7 +242,7 @@ void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, 
int errnoval,
 char *libxl__abs_path(libxl__gc *gc, const char *s, const char *path)
 {
     if (s[0] == '/') return libxl__strdup(gc, s);
-    return libxl__sprintf(gc, "%s/%s", path, s);
+    return GCSPRINTF("%s/%s", path, s);
 }
 
 
@@ -368,7 +368,7 @@ int libxl__device_model_version_running(libxl__gc *gc, 
uint32_t domid)
     libxl_device_model_version value;
 
     path = libxl__xs_libxl_path(gc, domid);
-    path = libxl__sprintf(gc, "%s/dm-version", path);
+    path = GCSPRINTF("%s/dm-version", path);
     dm_version = libxl__xs_read(gc, XBT_NULL, path);
     if (!dm_version) {
         return LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index fad2eb6..48827d7 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -50,18 +50,18 @@ static int pcidev_struct_fill(libxl_device_pci *pcidev, 
unsigned int domain,
 
 static void libxl_create_pci_backend_device(libxl__gc *gc, flexarray_t *back, 
int num, libxl_device_pci *pcidev)
 {
-    flexarray_append(back, libxl__sprintf(gc, "key-%d", num));
+    flexarray_append(back, GCSPRINTF("key-%d", num));
     flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
-    flexarray_append(back, libxl__sprintf(gc, "dev-%d", num));
+    flexarray_append(back, GCSPRINTF("dev-%d", num));
     flexarray_append(back, libxl__sprintf(gc, PCI_BDF, pcidev->domain, 
pcidev->bus, pcidev->dev, pcidev->func));
     if (pcidev->vdevfn)
-        flexarray_append_pair(back, libxl__sprintf(gc, "vdevfn-%d", num), 
libxl__sprintf(gc, "%x", pcidev->vdevfn));
-    flexarray_append(back, libxl__sprintf(gc, "opts-%d", num));
+        flexarray_append_pair(back, GCSPRINTF("vdevfn-%d", num), 
libxl__sprintf(gc, "%x", pcidev->vdevfn));
+    flexarray_append(back, GCSPRINTF("opts-%d", num));
     flexarray_append(back,
-              libxl__sprintf(gc, "msitranslate=%d,power_mgmt=%d,permissive=%d",
+              GCSPRINTF("msitranslate=%d,power_mgmt=%d,permissive=%d",
                              pcidev->msitranslate, pcidev->power_mgmt,
                              pcidev->permissive));
-    flexarray_append_pair(back, libxl__sprintf(gc, "state-%d", num), 
GCSPRINTF("%d", XenbusStateInitialising));
+    flexarray_append_pair(back, GCSPRINTF("state-%d", num), GCSPRINTF("%d", 
XenbusStateInitialising));
 }
 
 static int libxl__device_from_pcidev(libxl__gc *gc, uint32_t domid,
@@ -96,7 +96,7 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
     /* add pci device */
     libxl__device_from_pcidev(gc, domid, pcidev, &device);
 
-    flexarray_append_pair(back, "frontend-id", libxl__sprintf(gc, "%d", 
domid));
+    flexarray_append_pair(back, "frontend-id", GCSPRINTF("%d", domid));
     flexarray_append_pair(back, "online", "1");
     flexarray_append_pair(back, "state", GCSPRINTF("%d", 
XenbusStateInitialising));
     flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid));
@@ -104,8 +104,8 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
     for (i = 0; i < num; i++, pcidev++)
         libxl_create_pci_backend_device(gc, back, i, pcidev);
 
-    flexarray_append_pair(back, "num_devs", libxl__sprintf(gc, "%d", num));
-    flexarray_append_pair(front, "backend-id", libxl__sprintf(gc, "%d", 0));
+    flexarray_append_pair(back, "num_devs", GCSPRINTF("%d", num));
+    flexarray_append_pair(front, "backend-id", GCSPRINTF("%d", 0));
     flexarray_append_pair(front, "state", GCSPRINTF("%d", 
XenbusStateInitialising));
 
     libxl__device_generic_add(gc, XBT_NULL, &device,
@@ -132,8 +132,8 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, 
uint32_t domid, libxl_d
     libxl_device_pci_init(&pcidev_saved);
     libxl_device_pci_copy(CTX, &pcidev_saved, pcidev);
 
-    be_path = libxl__sprintf(gc, "%s/backend/pci/%d/0", 
libxl__xs_get_dompath(gc, 0), domid);
-    num_devs = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/num_devs", 
be_path));
+    be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), 
domid);
+    num_devs = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/num_devs", be_path));
     if (!num_devs)
         return libxl__create_pci_backend(gc, domid, pcidev, 1);
 
@@ -151,7 +151,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, 
uint32_t domid, libxl_d
     LOG(DEBUG, "Adding new pci device to xenstore");
     num = atoi(num_devs);
     libxl_create_pci_backend_device(gc, back, num, pcidev);
-    flexarray_append_pair(back, "num_devs", libxl__sprintf(gc, "%d", num + 1));
+    flexarray_append_pair(back, "num_devs", GCSPRINTF("%d", num + 1));
     if (!starting)
         flexarray_append_pair(back, "state", GCSPRINTF("%d", 
XenbusStateReconfiguring));
 
@@ -199,8 +199,8 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, 
uint32_t domid, libx
     int num, i, j;
     xs_transaction_t t;
 
-    be_path = libxl__sprintf(gc, "%s/backend/pci/%d/0", 
libxl__xs_get_dompath(gc, 0), domid);
-    num_devs_path = libxl__sprintf(gc, "%s/num_devs", be_path);
+    be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), 
domid);
+    num_devs_path = GCSPRINTF("%s/num_devs", be_path);
     num_devs = libxl__xs_read(gc, XBT_NULL, num_devs_path);
     if (!num_devs)
         return ERROR_INVAL;
@@ -219,7 +219,7 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, 
uint32_t domid, libx
 
     for (i = 0; i < num; i++) {
         unsigned int domain = 0, bus = 0, dev = 0, func = 0;
-        xsdev = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/dev-%d", 
be_path, i));
+        xsdev = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/dev-%d", be_path, 
i));
         sscanf(xsdev, PCI_BDF, &domain, &bus, &dev, &func);
         if (domain == pcidev->domain && bus == pcidev->bus &&
             pcidev->dev == dev && pcidev->func == func) {
@@ -233,8 +233,8 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, 
uint32_t domid, libx
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/state-%d", be_path, i), 
GCSPRINTF("%d", XenbusStateClosing), 1);
-    xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/state", be_path), 
GCSPRINTF("%d", XenbusStateReconfiguring), 1);
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/state-%d", be_path, i), 
GCSPRINTF("%d", XenbusStateClosing), 1);
+    xs_write(ctx->xsh, t, GCSPRINTF("%s/state", be_path), GCSPRINTF("%d", 
XenbusStateReconfiguring), 1);
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;
@@ -248,42 +248,42 @@ retry_transaction:
 
 retry_transaction2:
     t = xs_transaction_start(ctx->xsh);
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/state-%d", be_path, i));
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/key-%d", be_path, i));
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/dev-%d", be_path, i));
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/vdev-%d", be_path, i));
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/opts-%d", be_path, i));
-    xs_rm(ctx->xsh, t, libxl__sprintf(gc, "%s/vdevfn-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/state-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/key-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/dev-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/vdev-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/opts-%d", be_path, i));
+    xs_rm(ctx->xsh, t, GCSPRINTF("%s/vdevfn-%d", be_path, i));
     libxl__xs_write(gc, t, num_devs_path, "%d", num - 1);
     for (j = i + 1; j < num; j++) {
-        tmppath = libxl__sprintf(gc, "%s/state-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/state-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
-        xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/state-%d", be_path, j - 
1), tmp, strlen(tmp));
+        xs_write(ctx->xsh, t, GCSPRINTF("%s/state-%d", be_path, j - 1), tmp, 
strlen(tmp));
         xs_rm(ctx->xsh, t, tmppath);
-        tmppath = libxl__sprintf(gc, "%s/dev-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/dev-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
-        xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/dev-%d", be_path, j - 1), 
tmp, strlen(tmp));
+        xs_write(ctx->xsh, t, GCSPRINTF("%s/dev-%d", be_path, j - 1), tmp, 
strlen(tmp));
         xs_rm(ctx->xsh, t, tmppath);
-        tmppath = libxl__sprintf(gc, "%s/key-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/key-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
-        xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/key-%d", be_path, j - 1), 
tmp, strlen(tmp));
+        xs_write(ctx->xsh, t, GCSPRINTF("%s/key-%d", be_path, j - 1), tmp, 
strlen(tmp));
         xs_rm(ctx->xsh, t, tmppath);
-        tmppath = libxl__sprintf(gc, "%s/vdev-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/vdev-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
         if (tmp) {
-            xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vdev-%d", be_path, j 
- 1), tmp, strlen(tmp));
+            xs_write(ctx->xsh, t, GCSPRINTF("%s/vdev-%d", be_path, j - 1), 
tmp, strlen(tmp));
             xs_rm(ctx->xsh, t, tmppath);
         }
-        tmppath = libxl__sprintf(gc, "%s/opts-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/opts-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
         if (tmp) {
-            xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/opts-%d", be_path, j 
- 1), tmp, strlen(tmp));
+            xs_write(ctx->xsh, t, GCSPRINTF("%s/opts-%d", be_path, j - 1), 
tmp, strlen(tmp));
             xs_rm(ctx->xsh, t, tmppath);
         }
-        tmppath = libxl__sprintf(gc, "%s/vdevfn-%d", be_path, j);
+        tmppath = GCSPRINTF("%s/vdevfn-%d", be_path, j);
         tmp = libxl__xs_read(gc, t, tmppath);
         if (tmp) {
-            xs_write(ctx->xsh, t, libxl__sprintf(gc, "%s/vdevfn-%d", be_path, 
j - 1), tmp, strlen(tmp));
+            xs_write(ctx->xsh, t, GCSPRINTF("%s/vdevfn-%d", be_path, j - 1), 
tmp, strlen(tmp));
             xs_rm(ctx->xsh, t, tmppath);
         }
     }
@@ -319,14 +319,14 @@ static int get_all_assigned_devices(libxl__gc *gc, 
libxl_device_pci **list, int
     for(i = 0; i < nd; i++) {
         char *path, *num_devs;
 
-        path = libxl__sprintf(gc, "/local/domain/0/backend/pci/%s/0/num_devs", 
domlist[i]);
+        path = GCSPRINTF("/local/domain/0/backend/pci/%s/0/num_devs", 
domlist[i]);
         num_devs = libxl__xs_read(gc, XBT_NULL, path);
         if ( num_devs ) {
             int ndev = atoi(num_devs), j;
             char *devpath, *bdf;
 
             for(j = 0; j < ndev; j++) {
-                devpath = libxl__sprintf(gc, 
"/local/domain/0/backend/pci/%s/0/dev-%u",
+                devpath = GCSPRINTF("/local/domain/0/backend/pci/%s/0/dev-%u",
                                         domlist[i], j);
                 bdf = libxl__xs_read(gc, XBT_NULL, devpath);
                 if ( bdf ) {
@@ -471,7 +471,7 @@ static int sysfs_dev_unbind(libxl__gc *gc, libxl_device_pci 
*pcidev,
         LOG(DEBUG, "Driver re-plug path: %s", dp);
 
         /* Unbind from the old driver */
-        spath = libxl__sprintf(gc, "%s/unbind", dp);
+        spath = GCSPRINTF("%s/unbind", dp);
         if ( sysfs_write_bdf(gc, spath, pcidev) < 0 ) {
             LOGE(ERROR, "Couldn't unbind device");
             return -1;
@@ -851,7 +851,7 @@ static int libxl__device_pci_assignable_remove(libxl__gc 
*gc,
             LOG(INFO, "Rebinding to driver at %s", driver_path);
 
             if ( sysfs_write_bdf(gc,
-                                 libxl__sprintf(gc, "%s/bind", driver_path),
+                                 GCSPRINTF("%s/bind", driver_path),
                                  pcidev) < 0 ) {
                 LOGE(ERROR, "Couldn't bind device to %s", driver_path);
                 return -1;
@@ -1131,7 +1131,7 @@ static int libxl__device_pci_reset(libxl__gc *gc, 
unsigned int domain, unsigned
     char *reset;
     int fd, rc;
 
-    reset = libxl__sprintf(gc, "%s/do_flr", SYSFS_PCIBACK_DRIVER);
+    reset = GCSPRINTF("%s/do_flr", SYSFS_PCIBACK_DRIVER);
     fd = open(reset, O_WRONLY);
     if (fd >= 0) {
         char *buf = libxl__sprintf(gc, PCI_BDF, domain, bus, dev, func);
@@ -1143,7 +1143,7 @@ static int libxl__device_pci_reset(libxl__gc *gc, 
unsigned int domain, unsigned
     }
     if (errno != ENOENT)
         LOGE(ERROR, "Failed to access pciback path %s", reset);
-    reset = libxl__sprintf(gc, "%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, 
bus, dev, func);
+    reset = GCSPRINTF("%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, 
func);
     fd = open(reset, O_WRONLY);
     if (fd >= 0) {
         rc = write(fd, "1", 1);
@@ -1533,16 +1533,16 @@ static void libxl__device_pci_from_xs_be(libxl__gc *gc,
     char *s;
     unsigned int domain = 0, bus = 0, dev = 0, func = 0, vdevfn = 0;
 
-    s = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/dev-%d", be_path, 
nr));
+    s = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/dev-%d", be_path, nr));
     sscanf(s, PCI_BDF, &domain, &bus, &dev, &func);
 
-    s = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/vdevfn-%d", 
be_path, nr));
+    s = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vdevfn-%d", be_path, nr));
     if (s)
         vdevfn = strtol(s, (char **) NULL, 16);
 
     pcidev_struct_fill(pci, domain, bus, dev, func, vdevfn);
 
-    s = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/opts-%d", be_path, 
nr));
+    s = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/opts-%d", be_path, nr));
     if (s) {
         char *saveptr;
         char *p = strtok_r(s, ",=", &saveptr);
@@ -1572,8 +1572,8 @@ libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, 
uint32_t domid, int *num
 
     *num = 0;
 
-    be_path = libxl__sprintf(gc, "%s/backend/pci/%d/0", 
libxl__xs_get_dompath(gc, 0), domid);
-    num_devs = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/num_devs", 
be_path));
+    be_path = GCSPRINTF("%s/backend/pci/%d/0", libxl__xs_get_dompath(gc, 0), 
domid);
+    num_devs = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/num_devs", be_path));
     if (!num_devs)
         goto out;
 
diff --git a/tools/libxl/libxl_xshelp.c b/tools/libxl/libxl_xshelp.c
index b0db062..bc60b9a 100644
--- a/tools/libxl/libxl_xshelp.c
+++ b/tools/libxl/libxl_xshelp.c
@@ -54,7 +54,7 @@ int libxl__xs_writev_perms(libxl__gc *gc, xs_transaction_t t,
         return 0;
 
     for (i = 0; kvs[i] != NULL; i += 2) {
-        path = libxl__sprintf(gc, "%s/%s", dir, kvs[i]);
+        path = GCSPRINTF("%s/%s", dir, kvs[i]);
         if (path && kvs[i + 1]) {
             int length = strlen(kvs[i + 1]);
             xs_write(ctx->xsh, t, path, kvs[i + 1], length);
@@ -159,7 +159,7 @@ bool libxl__xs_mkdir(libxl__gc *gc, xs_transaction_t t,
 
 char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid)
 {
-    char *s = libxl__sprintf(gc, "/libxl/%i", domid);
+    char *s = GCSPRINTF("/libxl/%i", domid);
     if (!s)
         LOG(ERROR, "cannot allocate create paths");
     return s;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.