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

[Xen-changelog] [xen master] tools: libxl: Remove unnecessary trailing \n from log messages.



commit cb86677d2d1e061bf8d057bf1dd06cbb60210f33
Author:     Ian Campbell <ian.campbell@xxxxxxxxxx>
AuthorDate: Wed Aug 12 14:56:01 2015 +0100
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Thu Aug 13 11:01:23 2015 +0100

    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@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c              |   43 +++++++++++++++++++++----------------
 tools/libxl/libxl_arm.c          |    6 ++--
 tools/libxl/libxl_create.c       |    2 +-
 tools/libxl/libxl_dm.c           |    4 +-
 tools/libxl/libxl_dom.c          |    2 +-
 tools/libxl/libxl_internal.c     |   11 ++++-----
 tools/libxl/libxl_json.c         |    6 ++--
 tools/libxl/libxl_linux.c        |    4 +-
 tools/libxl/libxl_qmp.c          |    2 +-
 tools/libxl/libxl_stream_write.c |    2 +-
 tools/libxl/libxl_x86.c          |    2 +-
 11 files changed, 44 insertions(+), 40 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 083f099..865e162 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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;
     }
 
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index a310737..0af8010 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -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;
 }
 
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 2348ffc..5128160 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -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;
         }
     }
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 02c0162..c84085e 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -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;
 }
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index e1f11a3..4a061ec 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -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)
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 23fd751..366ea05 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -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;
     }
diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index 346929a..3b695dd 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -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;
         }
diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 4fbcba1..be4afc6 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -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;
         }
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 965c507..f798de7 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -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;
                 }
 
diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c
index 10a9e0f..52a60d7 100644
--- a/tools/libxl/libxl_stream_write.c
+++ b/tools/libxl/libxl_stream_write.c
@@ -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;
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index b379e09..896f34c 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -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;
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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