chiark / gitweb /
bootchart: use _cleanup_close_
[elogind.git] / src / bootchart / svg.c
index 4c78abda63af2e3d80d2c7fb342e3188b67a6d1f..79476716a6bfe20563c9c06486c7043d0acc004b 100644 (file)
@@ -103,7 +103,7 @@ static void svg_header(void)
         svg("<!-- your browser to file:///run/log/ and click. This bootchart was      -->\n\n");
 
         svg("<!-- generated by bootchart version %s, running with options:  -->\n", VERSION);
-        svg("<!-- hz=\"%f\" n=\"%d\" -->\n", hz, len);
+        svg("<!-- hz=\"%f\" n=\"%d\" -->\n", hz, samples_len);
         svg("<!-- x=\"%f\" y=\"%f\" -->\n", scale_x, scale_y);
         svg("<!-- rel=\"%d\" f=\"%d\" -->\n", relative, filter);
         svg("<!-- p=\"%d\" e=\"%d\" -->\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("<text class=\"t1\" x=\"0\" y=\"30\">Bootchart for %s - %s</text>\n",
@@ -222,7 +219,7 @@ static void svg_title(const char *build)
                 svg("Not detected");
         svg("</text>\n");
         svg("<text class=\"sec\" x=\"20\" y=\"155\">Graph data: %.03f samples/sec, recorded %i total, dropped %i samples, %i processes, %i filtered</text>\n",
-            hz, len, overrun, pscount, pfiltered);
+            hz, samples_len, overrun, pscount, pfiltered);
 }