mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools: libxl: Remove unnecessary trailing \n from log messages.
Both xl's LOG and the various libxl logging mechanisms automatically
include a trailing \n.
Remove all unnecessary \n's from the logs messages with the following
semantic patch.
spatch also reindents (I couldn't see how to make it stop). In general
it has improved matters but in 1 case it has introduced a long line,
this will be fixed in the next patch.
Semantic patch, run as
spatch --in-place --no-includes --include-headers \
--sp-file libxl-log-nl.spatch \
tools/libxl/libxl*.[ch] tools/libxl/xl*.[ch]
=========
// Heavily inspired by https://lkml.org/lkml/2014/9/12/134
virtual patch
virtual context
virtual org
virtual report
// First the macros
@macro1@
identifier FN =~ "LOG|LOGE|LOGEV";
constant s1 =~ ".*\\n";
constant level;
@@
FN(level, s1, ...);
@script:python macro2@
s1 << macro1.s1;
s2;
@@
coccinelle.s2 = s1[:-3]+'"';
@macro3@
identifier macro1.FN;
constant macro1.level;
expression args;
constant macro1.s1;
identifier macro2.s2;
@@
-FN(level, s1, args);
+FN(level, s2, args);
@macro4@
identifier macro1.FN;
constant macro1.level;
constant macro1.s1;
identifier macro2.s2;
@@
-FN(level, s1);
+FN(level, s2);
// Now the functions
@log1@
identifier FN =~ "LIBXL__LOG(|_ERRNO|_ERRNOVAL)";
constant s1 =~ ".*\\n";
expression ctx;
constant level;
@@
FN(ctx, level, s1, ...);
@script:python log2@
s1 << log1.s1;
s2;
@@
coccinelle.s2 = s1[:-3]+'"';
@log3@
identifier log1.FN;
constant log1.level;
expression args;
expression log1.ctx;
constant log1.s1;
identifier log2.s2;
@@
-FN(ctx, level, s1, args);
+FN(ctx, level, s2, args);
@log4@
identifier log1.FN;
constant log1.level;
expression log1.ctx;
constant log1.s1;
identifier log2.s2;
@@
-FN(ctx, level, s1);
+FN(ctx, level, s2);
=========
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
7d134b44ac
commit
cb86677d2d
11 files changed
+44
-40
No files matched your search
+24
-19
@@ -699,7 +699,7 @@ static int cpupool_info(libxl__gc *gc,
|
||||
if (xcinfo == NULL)
|
||||
{
|
||||
if (exact || errno != ENOENT)
|
||||
LOGE(ERROR, "failed to get info for cpupool%d\n", poolid);
|
||||
LOGE(ERROR, "failed to get info for cpupool%d", poolid);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -2261,7 +2261,7 @@ int libxl_device_vtpm_getinfo(libxl_ctx *ctx,
|
||||
val = libxl__xs_read(gc, XBT_NULL,
|
||||
GCSPRINTF("%s/uuid", vtpminfo->backend));
|
||||
if(val == NULL) {
|
||||
LOG(ERROR, "%s/uuid does not exist!\n", vtpminfo->backend);
|
||||
LOG(ERROR, "%s/uuid does not exist!", vtpminfo->backend);
|
||||
goto err;
|
||||
}
|
||||
if(libxl_uuid_from_string(&(vtpminfo->uuid), val)) {
|
||||
@@ -2352,8 +2352,8 @@ int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
|
||||
device->backend_kind = LIBXL__DEVICE_KIND_QDISK;
|
||||
break;
|
||||
default:
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n",
|
||||
disk->backend);
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
|
||||
"unrecognized disk backend type: %d", disk->backend);
|
||||
return ERROR_INVAL;
|
||||
}
|
||||
|
||||
@@ -2495,7 +2495,7 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
|
||||
dev = libxl__blktap_devpath(gc, disk->pdev_path,
|
||||
disk->format);
|
||||
if (!dev) {
|
||||
LOG(ERROR, "failed to get blktap devpath for %p\n",
|
||||
LOG(ERROR, "failed to get blktap devpath for %p",
|
||||
disk->pdev_path);
|
||||
rc = ERROR_FAIL;
|
||||
goto out;
|
||||
@@ -2519,7 +2519,9 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
|
||||
assert(device->backend_kind == LIBXL__DEVICE_KIND_QDISK);
|
||||
break;
|
||||
default:
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend type: %d\n", disk->backend);
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
|
||||
"unrecognized disk backend type: %d",
|
||||
disk->backend);
|
||||
rc = ERROR_INVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -4573,7 +4575,9 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
|
||||
|
||||
mem = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/memory/target", dompath));
|
||||
if (!mem) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "cannot get memory info from %s/memory/target\n", dompath);
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"cannot get memory info from %s/memory/target",
|
||||
dompath);
|
||||
goto out;
|
||||
}
|
||||
memorykb = strtoul(mem, &endptr, 10);
|
||||
@@ -4583,7 +4587,8 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
|
||||
}
|
||||
|
||||
if (max_memkb < memorykb) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "memory_static_max must be greater than or or equal to memory_dynamic_max\n");
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"memory_static_max must be greater than or or equal to memory_dynamic_max");
|
||||
goto out;
|
||||
}
|
||||
rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + LIBXL_MAXMEM_CONSTANT);
|
||||
@@ -4722,8 +4727,8 @@ retry_transaction:
|
||||
goto retry_transaction;
|
||||
} else if (!target) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"cannot get target memory info from %s/memory/target\n",
|
||||
dompath);
|
||||
"cannot get target memory info from %s/memory/target",
|
||||
dompath);
|
||||
abort_transaction = 1;
|
||||
goto out;
|
||||
} else {
|
||||
@@ -4740,8 +4745,8 @@ retry_transaction:
|
||||
"%s/memory/static-max", dompath));
|
||||
if (!memmax) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"cannot get memory info from %s/memory/static-max\n",
|
||||
dompath);
|
||||
"cannot get memory info from %s/memory/static-max",
|
||||
dompath);
|
||||
abort_transaction = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -4775,8 +4780,8 @@ retry_transaction:
|
||||
|
||||
if (!domid && new_target_memkb < LIBXL_MIN_DOM0_MEM) {
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
|
||||
"new target %d for dom0 is below the minimum threshold\n",
|
||||
new_target_memkb);
|
||||
"new target %d for dom0 is below the minimum threshold",
|
||||
new_target_memkb);
|
||||
abort_transaction = 1;
|
||||
goto out;
|
||||
}
|
||||
@@ -4856,13 +4861,13 @@ static int libxl__get_memory_target(libxl__gc *gc, uint32_t domid,
|
||||
goto out;
|
||||
} else if (!target) {
|
||||
LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
|
||||
"cannot get target memory info from %s/memory/target\n",
|
||||
dompath);
|
||||
"cannot get target memory info from %s/memory/target",
|
||||
dompath);
|
||||
goto out;
|
||||
} else if (!static_max) {
|
||||
LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
|
||||
"cannot get target memory info from %s/memory/static-max\n",
|
||||
dompath);
|
||||
"cannot get target memory info from %s/memory/static-max",
|
||||
dompath);
|
||||
goto out;
|
||||
} else {
|
||||
target_memkb = strtoul(target, &endptr, 10);
|
||||
@@ -5654,7 +5659,7 @@ int libxl_sched_credit_params_set(libxl_ctx *ctx, uint32_t poolid,
|
||||
}
|
||||
if (scinfo->ratelimit_us > scinfo->tslice_ms*1000) {
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
|
||||
"Ratelimit cannot be greater than timeslice\n");
|
||||
"Ratelimit cannot be greater than timeslice");
|
||||
return ERROR_INVAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
|
||||
xc_config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
|
||||
break;
|
||||
default:
|
||||
LOG(ERROR, "Unknown GIC version %d\n",
|
||||
LOG(ERROR, "Unknown GIC version %d",
|
||||
d_config->b_info.arch_arm.gic_version);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ int libxl__arch_domain_save_config(libxl__gc *gc,
|
||||
d_config->b_info.arch_arm.gic_version = LIBXL_GIC_VERSION_V3;
|
||||
break;
|
||||
default:
|
||||
LOG(ERROR, "Unexpected gic version %u\n", xc_config->gic_version);
|
||||
LOG(ERROR, "Unexpected gic version %u", xc_config->gic_version);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ static const struct arch_info *get_arch_info(libxl__gc *gc,
|
||||
if (!strcmp(dom->guest_type, info->guest_type))
|
||||
return info;
|
||||
}
|
||||
LOG(ERROR, "Unable to find arch FDT info for %s\n", dom->guest_type);
|
||||
LOG(ERROR, "Unable to find arch FDT info for %s", dom->guest_type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1460,7 +1460,7 @@ static void domcreate_attach_dtdev(libxl__egc *egc,
|
||||
LOG(DEBUG, "Assign device \"%s\" to dom%u", dtdev->path, domid);
|
||||
ret = xc_assign_dt_device(CTX->xch, domid, dtdev->path);
|
||||
if (ret < 0) {
|
||||
LOG(ERROR, "xc_assign_dtdevice failed: %d\n", ret);
|
||||
LOG(ERROR, "xc_assign_dtdevice failed: %d", ret);
|
||||
goto error_out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ const char *libxl__domain_device_model(libxl__gc *gc,
|
||||
break;
|
||||
default:
|
||||
LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
|
||||
"invalid device model version %d\n",
|
||||
"invalid device model version %d",
|
||||
info->device_model_version);
|
||||
dm = NULL;
|
||||
break;
|
||||
@@ -124,7 +124,7 @@ libxl__xc_device_get_rdm(libxl__gc *gc,
|
||||
if (rc) {
|
||||
*nr_entries = 0;
|
||||
*xrdm = NULL;
|
||||
LOG(ERROR, "Could not get reserved device memory maps.\n");
|
||||
LOG(ERROR, "Could not get reserved device memory maps.");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ int libxl__domain_cpupool(libxl__gc *gc, uint32_t domid)
|
||||
ret = xc_domain_getinfolist(CTX->xch, domid, 1, &info);
|
||||
if (ret != 1)
|
||||
{
|
||||
LOGE(ERROR, "getinfolist failed %d\n", ret);
|
||||
LOGE(ERROR, "getinfolist failed %d", ret);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
if (info.domain != domid)
|
||||
|
||||
@@ -340,19 +340,18 @@ _hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *lock)
|
||||
int rc = 0;
|
||||
|
||||
if (pthread_mutexattr_init(&attr) != 0) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"Failed to init mutex attributes\n");
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"Failed to init mutex attributes");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"Failed to set mutex attributes\n");
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"Failed to set mutex attributes");
|
||||
rc = ERROR_FAIL;
|
||||
goto out;
|
||||
}
|
||||
if (pthread_mutex_init(lock, &attr) != 0) {
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
|
||||
"Failed to init mutex\n");
|
||||
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to init mutex");
|
||||
rc = ERROR_FAIL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ struct libxl__yajl_ctx {
|
||||
const unsigned char *buf = NULL; \
|
||||
size_t len = 0; \
|
||||
yajl_gen_get_buf((yajl_ctx)->g, &buf, &len); \
|
||||
LIBXL__LOG(libxl__gc_owner((yajl_ctx)->gc), \
|
||||
LIBXL__LOG_DEBUG, "response:\n%s", buf); \
|
||||
LIBXL__LOG(libxl__gc_owner((yajl_ctx)->gc), LIBXL__LOG_DEBUG,
|
||||
"response:\n", buf); \
|
||||
yajl_gen_free((yajl_ctx)->g); \
|
||||
(yajl_ctx)->g = NULL; \
|
||||
} while (0)
|
||||
@@ -487,7 +487,7 @@ int libxl__json_object_append_to(libxl__gc *gc, libxl__json_object *obj,
|
||||
break;
|
||||
default:
|
||||
LIBXL__LOG(libxl__gc_owner(gc), LIBXL__LOG_ERROR,
|
||||
"Try append an object is not a map/array (%i)\n",
|
||||
"Try append an object is not a map/array (%i)",
|
||||
dst->type);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
|
||||
switch (dev->backend_kind) {
|
||||
case LIBXL__DEVICE_KIND_VBD:
|
||||
if (num_exec != 0) {
|
||||
LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec);
|
||||
LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
|
||||
*/
|
||||
if ((num_exec > 1) ||
|
||||
(libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
|
||||
LOG(DEBUG, "num_exec %d, not running hotplug scripts\n", num_exec);
|
||||
LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
|
||||
if (o) {
|
||||
rc = qmp_handle_response(gc, qmp, o);
|
||||
} else {
|
||||
LOG(ERROR, "Parse error of : %s\n", s);
|
||||
LOG(ERROR, "Parse error of : %s", s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ void libxl__stream_write_start(libxl__egc *egc,
|
||||
|
||||
default:
|
||||
rc = ERROR_FAIL;
|
||||
LOG(ERROR, "Unknown emulator for HVM domain\n");
|
||||
LOG(ERROR, "Unknown emulator for HVM domain");
|
||||
goto err;
|
||||
}
|
||||
stream->emu_sub_hdr.index = 0;
|
||||
|
||||
@@ -494,7 +494,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
|
||||
e820_entries++;
|
||||
|
||||
if (e820_entries >= E820MAX) {
|
||||
LOG(ERROR, "Ooops! Too many entries in the memory map!\n");
|
||||
LOG(ERROR, "Ooops! Too many entries in the memory map!");
|
||||
rc = ERROR_INVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||