X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fsvg.c;h=79476716a6bfe20563c9c06486c7043d0acc004b;hb=0ea9530d401827e299c6e04a433e69a7a2a89d80;hp=f8a37768733490866aa8ab91740031097ed4cee3;hpb=8846199d2006824debdc587df73826a7efa31d24;p=elogind.git
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index f8a377687..79476716a 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -103,7 +103,7 @@ static void svg_header(void)
svg("\n\n");
svg("\n", VERSION);
- svg("\n", hz, len);
+ svg("\n", hz, samples_len);
svg("\n", scale_x, scale_y);
svg("\n", relative, filter);
svg("\n", pss, entropy);
@@ -150,7 +150,7 @@ static void svg_title(const char *build)
char date[256] = "Unknown";
char cpu[256] = "Unknown";
char *c;
- FILE *f;
+ FILE _cleanup_fclose_ *f = NULL;
time_t t;
int fd;
struct utsname uts;
@@ -161,7 +161,6 @@ static void svg_title(const char *build)
if (f) {
if (!fgets(cmdline, 255, f))
sprintf(cmdline, "Unknown");
- fclose(f);
}
/* extract root fs so we can find disk model name in sysfs */
@@ -176,7 +175,6 @@ static void svg_title(const char *build)
if (f) {
if (!fgets(model, 255, f))
fprintf(stderr, "Error reading disk model for %s\n", rootbdev);
- fclose(f);
}
}
@@ -198,7 +196,6 @@ static void svg_title(const char *build)
break;
}
}
- fclose(f);
}
svg("Bootchart for %s - %s\n",
@@ -222,7 +219,7 @@ static void svg_title(const char *build)
svg("Not detected");
svg("\n");
svg("Graph data: %.03f samples/sec, recorded %i total, dropped %i samples, %i processes, %i filtered\n",
- hz, len, overrun, pscount, pfiltered);
+ hz, samples_len, overrun, pscount, pfiltered);
}
@@ -267,6 +264,20 @@ static void svg_graph_box(int height)
}
}
+/* xml comments must not contain "--" */
+static char* xml_comment_encode(const char* name) {
+ char *enc_name, *p;
+
+ enc_name = strdup(name);
+ if (!enc_name)
+ return NULL;
+
+ for (p = enc_name; *p; p++)
+ if (p[0] == '-' && p[1] == '-')
+ p[1] = '_';
+
+ return enc_name;
+}
static void svg_pss_graph(void)
{
@@ -369,7 +380,7 @@ static void svg_pss_graph(void)
top = bottom + ps->sample[i].pss;
/* draw a label with the process / PID */
if ((i == 1) || (ps->sample[i - 1].pss <= (100 * scale_y)))
- svg(" %s [%i]\n",
+ svg(" [%i]\n",
time_to_graph(sampletime[i] - graph_start),
kb_to_graph(1000000.0 - bottom - ((top - bottom) / 2)),
ps->name,
@@ -383,10 +394,17 @@ static void svg_pss_graph(void)
svg("\n\n\n");
ps = ps_first;
while (ps->next_ps) {
+ char _cleanup_free_*enc_name;
ps = ps->next_ps;
if (!ps)
continue;
- svg("\n", ps->name, ps->pid,
+ svg("\n", enc_name, ps->pid,
ps->ppid, ps->total);
/* it would be nice if we could use exec_start from /proc/pid/sched,
@@ -898,7 +922,7 @@ static void svg_ps_bars(void)
w = ps->first;
/* text label of process name */
- svg(" %s [%i] %.03fs\n",
+ svg(" [%i]%.03fs\n",
time_to_graph(sampletime[w] - graph_start) + 5.0,
ps_to_graph(j) + 14.0,
ps->name,
@@ -1002,7 +1026,7 @@ static void svg_top_ten_cpu(void)
svg("Top CPU consumers:\n");
for (n = 0; n < 10; n++)
- svg("%3.03fs - %s[%d]\n",
+ svg("%3.03fs - [%d]\n",
20 + (n * 13),
top[n]->total,
top[n]->name,
@@ -1037,7 +1061,7 @@ static void svg_top_ten_pss(void)
svg("Top PSS consumers:\n");
for (n = 0; n < 10; n++)
- svg("%dK - %s[%d]\n",
+ svg("%dK - [%d]\n",
20 + (n * 13),
top[n]->pss_max,
top[n]->name,