Convert libxl__sprintf(gc) to GCSPRINTF
cover Convert libxl__sprintf(gc) to GCSPRINTF
There are mixed usage of libxl__sprintf(gc) and GCSPRINTF. Convert all libxl__sprintf to GCSPRINTF.
Wei Liu (2):
libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
libxl: fix line wrapping issues introduced by sed
tools/libxl/libxl.c | 181 ++++++++++++++++++++--------------------- tools/libxl/libxl_blktap2.c | 4 +- tools/libxl/libxl_bootloader.c | 10 +-- tools/libxl/libxl_create.c | 40 ++++----- tools/libxl/libxl_dm.c | 99 +++++++++++----------- tools/libxl/libxl_internal.c | 4 +- tools/libxl/libxl_pci.c | 92 ++++++++++----------- tools/libxl/libxl_xshelp.c | 4 +- 8 files changed, 214 insertions(+), 220 deletions(-)
Signature · 1 line
2.1.4
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
--- 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(-)
tools/libxl/libxl.c +85 -85
@@ -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 ))
tools/libxl/libxl_blktap2.c +2 -2
@@ -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);
tools/libxl/libxl_bootloader.c +5 -5
@@ -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;
tools/libxl/libxl_create.c +20 -20
@@ -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;
tools/libxl/libxl_dm.c +40 -40
262 lines not on this page · raw message
tools/libxl/libxl_internal.c +2 -2
@@ -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 ;
tools/libxl/libxl_pci.c +46 -46
225 lines not on this page · raw message
tools/libxl/libxl_xshelp.c +2 -2
@@ -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;
Signature · 1 line
2.1.4
Re: [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
Quoted 4 lines · Wei Liu
The rune is
sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c
Hmm... It looks like this rune alone doesn't cover all situations.
$ ack-grep 'libxl__sprintf\(gc' | wc -l 43
Let me see if I can refine it a bit or use multiple runes to replace all libxl__sprintf.
Re: [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
Quoted 6 lines · Wei Liu
Quoted 4 lines · Wei Liu
The rune is
sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c
Quoted 7 lines
Hmm... It looks like this rune alone doesn't cover all situations.
$ ack-grep 'libxl__sprintf\(gc' | wc -l 43Let me see if I can refine it a bit or use multiple runes to replace all
libxl__sprintf.
Coccinelle would probably work quite well for this particular case.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Wei Liu
Quoted 4 lines · Wei Liu
The rune is
sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c
Hmm... It looks like this rune alone doesn't cover all situations.
Quoted 8 lines
Quoted 5 lines
$ ack-grep 'libxl__sprintf\(gc' | wc -l 43Let me see if I can refine it a bit or use multiple runes to replace all
libxl__sprintf.Coccinelle would probably work quite well for this particular case.
Unfortunately no. Coccinelle doesn't support variable arguments, otherwise I would have used it already.
Wei.
Quoted 1 line
Ian.
Re: [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
Quoted 18 lines · Wei Liu
Quoted 17 lines · Ian Campbell
Quoted 15 lines · Wei Liu
Quoted 5 lines · Wei Liu
The rune is
sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c
Hmm... It looks like this rune alone doesn't cover all situations.
$ ack-grep 'libxl__sprintf\(gc' | wc -l 43Let me see if I can refine it a bit or use multiple runes to replace all
libxl__sprintf.
Quoted 5 lines
Quoted 2 lines
Coccinelle would probably work quite well for this particular case.
Unfortunately no. Coccinelle doesn't support variable arguments, otherwise I would have used it already.
Ah yes, I remember struggling with that at one point.
FWIW xen.git db82cd9251eb55a55242d6a713f710cd72d18fb0
and cb86677d2d1e061bf8d057bf1dd06cbb60210f33 seems to have gotten it to work some way or another.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/2] libxl: replace libxl__sprintf(gc, ...) with GCSPRINTF
Quoted 22 lines · Ian Campbell
Quoted 21 lines · Wei Liu
Quoted 19 lines · Ian Campbell
Quoted 7 lines · Wei Liu
Quoted 5 lines · Wei Liu
The rune is
sed -i 's/libxl__sprintf(gc,\s*\(".*",.*\)/GCSPRINTF(\1/g' libxl*.c
Quoted 8 lines
Hmm... It looks like this rune alone doesn't cover all situations.
$ ack-grep 'libxl__sprintf\(gc' | wc -l 43Let me see if I can refine it a bit or use multiple runes to replace all
libxl__sprintf.Coccinelle would probably work quite well for this particular case.
Quoted 6 lines
Quoted 2 lines
Unfortunately no. Coccinelle doesn't support variable arguments, otherwise I would have used it already.
Ah yes, I remember struggling with that at one point.
FWIW xen.git
db82cd9251eb55a55242d6a713f710cd72d18fb0
This is me enumerating from 0 to 3 arguments, which at the time covered 90%+ cases.
Actually this time it is not too bad. One sed invocation plus two minor fixups are enough to make libxl build.
Wei.
Quoted 5 lines
and cb86677d2d1e061bf8d057bf1dd06cbb60210f33 seems to have gotten it to work some way or another.
Ian.
PATCH 2/2 libxl: fix line wrapping issues introduced by automatic replacement
In reply to Wei Liu--- tools/libxl/libxl.c | 21 ++++++++++----------- tools/libxl/libxl_dm.c | 29 ++++++++++++----------------- 2 files changed, 22 insertions(+), 28 deletions(-)
tools/libxl/libxl.c +10 -11
@@ -1374,8 +1374,8 @@ 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 , -GCSPRINTF ("%.*s/backend" , - (int )strlen (wpath)-6 , wpath)); +GCSPRINTF ("%.*s/backend" , (int )strlen (wpath)-6 , + wpath));sscanf (backend, "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE)
@@ -2747,8 +2747,8 @@ int libxl_vdev_to_device_disk(libxl_ctx *ctx, uint32_t domid, goto out; } path =libxl__xs_read (gc,XBT_NULL , -GCSPRINTF ("%s/device/vbd/%d/backend" , - dompath, devid)); +GCSPRINTF ("%s/device/vbd/%d/backend" , dompath, + devid));if (!path) goto out;
@@ -3517,8 +3517,8 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid, goto out; path =libxl__xs_read (gc,XBT_NULL , -GCSPRINTF ("%s/device/vif/%d/backend" , - dompath, devid)); +GCSPRINTF ("%s/device/vif/%d/backend" , dompath, + devid));if (!path) goto out;
@@ -3543,8 +3543,8 @@ static int libxl__append_nic_list_of_type(libxl__gc *gc,libxl_device_nic *pnic =NULL , *pnic_end =NULL ;int rc; - be_path =GCSPRINTF ("%s/backend/%s/%d" , -libxl__xs_get_dompath (gc,0 ), type, domid); + 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) {libxl_device_nic *tmp;
@@ -3911,10 +3911,9 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, channelinfo->devid = channel->devid; fe_path =GCSPRINTF ("%s/device/console/%d" , dompath, - channelinfo->devid +1 ); + channelinfo->devid +1 ); channelinfo->backend =xs_read (ctx->xsh,XBT_NULL , -GCSPRINTF ("%s/backend" , - fe_path),NULL ); +GCSPRINTF ("%s/backend" , fe_path),NULL );if (!channelinfo->backend) {GC_FREE ;return ERROR_FAIL ;
tools/libxl/libxl_dm.c +12 -17
@@ -442,8 +442,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, } vncarg = vnc->listen; }else { - vncarg =GCSPRINTF ("%s:%d" , vnc->listen, - vnc->display); + vncarg =GCSPRINTF ("%s:%d" , vnc->listen, vnc->display); } }else vncarg =GCSPRINTF ("127.0.0.1:%d" , vnc->display);
@@ -517,8 +516,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,if (b_info->video_memkb) {flexarray_vappend (dm_args,"-videoram" , -GCSPRINTF ("%d" , -libxl__sizekb_to_mb (b_info->video_memkb)), +GCSPRINTF ("%d" ,libxl__sizekb_to_mb (b_info->video_memkb)),NULL ); }
@@ -683,8 +681,7 @@ static char *dm_spice_options(libxl__gc *gc,return NULL ; } } - opt =GCSPRINTF ("port=%d,tls-port=%d" , - spice->port, spice->tls_port); + opt =GCSPRINTF ("port=%d,tls-port=%d" , spice->port, spice->tls_port);if (spice->host) opt =GCSPRINTF ("%s,addr=%s" , opt, spice->host);if (libxl_defbool_val (spice->disable_ticketing))
@@ -692,18 +689,17 @@ static char *dm_spice_options(libxl__gc *gc,else opt =GCSPRINTF ("%s,password=%s" , opt, spice->passwd); opt =GCSPRINTF ("%s,agent-mouse=%s" , opt, -libxl_defbool_val (spice->agent_mouse) ?"on" :"off" ); +libxl_defbool_val (spice->agent_mouse) ?"on" :"off" );if (!libxl_defbool_val (spice->clipboard_sharing)) opt =GCSPRINTF ("%s,disable-copy-paste" , opt);if (spice->image_compression) opt =GCSPRINTF ("%s,image-compression=%s" , opt, - spice->image_compression); + spice->image_compression);if (spice->streaming_video) - opt =GCSPRINTF ("%s,streaming-video=%s" , opt, - spice->streaming_video); + opt =GCSPRINTF ("%s,streaming-video=%s" , opt, spice->streaming_video);return opt; }
@@ -1052,11 +1048,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, nr_set_cpus =libxl_bitmap_count_set (&b_info->avail_vcpus);flexarray_append (dm_args,GCSPRINTF ("%d,maxcpus=%d" , - nr_set_cpus, - b_info->max_vcpus)); + nr_set_cpus, + b_info->max_vcpus)); }else -flexarray_append (dm_args,GCSPRINTF ("%d" , - b_info->max_vcpus)); +flexarray_append (dm_args,GCSPRINTF ("%d" , b_info->max_vcpus)); }for (i =0 ; i < num_nics; i++) {if (nics[i].nictype ==LIBXL_NIC_TYPE_VIF_IOEMU ) {
@@ -1068,8 +1063,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,flexarray_append (dm_args,"-device" );flexarray_append (dm_args,GCSPRINTF ("%s,id=nic%d,netdev=net%d,mac=%s" , - nics[i].model, nics[i].devid, - nics[i].devid, smac)); + nics[i].model, nics[i].devid, + nics[i].devid, smac));flexarray_append (dm_args,"-netdev" ); flexarray_append(dm_args, GCSPRINTF( "type=tap,id=net%d,ifname=%s,"
@@ -1640,7 +1635,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,char *name;case STUBDOM_CONSOLE_LOGGING : name =GCSPRINTF ("qemu-dm-%s" , -libxl_domid_to_name (ctx, guest_domid)); +libxl_domid_to_name (ctx, guest_domid)); ret =libxl_create_logfile (ctx, name, &filename);if (ret) goto out; console[i].output =GCSPRINTF ("file:%s" , filename);
Signature · 1 line
2.1.4
Quoted 2 lines · Wei Liu
There are mixed usage of
libxl__sprintf(gc)and GCSPRINTF. Convert alllibxl__sprintfto GCSPRINTF.
This looks like pointless churn /and/ GCSPRINTF is /less/ readable than libxl__sprintf(gc,...) because the reader now has to also look up what GCSPRINTF does.
David
Quoted 8 lines · David Vrabel
Quoted 2 lines · Wei Liu
There are mixed usage of
libxl__sprintf(gc)and GCSPRINTF. Convert alllibxl__sprintfto GCSPRINTF.This looks like pointless churn /and/ GCSPRINTF is /less/ readable than
libxl__sprintf(gc,...)because the reader now has to also look up what GCSPRINTF does.
The goal is to make things consistent across libxl code base. Currently there are 400+ GCSPRINTF vs 240+ libxl__sprintf, which is causing confusion for contributors. If you think libxl__sprintf is clear you can submit patch to turn that 400+ GCSPRINTF to libxl__sprintf.
Wei.
Quoted 3 lines
David