Re: [systemd-devel] [PATCH v2 2/2] bootchart: escape non printable process name
On Wed, 12.11.14 19:49, WaLyong Cho (walyong@samsung.com) wrote: Applied both. Made some changes regarding UTF8 escaping, see other mail. > --- > src/bootchart/svg.c | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c > index faf377e..e5569e1 100644 > --- a/src/bootchart/svg.c > +++ b/src/bootchart/svg.c > @@ -39,6 +39,7 @@ > #include "svg.h" > #include "bootchart.h" > #include "list.h" > +#include "utf8.h" > > #define time_to_graph(t) ((t) * arg_scale_x) > #define ps_to_graph(n) ((n) * arg_scale_y) > @@ -1006,12 +1007,15 @@ static void svg_ps_bars(void) { > /* pass 2 - ps boxes */ > ps = ps_first; > while ((ps = get_next_ps(ps))) { > -_cleanup_free_ char *enc_name = NULL; > +_cleanup_free_ char *enc_name = NULL, *escaped = NULL; > double endtime; > double starttime; > int t; > > -enc_name = xml_comment_encode(ps->name); > +if (!utf8_is_printable(ps->name, strlen(ps->name))) > +escaped = utf8_escape_non_printable(ps->name); > + > +enc_name = xml_comment_encode(escaped ? escaped : ps->name); > if (!enc_name) > continue; > > @@ -1100,7 +1104,7 @@ static void svg_ps_bars(void) { > svg(" > [%i]%.03fs %s\n", > time_to_graph(w - graph_start) + 5.0, > ps_to_graph(j) + 14.0, > -ps->name, > +escaped ? escaped : ps->name, > ps->pid, > (ps->last->runtime - ps->first->runtime) / 10.0, > arg_show_cgroup ? ps->cgroup : ""); > -- > 1.9.3 > > Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 2/2] bootchart: escape non printable process name
--- src/bootchart/svg.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index faf377e..e5569e1 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -39,6 +39,7 @@ #include "svg.h" #include "bootchart.h" #include "list.h" +#include "utf8.h" #define time_to_graph(t) ((t) * arg_scale_x) #define ps_to_graph(n) ((n) * arg_scale_y) @@ -1006,12 +1007,15 @@ static void svg_ps_bars(void) { /* pass 2 - ps boxes */ ps = ps_first; while ((ps = get_next_ps(ps))) { -_cleanup_free_ char *enc_name = NULL; +_cleanup_free_ char *enc_name = NULL, *escaped = NULL; double endtime; double starttime; int t; -enc_name = xml_comment_encode(ps->name); +if (!utf8_is_printable(ps->name, strlen(ps->name))) +escaped = utf8_escape_non_printable(ps->name); + +enc_name = xml_comment_encode(escaped ? escaped : ps->name); if (!enc_name) continue; @@ -1100,7 +1104,7 @@ static void svg_ps_bars(void) { svg(" [%i]%.03fs %s\n", time_to_graph(w - graph_start) + 5.0, ps_to_graph(j) + 14.0, -ps->name, +escaped ? escaped : ps->name, ps->pid, (ps->last->runtime - ps->first->runtime) / 10.0, arg_show_cgroup ? ps->cgroup : ""); -- 1.9.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v2 2/2] bootchart: escape non printable process name
On Mon, 03.11.14 15:00, WaLyong Cho (walyong@samsung.com) wrote: > --- > src/bootchart/svg.c | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c > index faf377e..e5569e1 100644 > --- a/src/bootchart/svg.c > +++ b/src/bootchart/svg.c > @@ -39,6 +39,7 @@ > #include "svg.h" > #include "bootchart.h" > #include "list.h" > +#include "utf8.h" > > #define time_to_graph(t) ((t) * arg_scale_x) > #define ps_to_graph(n) ((n) * arg_scale_y) > @@ -1006,12 +1007,15 @@ static void svg_ps_bars(void) { > /* pass 2 - ps boxes */ > ps = ps_first; > while ((ps = get_next_ps(ps))) { > -_cleanup_free_ char *enc_name = NULL; > +_cleanup_free_ char *enc_name = NULL, *escaped = NULL; > double endtime; > double starttime; > int t; > > -enc_name = xml_comment_encode(ps->name); > +if (!utf8_is_printable(ps->name, strlen(ps->name))) > +escaped = utf8_escape_non_printable(ps->name); > + > +enc_name = xml_comment_encode(escaped ? escaped : ps->name); Not liking the nonchalant ignoring of OOM here, but I figure the bootchart code isn't very good at than anyway... Lennart -- Lennart Poettering, Red Hat ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH v2 2/2] bootchart: escape non printable process name
--- src/bootchart/svg.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index faf377e..e5569e1 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -39,6 +39,7 @@ #include "svg.h" #include "bootchart.h" #include "list.h" +#include "utf8.h" #define time_to_graph(t) ((t) * arg_scale_x) #define ps_to_graph(n) ((n) * arg_scale_y) @@ -1006,12 +1007,15 @@ static void svg_ps_bars(void) { /* pass 2 - ps boxes */ ps = ps_first; while ((ps = get_next_ps(ps))) { -_cleanup_free_ char *enc_name = NULL; +_cleanup_free_ char *enc_name = NULL, *escaped = NULL; double endtime; double starttime; int t; -enc_name = xml_comment_encode(ps->name); +if (!utf8_is_printable(ps->name, strlen(ps->name))) +escaped = utf8_escape_non_printable(ps->name); + +enc_name = xml_comment_encode(escaped ? escaped : ps->name); if (!enc_name) continue; @@ -1100,7 +1104,7 @@ static void svg_ps_bars(void) { svg(" [%i]%.03fs %s\n", time_to_graph(w - graph_start) + 5.0, ps_to_graph(j) + 14.0, -ps->name, +escaped ? escaped : ps->name, ps->pid, (ps->last->runtime - ps->first->runtime) / 10.0, arg_show_cgroup ? ps->cgroup : ""); -- 1.9.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel