]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commit
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)
commitcb86677d2d1e061bf8d057bf1dd06cbb60210f33
tree05caea67a66a54be8251fa8f017cdec2dae65ea1
parent7d134b44ac32918744563640cb319f7b3184969d
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>
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