]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
tools: libxl: Remove unnecessary trailing \n from log messages.
authorIan Campbell <ian.campbell@citrix.com>
Wed, 12 Aug 2015 13:56:01 +0000 (14:56 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 13 Aug 2015 10:01:23 +0000 (11:01 +0100)
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>
tools/libxl/libxl.c
tools/libxl/libxl_arm.c
tools/libxl/libxl_create.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.c
tools/libxl/libxl_json.c
tools/libxl/libxl_linux.c
tools/libxl/libxl_qmp.c
tools/libxl/libxl_stream_write.c
tools/libxl/libxl_x86.c

index 083f09945974e05e99ad0262e081211a05b952c0..865e162ed99e728d63c6d696c580c3471ef8520d 100644 (file)
@@ -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;
     }
 
index a310737482a3f77ba073bef0553767e5e3cca3f1..0af8010dbc3f533379e09b925483d13dabead85f 100644 (file)
@@ -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;
 }
 
index 2348ffcf399335e2ce8ea937378e0acd519a14af..51281608cc605c273b52ead39e35c77cc712e8f2 100644 (file)
@@ -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;
         }
     }
index 02c016233d9cd88c4e7d84953ccda19e87b1397f..c84085e89a2c6577aa3a18cdf6fa00224754af9b 100644 (file)
@@ -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;
 }
index e1f11a3e500dd8c43778b324b011e07eefce4b2b..4a061ec711ed27ed11c53fde2579ff281347d346 100644 (file)
@@ -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)
index 23fd75147ee1cf3d78ae570d58103638c505f4cc..366ea05886c23e3cfcb7f8510bccd64d75aecc29 100644 (file)
@@ -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;
     }
index 346929a2b12218b752701aaa718bf8e40d16e733..3b695ddb4c0ed965a437528137156aeebf3cfabb 100644 (file)
@@ -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;
         }
index 4fbcba1061b88ce629835ddc2916787badfe13dd..be4afc68c4348234b50782340b9891fb764260d0 100644 (file)
@@ -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;
         }
index 965c5074f1adcacebfb455f984a72053eb26c178..f798de74c5d9015a830c1e3b0c799bc28c416581 100644 (file)
@@ -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;
                 }
 
index 10a9e0f13a5620bf8cb168aa7cbf4a5f68a2ca7e..52a60d7726fb451761dd6f4187cd2c4afba710ec 100644 (file)
@@ -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;
index b379e09b2019a18ecfc3602a17bc13efc55f157d..896f34c45b5f984b14b9bbe24b5717848cc48386 100644 (file)
@@ -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;
     }